texts: How to use Content Access Module API to Revoke Owner Edit for a Node?

texts: I have a custom field for a manager to approve a node. When the node status is set to "approved" I need to revoke the owner's permission to edit the node. I am using the Content Access module, but can't figure out which API call will revoke the owner's permission to edit the particular node.


texts: Alright, I've got an odd issue with what I am guessing to be is size. I have uploaded several images to a site, and while they upload correctly (meaning I can find the image in the appropriate folder without loss of quality), I can't see images larger than what I am guessing is from 400-500KB. As you can see, the two bottom images are 353KB or less in size, and I can see them. However, the upper three are 850KB or larger and cannot be seen, am I doing something wrong with this? Thanks.


texts: Views - How to display results in nested groups?

texts:
I have a View listing out members of staff. Each staff member belongs to a department, or sub-department. I want to list out all staff members but group them under their (sub)-department in a nested manner. For example:

# School Board
John Doe

# Teaching Staff
Jane Doe

    ## Chemistry
    Eric Betzig

    ## Physics
    Shuji Nakamura
    Isamu Akasaki

I know you can use the Group by Fields option, as described in this answer, but it doesn't allow for nesting:

# School Board
John Doe

# Teaching Staff
Jane Doe

# Chemistry // Not nested
Eric Betzig

# Physics // Not nested
Shuji Nakamura
Isamu Akasaki


texts: How to implement this event tracking to google analytics module

texts:
I need to implement this event

setTimeout('pageTracker._trackEvent(\'NoBounce\',\'NoBounce\',\'Over 30 seconds\')',30000);

with the Google Analytics event tracking module, I do not understand how to proceed and create this event, The event is useful for count a bounced visitor only if the visitor leaves before 30 secons, I need to add that event, any help would be appreciated. Thanks


texts: How to send formatted html email using swiftmailer?

texts: How can I send styled html body using custom module to send an email. I am using swiftmailer module. With that I am able to send normal body, but I am not able to use html tags or css. How can I do this?


texts:
I am storing some data into the database

try {
      $fields = array(
        'uid' => \Drupal::currentUser()->id(),
        'value' => $form_state->getValue('blood_sugar'),
        'created' => time(),
      );
      Database::getConnection()->insert('blood_sugar_monitor')->fields($fields)->execute();
}

Later on I would like to check the latest inserted row to check if it was inserted within the last hour.

Could someone provide an example of fetching one item from the database?


texts: Putting subsites outside of the sites directory

texts:
When number of subsites increase, is there a way to put subsites in a directory outside of sites directory or even outside of drupal base directory, like /var ?

Are symlinks the only solution?


texts:
I have an Article content type that has related_news field. It displays inside the article text as a box.

In node--article.tpl.php I have the following code:

<?php
  // We hide the comments and links now so that we can render them later.
     hide($content['comments']);
     hide($content['links']);
     hide($content['field_addthis']);
     print render($content);
?>

I found that I can hide the related_news field using hide as:

hide($content['field_related_news']);

Is there any function like hide that could able to wrap the that field in custom HTML like
...
?

I tried the following:

//$content['field_related_news'] = "***". $content['field_related_news']."***";

But it causes to hide the field from the node.


texts: How to supress the second sidebar in Zen theme?

texts:
I have nodes that include blocks in the second sidebar. When all the blocks are removed, every node's content takes up the width of the page (and extends into the sidebar region) which is what I want. When I add any block, even if it isn't displaying on that specific node, the sidebar is no longer suppressed.

I also have to re-save every block I add in the second sidebar region, because if not, it displays the title 2x and it displays on every node, regardless of what it is configured for. So for example, if my block of "related links" displays only on node x, it will show also on node y UNLESS I re-save the block configuration.

I have not found anything in my searches here and on Google (most want to add to a sidebar not remove it), and I just don't know where to even start looking for what could be wrong. Any help would be appreciated.


texts: Cannot trigger CKEditor WYSIWYG in form API

texts:
I’m using Drupal 7.18 with CKEditor 4.3 (full package), and trying to get a WYSIWYG field via the form API. My code:

function article_edit_form($form, &$form_state, $article)
{
    // ...

    return array(
        // ...
        'content'  => array(
            '#type'    => 'text_format',
            '#title'   => t('Content'),
            '#format'  => 'full_html',
            '#wysiwyg' => true,
            '#input_format' => '1',
            '#value'   => array(
                'value'  => is_null($article) ? '' : $article->content,
                'format' => 'full_html'
            )
        ),
        // ...
    );
}

But this only displays a regular textarea with a section to choose the “text format”. The CKEditor is installed, enabled and I’m logged as admin.


texts:
The node_api hook provides a bunch of triggers which allows you to customize what might happen on, for example, a presave. The node_api presave opcode triggers an action to occur after clicking on the node 'save' button but BEFORE the information in the node form is inserted into the database. I would like to create a trigger which will be a post-save trigger, to trigger my custom code after clicking the save button but AFTER the node info has been saved into the database. Does anyone have any ideas of how I might create such a trigger?

(I have read the documentation about how to create a trigger, I just don't know to code the trigger I am describing above.)


texts: How to pass variables between theme functions

texts:
I often use functions that contain variables in the following files:

Template.php
Custom Panels Style Plugins
node.tpl.php files
field.tpl.php files
views.tpl.php files

I often needed to pass variables between these functions.

At the moment, I do this by declaring my variable as a global Using PHP's global command. However, I have read that is not best practice. Is there a better way?

I know that Drupal has variable_set() and  variable_get(). However, apparently these have similar problems to using Globals for lots of little variables.


texts: How to rename a content type programmatically

texts:
There are many answers and tutorials addressing the problem of changing the machine name of a content type, or migrating content types. However, I would like to rename a content type, without changing the machine name. This is what I tried:

$type = node_type_load('my_content_type');
$type->name = 'A new name';
node_type_save($type);

But this has no effect. What is the proper way to do this?


texts: Exposed filter on field collection with unlimited values without creating duplicates in view?

texts:
I have a 'Video' content type with a 'video_translations' field collection which is allowed unlimited values.  This field collection has a 'language' and 'url' field attached and I want to be able to filter by the 'language' field.

I've created a relationship in the View for the 'video_translations' field and set the 'Delta' value to 'All'.  Then I created a filter for the filed collection item 'language'.

Filtering works okay like this, but using the Delta value of 'All' creates duplicates in my view when viewing all items.  If I set that Delta value to, for example, '1', then filtering only looks at the first field collection item, and ignores other values.

e.g. if I have 2 'video_translations' on a single Video, the first has the 'language' field set to French, and the second to Russian, then with the Delta value set to 'All', that single Video is displayed twice. Once for each 'video_translations' value. But with the relationship's Delta value set to '1', the Video only appears once, but I'm never able to filter by the second 'language' field.

I want to display the Video once, regardless of how many values the 'video_translations' field has, and also be able to filter by any of the field collection's 'language' field.

How can I do this in Drupal 7?


texts: I've tried to save /admin/structure/block page and open it with Firefox 14.0.1. After this I cannot drag blocks. Why is that? There are no errors in the console. How should I debug such behavior? I need this to better understand why doesn't Drupal work for JS-loaded content. The symptoms look similar.


texts: One Content type multiple usages of that content type, reusable background field?

texts:
As the title says. I have ran into a weird issue. I need to find a way to reuse my content type but allow myself to edit the background of that content type. So eventually i would have a lot of instances of the same content type but the field background image would be reused through out  with different images. Is there any way to achieve this?

Thanking you in advance


texts: Can you save state in the $form_state variable that remains when the form is rebuilt?

texts:
I have a form with a nested subform that has an ajax submit button in it. The subform is built inside a form_alter and attached to the form. The submit buttons #name is made unique by using a UUID generator.
When I press the ajax submit button, Drupal steps through its form builder steps rebuilding the form. Because of this, the same code in the form_alter is called rebuilding the same subform. The problem is that when it is rebuilt, the submit button gets a brand new #name via the UUID generator. As such, Drupal cannot match the _triggering_element to a #name, and the ajax fails.
One solution I thought to try was to attach the #name to $form_state storage when the form is first built hoping that it would be available when the form is rebuilt. For e.g. in the same form_alter I execute:
      $input = $form_state->getUserInput();
      if($input){
        //This only runs when the form is being rebuilt
      }

And I may be able to grab the correct #name out of $form_state storage and set it so Drupal can correctly match and find the right ajax callbacks.
Is something like this possible? Is there a better way to handle this?


texts:
Taxonomy page will have sidebar which will have taxonomy menu items and grid layout with image and brief details.

For example, taxonomy items have brand by certain names, price range, etc. User click on brand name, the grid layout will auto load the brand products without have going to /products/brand_name. On page, it will be /products, and then every brand name will show different products automatically loading on same page.

Is there such a way to do this? Or there is a module which can do that?

Example I found is
http://www.cynosure.com/products/

Click on any from menu on left column, you will see the products reloaded by menu click.


texts:
I have a module and a theme with different names. The module implements hook_theme() to specify a group of templates with 'template' and 'variables' for each. Template files in the module are working as intended.

In my theme, I implement templates/html.tpl.php and templates/page.tpl.php - which both work. But, theme/templates/mytemplate.tpl.php is not overriding the module's template. I have cleared the cache.

What do I have to do so that templates in my theme's templates/ folder will override my own module's templates?


texts:
I have this preprocess function:

function drisco_preprocess_page(&$vars) {
    $node = $vars['node'];
    $vars['theme_hook_suggestions'][] = 'page__node__' . clean_class($node->title);
    array_unshift($vars['theme_hook_suggestions'], 'page__node__' . clean_class($node->title));
    dpm($vars);
}

dpm() tells me my suggestion array looks like this:

0 (String, 26 characters ) page__node__hotel-overview
1 (String, 10 characters ) page__node
2 (String, 13 characters ) page__node__%
3 (String, 14 characters ) page__node__68
4 (String, 10 characters ) page__page
5 (String, 11 characters ) page__hotel
6 (String, 26 characters ) page__node__hotel-overview

My template file is called "page--node--hotel-overview.tpl.php" but isn't being used. I have page.tpl.php template file in my theme dir.

What am I doing wrong?

If I erase the template suggestions array and replace it with my own with only one file in it like thus, it loads the template. If I append or prepend the same suggestion, it just loads page.tpl.php.

$vars['theme_hook_suggestions'] = array('page__node__68');

This is a child theme; could that be making a difference?


texts: Views AJAX Submit is removing my custom classes

texts:
I have custom jQuery that I've added to views filters to my ajax view. When a user selects certain criteria a slideDown and addClass event is triggered and a new set of filters is shown. You can view it here:

https://www.feedingmatters.org/helpful-books

When I click submit the classes that are added to my elements are removed by Drupal. This causes the elements to display: none and now the users can no longer see their filter trail. How can I either stop Drupal from clearing my addClass? The filters need to remain visible so long as the correct criteria are selected.

Note: I tried views dependent filters but it doesn't work as needed.


texts: How to create and set a new menu block in some content region, programmatically

texts:
I want to create a new menu programmatically add for him some elements and the activate it in some content region as a block.

How can I do this programmatically?

I know how to add for an existing menu new elements, but I don't know how to create a new menu.


texts:
I'm trying to have a subpage for a special content type. Everything is working fine, also the breadcrumb is working now.

Only the active menu trail isn't showing up and I really don't know how to hack into the right process. Are there any special functions helping me with this problem?

I tried menu_set_active_trail(), but having problems with nodes placed in a menu by the user where I cannot get the previous menu trail for the node itself.

I hope you can help.Thanks in advanced!


texts:
I am trying to customize a module(quicktabs) for my need. In the hook_block_view, the block['content'] contains an associative array of the contents.
Is there an existing drupal call that renders the associative array in block['content']?


texts:
How can I create a view of nodes that are not tagged with any taxonomy term? Note, terms will be added in time and I wont be able to update the view each time.

Thanks


texts: Why does the Login Destination module not redirect to page?

texts:
I installed and enabled the Login Destination module, and added a login destination rule.

In Internal page or external URL I added myhomepage which is a basic page URL that I want to show after a user performs a login. If authenticated user login then it would not redirect to default page.

My default dashboard page is /cms and dashboard page after user login is cms/96/dashboard (96 in it is the uid of the user).

I have a three types of users:

authenticated user
administrator
employee entry form

And I want authenticated user and employee entry form user to be redirect to cms/{uid}/dashboard (but not administrator users).

Some more details about my configuration:

Redirect upon triggers : I have only select the first one and that is Login, registration, one-time login link
Only the listed pages:

cms
cms/register
cms/*/edit

and under setting tab I have checked both checkboxes.

But when I try to login then user gets redirected to default page.

Any suggestions?


texts: How to show the scroll percentage of the Scroll Depth Analytics module

texts:
I have installed & configured the Scroll Depth Analytics module on my website. I get the output as shown in below image:

I want to get the page title in the event label field so that I can see scroll percentage for an individual page.

Or else is there any way to see the scroll percentage with the path of the page next to it.


texts: How to insert data into node and other tables at the same time?

texts:
I create a Drupal module which install database tables during module installation, table is created using Drupal way. The tables are created perfectly and now i have to insert data into those tables.

Example table structure where i want data to be inserted in sequence :

Node (insert product name)
myproduct_category (take the inserted node id and save the product category and nid at the same time in this table)
myproduct_price (take the inserted node id and save the product price and nid at the same time in this table)

Once data are inserted into database, the site admin will retrieve those saved data and show it in front-end.

here's my current code to insert data into node, i just can't get the last inserted id and continue insert data into other tables :

            $node   = new stdClass();
            $node->title    = $val['ADDRESS_1'];
            $node->type     = 'basil_veco';
            node_object_prepare($node);
            $node->language = LANGUAGE_NONE;
            $node->uid      = $user->uid;
            $node->status   = 1;
            $node->promote  = 0;
            $node->comment  = 0;
            $node->created  = timestamp;

            $node = node_submit($node); // Prepare node for saving
            node_save($node);

Please tell me the way to go about if my approach is not the right way.

Thank you.


texts:
I am absolutely stumbling in configuring OAuth as a service provider in d6 which is mainly used via login. I have worked extensively with Services in D7, but services is not even there in D6.

How should I go about something like this?


texts:
I have to build a module to add custom charges along with the order, e.g., gift wrapping charges.

I am using Drupal 7.


texts: Understanding the Basic Context of Trusted Hosts

texts:
I got the trusted host settings error.

  The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is highly recommended that you configure this. See Protecting against HTTP HOST Header attacks for more information.

I read the Trusted Host Settings documentation but I'm not understanding some of the basic context.

Are the "trusted hosts" me and other administrators who want to be able to administer the site remotely?
If so, would I add my PC's domain to the trusted host list?


texts:
How to get the views field value and make a condition base on that field. Let say may views field is 'field_state'

Example below:

function my_module_views_pre_render(ViewExecutable $view) {
  //current user id
  $user_id = \Drupal::currentUser()->id();
  //load user data
  $user = \Drupal\user\Entity\User::load($user_id);
   // Get user state
  $state = $user->get('field_state')->getValue()[0]['value'];
  if ($state == Views field_state value) {
        $view->field['field_state']->options['exclude'] = TRUE; // exclude field for only this result ???
  }
  else{
    $view->field['field_state']->options['exclude'] = FALSE; // include field for only this result ???
  }
}

Is it possible on views pre-render or I need to use the different hook?


texts: 2 related content types in Views with date field

texts:
In a new project I want to create a View which displays 2 related content types.

The first content type is a school subject having a Date Repeat field with perhaps a weekly repeating rule.

The second content type is a homework with a single Date field and a entity reference field referencing a school subject.

The View I want to generate should be a typical diary which primarily shows the school subjects with a contextual filter set to weekly granularity to first show up the current week. I added the ID of the node, the node title, the date repeat field as fields to display and came across the idea to display the certain homeworks as a child View with the Views Field View module.

The child View should display the homeworks depending on the ID of the relating subject and depending on the time. That arguments come from the subjects in the parent View via the Views Field View module whereas it was easy to pass the node ID as an argument. The problem is about the repeating date field as an argument to the child View. I thought I can do that with a contextual Filter in the child View but with the other filters it seems more logical to me because the contextual filter doesn't work as I want to or rather doesn't working at all. But I cannot pass an argument to the filter in child View from the parent View, can't I?

I hope someone's out there who can help me with it before it finally drives me crazy :)

Edit:

I encountered that it's a bug. When I manually type the Contextual Filters in the preview field of the child View it works properly. So I came across this issue: https://www.drupal.org/node/1914780#comment-7565747

The problem is that date field returns the current date and not the date it contains?! Thats why my view displays content if I set the granularity to 'month' because the displayed fields are set to november but displays nothing when the granularity is set to 'day' which I want to achieve. I tried the hack mentioned in the link above but that returns the current date as well.

I'm confused. Maybe someone has an explanation for that. I would be really grateful!

I also tried to use the Views EVI module or the Views Filter Args module so I can create more complex filters with the date module, but on a date filter you cannot type arguments which are no date-formats.

The Child View:

The parent View:


texts:
I'd like to change the output from the field formatter view from the Field API. I'd like a cleaner markup without unnecessary tags. What's the best way to clean up field formatter view output? Many thanks.

Ideally to change from this:

Visualisation:&nbsp;

to this:

Visualisation:&nbsp;

heres my hook_function_field_formatter_view function:

function mango_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

  $output[0] = array(
    '#theme' => 'container',
    '#attributes' => array(
      'class' => array('something'),
    ),
  );
  return $output;
}


texts: Contextual filter in Views for taxonomy browsing

texts:
I'm having a problem with setting filter value from the URL. What I want to do is to list all terms in a taxonomy node, so I list all terms whose parent ID equals what's provided by URL. I have the relation set, I have the contextual filter set, but unfortunately when I enter %1 as the parent term ID value to be matched by the filter, it's treated literally and returns nothing. That's because no term has the ID of '%1'. However, when I expose the filter and type in the term ID, works as expected.

How do I use the placeholders in the filter definition?


texts: Install Drupal with MS SQL Server 2008 R2

texts:
Is it possible in any ways to connect Drupal 6.x to MS SQL Server 2008 R2 on Windows Server 2008? I am really struggling to find a way out.

please let me know. Any help would be greatly appreciated!


texts: Alter content translation page access based on content's field value

texts:
I have a content type: Test
I want to alter the permission to translate it based on one of it's field value.
Take the following use-case (field type, and role doesn't matter):

If field_test == '1' then the Translate link task should not be displayed (because the current user role does not have permission to view it).

What do you suggest?


texts: Autocomplete not working for Search API with Solr - Drupal 7

texts:
I have these modules installed with Drupal 7:

search_api
search_api_solr
search_api_autocomplete

There is a view configured for search results with exposed full-text search filter, based on the index in Solr set up via Search API. The view is working well, however autocomplete function isn't working at all, no glimpse of it present. Are there any special settings for autocomplete that may need to be activated for the view?


texts:
I'm developing my own module for a customizable bundle of commerce products.

I'm saving the subproducts in a field collection in a line item field.

For some reasons I'm doing this with my module, not using "Include this field on Add to Cart forms for line items of this type" in the line item field settings.

Well, when I use my module I use

$form['#submit'][] = 'commerce_custom_bundle_add_to_cart_form_submit';

inside a

commerce_custom_bundle_form_commerce_cart_add_to_cart_form_alter

(is hook_form_BASE_FORM_ID_alter)

Then my function is executed after the product is added to the cart.

The problem is if I choose to add to cart the same product no new line item is created and the existing quantity is increased in 1, obviously.

But I need a new line item, because my custom field changes and I need to not merge the values chosen in the existing line item. I don't know How to force the creation of a new line item.

I tested, if I not use my code and I expose this field in the add to cart form enabling the "Include this field on Add to Cart forms for line items of this type" in the line item field settings. If the same product is added to the cart with a different value in my custom field, is created a new line item.

How do I force the creation of a new line item?


texts: How to programatically add a pseudo field to views and display the field value based on value of other field?

texts:
I need to add a field to view and display the value of that field depending on the value of other fields already present.

The pseudo field i need to add is not connected with any database table.


texts: How do I import entity related fields using drush migration?

texts:
I am trying to do data migration from a Drupal 7 site to a Drupal 8 site using drush migration.
Example: I am trying to import users which has 5-7 fields and I tried to import fields using:

d7_field
d7_field_instance

These 2 are importing all fields in Drupal 7 (users, taxonomy, node). How can I restrict this to import only specific entity fields?


texts: Why do I need to enable the Drupal Bootstrap theme when using a Bootstrap subtheme?

texts:
I'm trying to learn how to use the Drupal Bootstrap theme to create my own subtheme.  I've added the Bootstrap theme to my drupal/themes directory, and chosen SASS as my sub-theme starterkit (i.e. I've copied drupal/themes/bootstrap/starterkits/sass to drupal/themes/mynewtheme).

I understand the concept of how sub-themes work: the sub-theme inherits the parent theme's resources.  But I don't understand how it works in the case of the Drupal Bootstrap theme.  Once I install the bootstrap framework into my sub-theme (per the instructions on the Drupal Bootstrap sub-theming instructions page), what resources is the sub-theme inheriting from the main theme?


texts:
I'm building a website for ads. Every ad will have an option to become a VIP ad and will be displayed in a blocks with better position.
The users will be able to make their ad into VIP ad by sending an SMS with prefix and their ad nid.

The idea is when a user clicks on the link "Make this ad VIP" will be displaying a field with details how to make the regular ad into VIP content. Let's say the ad node has nid 100, so when the user clicks on "Make this ad VIP" a info will be displayed like this: Send a text message "Prefix100" to the number 2xxx..where 100 will be the node id. On other ad if the node ID is 200, after clicking on "Make this ad VIP" the display text should be: Send a text message "Prefix200" to the number 2xxx.
The module for SMS service is already created.

The field with details will be hidden and "Make this ad VIP" will be a toggle, so I'll use jQuery for that, but how can I set the node id on every node?


texts: How to control from a module the block visibility of a block implemented by another module?

texts:
The default options in the administrative page for block visibility (e.g. admin/build/block/configure/block/3) are not enough for my needs.

For security reasons, I do not wish to use the PHP option (Show if the following PHP code returns TRUE (PHP-mode, experts only).).  I plan to turn off all PHP configuration throughout the site.

The only route that remains available is to create a module that will control the visibility of certain blocks on specific pages.  I am an experienced module developer but I do not know how to implement this specific thing.

What API exist that I could use? Apparently it's possible in Drupal 7. What alternatives do exist in Drupal 6?

Edit:
I actually easily found the answer to my original question. Now, I want to be able to control from my module the visibility of a block implemented by another module. My specific use case is thus: core's aggregator.module  create feed blocks, but I want each feed block to be displayed on pages of certain types authored by specific users who are associated with specific feeds. I could re-implement the whole aggregator_block() or... I could let the aggregator.module do its job and simply control the visibility of the block that it produces. Is it possible?


texts: Why the path alias is like http://domain/http://domain/path?

texts: Adding a simple alias for media [media:url] causes the domain to be listed twice in the URL on media listing page in admin, for example http://domain/http://domain/path. How do I change it to http://domain/path?


texts:
I have strange problem or maybe I'm doing something wrong. I've create my own module. My .info file looks like this:

...
files[] = DdFactory.inc
files[] = ArticleManager.inc
...

In ArticleManager.inc I have class ArticleManager (no namespace). Than I would like to use DFactory (namespace Dd) class in ArticleManager.

Here is the beginning of DFactory.inc:

<?php

namespace Dd;

class Factory
{
...

In ArticleManger I have:

$ob = new \Dd\Factory();

And error:

Fatal error:  Class 'Dd\Factory' not found

I can make it work in two ways. Or I have to remove namespaces than $ob = new Factory(); or I have to add include 'DFactory.inc' at top of ArticleManager.inc

Could somebody tells me how to run it with namespaces and without the include? I'm using drupal 7.


texts: List migrations separately but use single migration class

texts:
I have successfully created a custom migration class which works perfectly but my issue is with the drush migrate-status output.

When I execute drush migrate-status all the XML files I am attempting to migrate from ( I have over a hundred of them each with the same XML structure ) are all compacted into a single migration of 10,000. What I need is for each of my xml files to be listed individually.

I know I can achieve the individual listing by giving each of my XML file a unique migration class but that is inefficient because the code will be exactly the same in all the classes except for the class names.

Can anyone suggest a solution to help achieve my objective?


texts: How to add registration and login in a custom modules

texts:
I am creating a multi step form and in a one step i want to add user registration and login forms in as tabs and i have custom module which is uses to load multi step form,my problem is how i add registration and login forms in my page i try with things but didi't work out

  function garland_user_bar() {
  global $user;
  $output = '';

  if (!$user->uid) {
    $output .= drupal_get_form('user_login_block');
  }
  else {
    $output .= t('
Hi !user, welcome back.
', array('!user' => theme('username', $user)));

    $output .= theme('item_list', array(
      l(t('Your account'), 'user/'.$user->uid, array('title' => t('Edit your account'))),
      l(t('Sign out'), 'logout')));
  }

  $output = '
'.$output.'
';
  return $output;
}


texts: views replacing ul li within a large block of html text

texts:
I have a odd issue.  I am using Views 3 and Drupal 6, when I create content with ul and li tags, Views strips out the list tags and replaces them with the following:

nbsp;
     .nbsp;nbsp;nbsp;nbsp;content
     .nbsp;nbsp;nbsp;nbsp;content
     .nbsp;nbsp;nbsp;nbsp;content
     .nbsp;nbsp;nbsp;nbsp;content
nbsp;

instead of:

content

content

content

content

The content appears correctly in the database, but in display and preview from Views the rewrite happens.

I have the following options:
add default classes
  rewrite output (this was the first thing I checked and is displaying this behavior regardless of this rewrite)
hide contents if empty.

thanks


texts: The URL to change the admin theme isn't the same in Drupal 7 compared to 6.  What is the new URL?


texts: Remove all generated HTML for blocks/regions

texts:
Even though I've overriden the block.html.twig template, as well as region.html.twig, Drupal still outputs a lot of hardcoded HTML in my templates, for Block Regions (from Layouts) for example.

block.html.twig

{% set attributes = attributes.addClass([
  'block-' ~ configuration.provider|clean_class,
  attributes.id
]) %}

region.html.twig

{% if content %}
    {{ content }}
{% endif %}

What am I missing? Why do I keep seeing all this markup?


texts: Is there any management utility for multi-site deployment?

texts:
I'm creating a multi-site instance for a client that makes heavy use of Webform. It's going to be a survey tool of sorts with a single base domain (no sub-domains) and a single SSL certificate.

I've set up the /sites/default the base of what we'd like all other sites to be like. I've gone so far as to attempt this using bash. (This is not my best code and it lives on a throw away VM*):

# Create temporary password
PASS=`tr -dc a-z1-4 </dev/urandom  | head -c 10`

# File structure and empty settings file
mkdir /var/www/html/sites/$1
mkdir /var/www/html/sites/$1/files
cp /var/www/html/sites/default/default.settings.php /var/www/html/sites/$1/settings.php

mysql -u root -p -e "create database $1"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON $1.* TO '$1'@'%' IDENTIFIED AS PASSWORD('$PASS');"

# And here is where things fall apart
drush si ???

My question is, is there a module or utility that could help create a new site inside this multi-site installation? That is, I'd like to clone the model database, create a /sites/new-site/settings.php, and enable a chosen set of modules.

My dream would be to have a drush clone-site command.


texts:
In Ubercart, the uc_order view (admin/structure/views/view/uc_orders) uses exposed filters for status and order ID.

I can add another filter, for example username, email and so on by clicking on Add filter criteria and selecting the criteria (user:username, user:email).

I need to add a filter to filter orders by the roles assigned to customers. There is no option such as user:roles in the filter criteria list to select.

How can I achieve this?


texts: Programmatically submit form / save all nodes

texts:
After migrating all the content from a drupal 6 installation to a drupal 7 one, I ended up with empty fields in my nodes, that are displayed when viewing the node.

However if I edit the node without changing anything and save it, the empty fields are gone (at that point the save function populates the database with the proper null values).

Obviously I can't do that by hand and the solution proposed here: Load and Save nodes with script? doesn't remove the empty fields, even if I actually edit one of the fields. I would like to do this with a php script as I am not familiar at all with Python and the selenium script proposed here: How to programmatically iterate over nodes, load into form, and save the form?.

Now as far as Drupal's form_submit method, how does it actually populate the $form, $form_state variables since I won't be changing anything.

Thanks in advance.


texts: Send php variable to js in drupal 8 block

texts:
I am trying to attach js files attach_library() inside a custom block.

However, I can neither add the libraries via block nor add a library. attach_library() does not accept variables like drupal_add_js.

Any ideas on A) how to send a php variable in the block::build() function and how to attach the library through the build() instead of the twig templates?


texts: Theming with Views generates error undefined variable

texts:
I have a basic installation of Drupal 7, with the Views module. I am using the Garland Template.

When I try to create a new template for my views the following error is thrown:

  Notice: Undefined variable: build in include() (line 2 of /XXX/public_html/themes/garland/views-view—block.tpl.php).

There is only one line in that template:

<?php dpm($fields); ?>

Most likely this is something simple to resolve, but I cannot find the answer.


texts:
I'm using views exposed filter, so the users can select a categories from taxonomy.

This is an example of the structure:

Category 1

-sub category 1

-- sub-sub category 1

-- sub-sub category 2

-sub category 2

Category 2

-sub category 1

-sub category 2

The problem is some of the sub categories has a same name, so for the user it's hardly to recognize which sub category belongs to specific category. I'm trying to style with CSS the main categories in one color and sub categories in other, but with firebug I don't see a way how to do that.
Is there any option or feature for Views exposed filters? So far I've tried with better exposed filters module, but it does not have any option for that.


texts:
What if my nid reaches the maximum allowed value of MySql int type

I have made a drupal.org site search that ends up Here. And also i found Integer Types (Exact Value). In an app that i am about to build is a contact manager for students. Which is supposed to pull gmail, fb contacts in future. My plan is to make each contact a node. Is it a good idea to keep each contact as separate node? Can you suggest any other brilliant mechanism to handle this?

I am worried about the overflow of nid as i made a test run using may own gmail id, which ends up in a 1025 new nodes.

I am using typical Drupal 7.14 installation.


texts: How do I preserve custom files in my Drupal configuration across minor core upgrades?

texts:
When I do a minor upgrade of the core, my custom .htaccess and robots.txt are overwritten.

How do I prevent that?


texts:
I'm loading the edit node form in a block and I want to use Ajax to save the node.

class MyBLockNameBlock extends BlockBase{

  public function build() {
    //I find the $nid i want to display

    $entity = Node::load($nid);
    $form = \Drupal::service('entity.form_builder')->getForm($entity, 'default');

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
      '#ajax' => [
      'wrapper' => $wrapper_id,
      'callback' => '::ajaxCallback',
     ],
   ];

   $block['form'] = $form;
   $block['#markup'] = $this->t('
Project Plan
');
   return $block;

  }

  public function validateForm(array &$form, FormStateInterface $form_state)
  {
    if($form_state->hasAnyErrors()){
      return $form;
    }
  }

  public function ajaxCallback(array &$form, FormStateInterface $form_state)
  {
     return $form;
  }
}

But it doesn't work.
If I change the $form['actions']['submit'] to

$form['actions']['submit'] = [
  '#type' => 'submit',
  '#value' => $this->t('Submit'),
  '#attributes'   =>array('class' => array('btn btn-info use-ajax-submit')),
  '#ajax' => [
    'wrapper' => $wrapper_id,
    'callback' => '::ajaxCallback',
  ],
];

The Ajax works but it doesn't validate the form.
Should I create the validation by myself for each field?

Also I tried ajax_form_entity module but even if the ajax works, reloads the form, doesn't clear the fields after submission and still doesn't validate.

Also I need an extra handler when the user clicks the submit button in order to update a field from an other form.

Any idea?


texts: How can I add a function  in my custom views .tpl page or where can I write my function and call that function in my views .tpl ?


texts: Fatal Error: PDOException: SQLSTATE[42000] [1049] Unknown database

texts:
I have a development site (site1) and created a second (site2) using drush, copied over all modules/themes and continued development. Both were working and I continued module updates in both.  When I returned to site1, I found an error message as follows:

  PDOException: SQLSTATE[42000] [1049] Unknown database 'mydevelopmentDB' in lock_may_be_available() (line 167 of mywebsite/includes/lock.inc).

There features and nodes I would like to use in site2 but I cannot access it. So I created a new site (site3) using drush, copied the contributed modules & themes from site2, and imported the database from site1 into site3, only to get the same error message as from site1.

As I interpret this, situation, the core and contributed module files in site3 should be good, the core is a fresh copy and contributed modules are taken from site2, which is working fine. The settings.php files are identical except for the database, username and password settings match the individual database name. The only difference is the database itself.  Can anyone help identify the table(s) that might have a setting that might cause this problem?


texts: Why are two url aliases being generated for some users?

texts:
I have a site under development, that is a migration from an different cms via the Migrate module. I noticed that the links for a lot of my user profiles are not staff/lastname-firstname as I set in the pathauto settings, but /firstname-lastname.

Looking in the url_alias table I see one alias for staff/lastname-firstname (pid 1644030) and another one (pid 1644031) for firstname-lastname. I point out the pids just because it appears that they are probably being created one after the other. They are both marked as language undefined, most likely due to the neutral path module. I suspect that one of the aliases was originally meant to be for English and the second for Japanese, but there is no setting in pathauto for different language paths for users. I can try disabling the neutral path module and rerunning my migration to confirm that they were each meant for different languages, but how can I fix it? I do not need a /firstname-lastname path in the system. I only want /staff/lastname-firstname to be generated.


texts: Drupal Search API facet block not listing all indexed fields

texts:
I have a content type that has a term reference field to a vocabulary called 'Categories'.

Categories

- Cat 1
- - Cat 1.1*
- - Cat 1.2
- - - Cat 1.2.1
- - - Cat 1.2.2*
- - Cat 1.3
- Cat 2
- Cat 3
- - Cat 3.1
- - - Cat 3.1.1
- - Cat 3.2

As you can see, the Category vocabulary has a terms in a Hierarchy.

Using Search API and Solr, im indexing the term reference field using 'Parents All'. I have set the index up to index the hierarchy.

Its all working perfectly, however, not all terms are listed in the facet box, despite the products being indexed correctly. There are a few terms that do not appear. (marked with a * above).

However, I know that the nodes are indexing correctly. I know this as I can filter by a facet that is working, then swap the argument in the URL arguments for the TID of a term that isnt working. When this happens, the products are displayed correctly in the view.

So my question is...what could cause Drupal/Search API to not display all items in a facet.

How can I start to debug this?

I have tried rewriting the facet using this function:

function HOOK_facet_items_alter(&$build, &$settings) {
                        if ($settings->facet == "YOUR_FACET_NAME") {
                          foreach($build as $key => $item) {
                            $build[$key]["#markup"] = drupal_strtoupper($item["#markup"]);
                          }
                        }
                      }

However, when I print out the list of terms inside $build the ones that arn't displaying are not listed in the array.

ANy help or any other hook suggestions are greatly appreciated.


texts:
When users get an email with one time login link, they will arrive on a page to set their password (separated form via Password Separate Form)
But once they click submit, it doesn't redirect them to the normal view of the profile page.

How should I make the redirect?
I tried different Rules (Test 1, Test 2) and I even wrote to the module support of Password Separate Form, but nobody answer me and I need to fix the issue.


texts: EntityFieldQuery BETWEEN condition is not working

texts:
$query->join('field_data_field_amountpaid', 'amt', 'n.nid = amt.entity_id and amt.field_amountpaid_value >=500 and amt.field_amountpaid_value <=5000 '); //JOIN node with Body

This is my normal query how can I call this in entity query?

I tried this way;

$query->fieldCondition('field_amountpaid', 'value', array('501','5000'),'BETWEEN');

But it's not working. Any idea?


texts: Incomplete Object error when updating site (after Drupal timeout)

texts:
I (foolishly) tried to enable an installed module whilst on my shared hosting. The site times out, which isn't all together unsurprising. However now I get this error message whenever I try and make any updates to the site (enable any modules, clear cache, run cron etc.)

Any thoughts as to the cause. Here is the error in full.

  Fatal error: views_plugin_display::destroy(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "metatag_views_plugin_display_extender_metatags" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxx/public_html/sites/all/modules/views/plugins/views_plugin_display.inc on line 272

If it makes any difference it was the Metatag module I was trying to enable.


texts: Installing TinyMCE plugins on Drupal 7 with the WYSIWYG module

texts:
I using Drupal 7 and the WYSIWYG module and the TinyMCE (3.4.2) plugin.
I want to install a plugin for TinyMCE.

I placed the plugin folder in the right directory.

sites/all/libraries/tinymce/jscripts/tiny_mce/plugins

However, the plugin doesn't show up in my configuration checkboxes for the WYSIWYG configuration.  What else do I need to do to enable a contributed plugin?


texts:
I'm working with the addressfield module. I need to change the thoroughfare column to have a max length of 960 (or make it a text instead of varchar) instead of the default 255.

However I'm not sure how I should do it.

I've created an empty module with a hook_schema_alter()

function hook_schema_alter(&$schema) {
  $schema['addressfield']['thoroughfare'] = array(
    'description' => 'The thoroughfare of this address. (i.e. Street address)',
    'type' => 'text',
    'default' => '',
    'not null' => FALSE,
  );
  return $schema;
}

However I suspect that the part "$schema['addressfield']['thoroughfare']" is not correct. Nothing is changed when I install the module with this hook.

How to change it? In the original addressfield it returns only columns in the schema hook, it's not really linked to a schema itself?


texts: How to install a specific version of drush?

texts: How can I install the a specific version of Drush, for example 5.9.0?


texts: How to print the Addthis block code into a template

texts:
I've installed the AddThis module and am trying to print the buttons on my template, however I can't get it to work. Here's the I'm using:

$addblock = module_invoke('addthis','block_view','addthis_block');
print render($addblock['content']);

For the record, If I switch to Bootstrap theme, the links are displayed on the page, if I switch to my own theme (Bootstrap child-theme) it doesn't. I've copied the code verbatim from modules/node/node.tpl.php and it still doesn't work.

Any suggestions?


texts: What is the equivalent of hook_image_styles_alter()?

texts:
I would like to allow uploading of SVG images to all the existing image fields with image effect. However, I wouldn't like the image styles to be applied to SVG images, as it is mostly designed for raster images.
I am thinking of detecting the format and avoid applying the styles to those formats.
Drupal 7 had hook_image_styles_alter(), but there is no equivalent in Drupal 8.


texts: more than one vote for single as well as guest users

texts:
I am using Drupal 7 with my custom theme. I have enabled core poll module and create poll form content and it will display on my desire place. but when any one can vote it will display result this flow was correct.

I want to do that when any one can vote than after display result but when refresh page or when ever come to that page it will display question and choices instead of result display. means I want that user or guest will give vote no. of times.

Is it possible with core poll module?

Thanks.


texts: Problem with HOOK_preprocess_breadcrump (Caching?)

texts:
I run in a strange issue with breadcrumb modifying. In my template, I created a hook to show the current page in the breadcrumbs (for testing):

function business_preprocess_breadcrumb(&$variables){

if(($node = \Drupal::routeMatch()->getParameter('node')) && $variables['breadcrumb']){
    $variables['breadcrumb'][] = array(
                    'text' => $node->getTitle(),
                    'url' => $node->URL()
                   );
     }

}

The code above works after clearing the cache and loading the first node page. However, as soon as I load any other node page, it's always showing the title of the first loaded node (like it is cached). Even when I echo the Node id, I always see the same ID from the first node. How can I fix this?
I even tried to create a custom module which overrides the breadcumb generation - same result here.

Drupal 8.1.1.


texts: View: How to make a list of article(in a block) related to the taxonomy term of my main article

texts:
I would like to display a list of link in a block that are related to the taxonomy term of my main article.

I read others subjects like article-view-with-links-to-other-articles

but it doesn't work for me. My URL is like that : example.com/product/[node:id] (Maybe it doesn't work because i don't have the term id in my url)

My article has a vocabulary call "tendance", this article is tag with the term, for instance "tendance one". I would like to have all the article tag with "tendance one"

I have this configuration:

Contextual filter: Content nid
WHEN THE FILTER VALUE IS NOT AVAILABLE : raw value from URL
I add validation etc.
And in More section, i click on exclude

So i had a list of all my article in my block thanks to the exclude but there are not related to the term "tendance one" of my main article.

I tried to add relationship :

Content: Taxonomy terms on node (and i select my vocabulary "tendance" and required relationship)
Taxonomy term: Content using tendance

And it doesn't work, i always have the same list of article linked to the good vacabulary but not to the good term.

Do i have to pass in my url the taxonomy term to make it work?
Thanks,


texts: AJAX returns response code 200, and displays error messages in callbacks

texts:
I'm running Drupal 7.34 with quite a few modules (relevant because unfortunately I did not notice when the problem first started and it would take ages to look through them all one by one) and I have some quite strange behaviour. Whenever I try to fill in an autocomplete text field, manually check for updates or do anything else that involves AJAX really, I get an error message with the HTTP Response Code 200 and the response text is actually the HTML of the user profile page. One exception to this is in a custom module I wrote which uses callbacks, and strangely when the callback is outputted any persistent messages (i.e operating in maintenance mode) are also displayed in the same place. I have tried disabling and deleting this module but it did not change anything.

Also, I suspect it could be related that my messages log is filled with warnings saying:

Warning: Cannot modify header information - headers already sent by (output started at /home/site.com/public_html/includes/common.inc:2725) in drupal_goto() (line 697 of /home/site.com/public_html/includes/common.inc).

Does anybody have any idea what could be causing this?


texts: Drush not connecting to site's settings.php

texts:
When I run drush --debug status in the docroot of my Drupal site, I get the following message:

[user@computer]$ drush --debug status
Phar detected. Proceeding to drush_main().
Loading drushrc "/home/user/.drush/drushrc.php" into "home.drush"[bootstrap]
scope. [0.02 sec, 3.54 MB]
Cache HIT cid: 8.1.14-commandfiles-removed    [debug]
[0.03 sec, 3.59 MB]
Bootstrap to phase 0. [0.28 sec, 9.55 MB]                            [bootstrap]
Trying to bootstrap as far as we can. [0.28 sec, 9.56 MB]                [debug]
Found command: core-status (commandfile=core) [0.28 sec, 9.56 MB]    [bootstrap]
Loading outputformat engine. [0.28 sec, 9.56 MB]                        [notice]
Calling hook drush_core_status [0.29 sec, 9.85 MB]                       [debug]
Returned from hook drush_core_status [0.38 sec, 9.86 MB]
         [debug]
 PHP configuration      :  /etc/php.ini /home/user/.drush/drush.ini
 PHP OS                 :  Linux
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.14
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /home/user/.drush/aliases.drushrc.php
Command dispatch complete [x.xx sec, x.xx MB]                           [notice]

As you may see in that output, "PHP Configuration" has two entries where as "Drush configuration" has none. And that one of the entries for "PHP Configuration" looks like the entry that should be in "Drush configuration".

I did run it within the docroot of Drupal. And I have even tried in sites/default. Plus, I have even tried my aliases and none of them are working. This all worked before though with another Drupal site. It just stopped working after I transferred the Drupal files from one server to another. I thought my permissions were correct but they don't look correct. Plus I have even tried adding --uri and --root to Drush and that didn't work either. For the transfer I used rsync options avzp.

drush -d pm-info give's the following:

[user@computer]$ drush -d pm-info
Phar detected. Proceeding to drush_main().
Loading drushrc "/home/user/.drush/drushrc.php" into "home.drush"[bootstrap]
scope. [0.02 sec, 3.54 MB]
Cache HIT cid: 8.1.14-commandfiles-removed    [debug] [0.03 sec, 3.59 MB]
Bootstrap to phase 0. [0.27 sec, 9.55 MB]                                              [bootstrap]
Bootstrap to phase 6. [0.28 sec, 9.56 MB]                              [bootstrap]
Command pm-info needs a higher bootstrap level to run - you will need[error]
to invoke drush from a more functional Drupal environment to run this
command. [0.28 sec, 9.56 MB]
The drush command 'pm-info' could not be executed. [0.28 sec, 9.56   [error]
MB]


texts: How to access an element's value in field validation function

texts:
Drupal form api reference example for #element_validate accesses element's value with $element['#value'] in field validation function:

function myelement_validate($element, &$form_state, $form) {
   if (empty($element['#value'])) {
     form_error($element, t('This field is required.'));
   }
}

But $element['#value'] is always empty for me. indeed in print_r($element) there is no key named #value in first dimension of the array. instead, it is in somewhere like $element['und'][0]['#entity']....

My code:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
   if (isset($form['field_myfield'])) {
      $form['field_myfield']['#element_validate'][] = 'myfield_validate';

   }
}

function myfield_validate($element, &$form_state, $form) {

   //print $element['#value']; exit; // returns nothing

   if (!empty($element['#value']) && !is_numeric($element['#value'])) { // always false
      form_error($element, t('Error'));
   }
}

Is anything wrong?


texts: drush sql-sync tries to rsync unknown dump file

texts:
Since I upgraded drush 5.10 -> 7.0-dev today, sql-sync fails to work with my existing alias file.

Using the command drush sql-sync @limelive @limedev fails.

The %dump-dir paths on both local and remote aliases correctly address existing directories. --debug shows the remote sql dump success:

 Database dump saved to /home/aegir/drush-backups/limetreethornfor/20140411235252/limetreethornfor_20140411_235252.sql.gz

but later reports

rsync: link_stat "/var/aegir/platforms/aventura-2014-04-11-1/Array" failed: No such file or directory

This suggest new command syntax incorrectly diagnosed. What am I doing wrong?


texts: Refresh a View's Results when back button is used

texts:
I have a view in Drupal 8 with a few filters all set to remember the last selection. This view uses AJAX.

If you use the filters and navigate away, then hit back, the state of the filters and results are not the most recent selection you made. Refreshing the page, however, updates everything with the last selection you made.

How can I preserve these settings and results without needing a manual refresh?

I believe this is related to this issue but it doesn't look like there has been much activity on it. I'm hoping someone might have a recommendation to get "remember selection" working well with AJAX.


texts:
When updating an entity I want to validate that the fields I am updating are correct. As this may be coming from VBO or a Drupal form I thought I could do it in hook_entity_update.

In hook_entity_update() is there a way to not update the entity and return/display a message.

Maybe I am coming from the wrong angle.


texts: How can i programmatically trigger a Lightbox window using Drupal

texts:
I'm creating a new module for a Drupal 7 site, and I was wondering if it is possible, using Drupal's AJAX functionality, to trigger a Lightbox window programmatically with PHP.

I have looked into the ajax_command_invoke() function, but unfortunately it doesn't seem to do what I need.

Edit: I would either like to run a custom function which would trigger the lightbox via  $('#id').ceebox().trigger('click'); or using another way to programmatically achieve this. (This is an example I have taken off from a non-Drupal project.)


texts: Requestee user cannot remove a one way User Relationship with requester user

texts:
I have a one-way User Relationship which also can be reciprocated, and I have run into an issue where users cannot remove a one-way relationship with another user that they have previously approved.

For example, User B sends a one-way relationship request to User A. User A approves it. Then, User A decides they no longer want to have that relationship with User B, and they click the link to remove that relationship (for example, https://mywebsite.com/user/778/relationships/requested/3338/remove). The relationship is not removed, and User A is presented with this message: "No action has been taken". There is nothing in the Recent Log Messages that would point to any specific issue, and all of the Have/Maintain/Request/Delete permissions are enabled for Authenticated and other specific user roles that these users have.

How can I fix this, so that User A has total control over which approved relationships they have with User B?


texts: How to add an sms:number link to a menu?

texts:
In Drupal 8.5, when you're adding a menu item, you can add a telephone number by setting the Link to tel:1-555-555-5555.

However, if you try to add an SMS link like sms:1-555-555-5555, it fails validation and says "The path 'sms:1-555-555-5555` is invalid."

What's the easiest way to override this so that I can add an sms link to the menu?


texts: When does hook_node_access() get invoked for $op == "create"?

texts:
When does hook_node_access get invoked for $op == "create" ?  In other words, at what portion of the node creation process is this permission checked?  I am not seeing anything in the API does about this.

I have a situation where I need to restrict a subset of users to only be allowed to create/edit content with a particular taxonomy term based on their user profile.  I have the $op == "update" and node form logic all worked out, and am not sure what I need to do about $op == "update"

Thanks.


texts:
I am using Organic Groups. That module has a form where you add new members to a group. I would like to run additional validation on that form. I use hook_form_alter and can identify the form. I add a validate callback and verify its been added to the form array. Yet that function never runs. I don't know why.

function organization_control_form_alter($form, &$form_state, $form_id){
  if($form_id == 'og_ui_add_users'){
    dpm("Validation Added");
    //This dpm displays.

    $form["#validate"][] = 'organization_control_og_size_control_form_validate';
    //I have also tried running my validate function first, like this
      //array_unshift($form["#validate"],'organization_control_og_size_control_form_validate');
    //I have also tried only running my validation, like this
      //$form["#validate"] = array('organization_control_og_size_control_form_validate');

    dpm("form");
    dpm($form);
    //This dpm shows the validate callback has been added.
  }
}

function organization_control_og_size_control_form_validate($form, &$form_state){
  dpm("Validation Started");
  //This dpm NEVER shows

  //hard code an error for testing
  $subscriptionInfo['field_total_seats_value'] = 4;

  dpm("Validation Run 2");
  //This dpm NEVER shows

  if($organzational_control_organization_size >=  $subscriptionInfo['field_total_seats_value']){
    dpm("ERROR");
    //This dpm NEVER shows

    form_set_error('edit-name', t('Your Organization has reached is current license size limit.'));
    //This error is not displayed and the form submissions continues and succeeds.
  }
  else{
    dpm("It thinks its Okay");
    //This dpm NEVER shows
  }
}


texts: Can I use Corolla theme as a fixed width layout?

texts:
I have a fresh install of D7 and have downloaded Corolla theme.

I go into appearance and set the page width from 100% to 944px, which works fine, but, whenever I resize the browser window, the first sidebar breaks and drops to the left of the page. I would like it to just display a horizontal scrollbar.

Is there anyway to modify this theme to do this?


texts: I want to add a prefix to my database Drupal8 how? I change the file  setting.php but it appears an error


texts: Showing user image for custom comments created in a view

texts:
I am using a Drupal view for displaying comments.

I have the show: in the format field set to comments.
Therefore I won't be able to add extra fields in the field's section.

I have a custom URL where I show the contents of a node along with its comments and a comment box which I have custom coded.

How can I add a user image along with my comments?


texts: Slow loading of text in WYSIWYG with TinyMCE 3.5 in Chrome Browser

texts:
On an node edit page with WYSIWYG (TinyMCE) it takes over a second for the text to show up, see this video.

FireFox doesn't seem to have this issue.
Has anyone chrome across this?


texts: '[warning] Drush command terminated abnormally.'

texts:
Drush won't run at the command line in any Drupal 8 subdomain installation:
[warning] Drush command terminated abnormally.
I am using GreenGeeks hosting for several Drupal 8.8.7 sites, one 8.8.6 site, one 9.0.0 site as subdomains, e.g. subdomain.domain.com and each subdomain is configured to point to the /web subdirectory (by installation default).

I installed Drush using this guide: https://www.greengeeks.com/support/article/how-do-i-install-drush/
I used composer successfully to install all above sites, by following the same guide and supplementing with version specific installation instructions, e.g. composer create-project drupal/recommended-project:8.8.7 bingo
I updated my .bashrc file, by using the same guide, i.e.

# User specific aliases and functions
alias drush='~/drush/vendor/bin/drush'

The D8 websites work fine. HOWEVER, if I navigate to the command line of any of the 8.x drupal sites, then Drush will not run as example below:
acctname@svrname [~/public_html/bingo]# drush version
 [warning] Drush command terminated abnormally.
acctname@svrname [~/public_html/bingo]#

Drush runs NORMALLY at the /public_html directory, but there is no drupal installed there:
acctname@svrname [~/public_html]# drush version
 Drush version : 10.2.2
acctname@svrname [~/public_html]#

Drush ALSO RUNS NORMALLY at the Drupal9 website:
acctname@svrname [~/public_html/drupal9]# drush version
 Drush version : 10.2.2
acctname@svrname [~/public_html/drupal9]#

THE FOLLOWING INFO MAY NOT BE RELATED...
HOWEVER, at the risk of distraction, the errorlog indicates a drush-related error for the D9 website and the website suddenly shows this error (it used to work):
The website encountered an unexpected error. Please try again later.
And the error_log reports this:
Error: Class 'Drush\Log\DrushLog' not found in /home/projects/public_html/drupal9/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 257
...but Drush still runs normally


texts: Filter Entity reference based on attribute

texts:
Here's my situation: I have a "Project" content type. I want to be able to add employees to a project based on their role with a select or multi-select drop down widget with unlimited number of values. So I can add multiple people with different roles.

I would like to be able to choose a Role first - say a "designer" - and then have the drop down for the entity reference only show just the roles for designers.

Project
  --> choose Role "designer"
  --> choose designer "John Doe"
  Add next person
  --> choose Role "??"
  --> choose person "??"

What are possible ways to do this?


texts: How to theme simplenews newsletters in D7?

texts:
I'm looking for something like a walk-through.  (The guide here, http://drupal.org/node/268404, was apparently written before the D6 rewrite).

The reason I'm after this is that when I use the default simplenews newsletter format, and enter for the subject "test" and for the body "test content" my resulting emails look like this:

-------- TES
-----------------------------------------------------------------
Test content**myReport taxonomy**
**myURL**

-- Unsubscribe from this newsletter:
**myUnsubscribeURL**

(The contents between the ** are correct, I've left them out for privacy).  But you can see the issues are things like:

The "t" at the end of "test," the last letter of the header, is left off for some reason.
I'm not sure where the hyphens are coming from, or how to modify that formatting decision. I'd like to eliminate the hyphens both before the heading, and between the heading and the body.
The body of the email abuts the name of the report taxonomy without space or break.
The body of the email comes before the name of the report taxonomy, I'd rather reverse the order.

Can anyone point me to a simple guide to alleviate at least these four problems?  Greater customizability would be helpful, but I need to address these for a minimum viable newsletter before getting fancy.


texts: Alternate links in a multilingual site Drupal 7

texts:
I have a multilingual website currently on localhost. I want to add the alternate links to each page like this: rel="alternate" hreflang="x".
How do i do that?
What about the canonical urls? I have already installed SEO suite module enabled.


texts:
I am using the Entity background module, which at the start of its .module file has a line which defines an image style constant.
define('EB_IMAGE_STYLE', 'large');

I don't want to use that image style, and I don't want to alter the original .module file.
I thought I could write a tiny module just to redefine that line, to alter it. After hours of trying to search for and understand hooks, I am no closer to a solution.
How can I correctly achieve what I want?


texts: Webform translation while keeping single node

texts:
I want to translate a Webform. I know it's very easy to achieve if there are separate Webform nodes for each language but I don't want to do that, I want to keep a single node.

I have already tried the Webform Localization module:

As per the readme of this module, it says to keep a single node enable
"localization by string translation" fieldset in the form settings

Which I have done.

I have also refreshed the i18n_string, as suggested in module readme.

Issue here is, even with above settings when I click on translate tab of the Webform node, it creates new node.

So are there any other settings I'm missing or this module is not working as its currently in under development.


texts: How do I show the form for adding a node as block?

texts:
I have a content type with the title and name fields. How can I the form for adding a node as block, in the front page?

I am using Drupal 7.

function mail_block_info() {
  $blocks = array();
  $blocks['mail_block'] = array(
    'info' => t('backend info left block'),
    'cache' => DRUPAL_NO_CACHE,
  );

  return $blocks;
}

function mail_block_view($block_name = '') {
  if ($block_name == 'mail_block') {
    $match = TRUE;
    $types = array('mailin_list_node_form' => 1);
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(array('nid' => $nid));
      $type = $node->type;
      if (isset($types[$type])) {
        $match = FALSE;
      }
    }

    $contact_node = node_load($node);

    drupal_get_form($node);
    $block = array(
      'subject' => t(''),
      'content' => $content,
    );

    return $block;
  }
}


texts: A commerce fees rule works fine, but is giving the warnings in the log

texts:
I've enabled the Commerce Fees module and added a rule with the following details:

{ "rules_setup_fee" : {
    "LABEL" : "Setup Fee",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce License Billing" ],
    "REQUIRES" : [ "rules", "commerce_fees" ],
    "ON" : { "commerce_fees_order" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "commerce-order:commerce-line-items:0:line-item-label" ],
          "match" : "book"
        }
      }
    ],
    "DO" : [
      { "commerce_fees_apply" : {
          "entity" : [ "commerce-order" ],
          "fee" : "setup_fee",
          "amount" : "999",
          "currency_code" : "USD"
        }
      }
    ]
  }
}

which correctly adds $9.99 setup fee to a shopping cart when customer selects any product which has the "book" string in its title (or SKU which we try to keep the same). So the whole thing serves its purpose just fine, however unfortunately it also leaves the following traces in the logs:

  Unable to evaluate condition text_matches. Unable to get the data
  value for the variable or parameter text. Error: Unable to get the
  data property line_item_label as the parent data structure is not set.

What am I doing wrong here? Thanks!


texts: Views Accordion Closes When I Hit Next On Pager On Interior View

texts: I have an issue where I have a view accordion and each row on the accordion has a view with a pager.  When I hit next on the pager the accordion closes which is a very undesirable effect.  Any ideas?


texts: Is it safe to use php within a Rules condition?

texts:
Using Rules I need a condition which checks if the logged in user has authored a given content type.

It seems that I need some custom php for this and I found the code below from a post on drupal.org, which works as required and my rule now does exactly what I want it to do.

I had to enable php filter (for User 1) in order to get the code in to my rule. But I have read that php filter should be disabled on production sites but find that my rule ceases to work if this is done.

I am not a coder and am need to know what is the best way to deal this situation?

https://drupal.org/node/2052241


texts: Same node to show using different themes

texts:
Drupal 8 question:
I need to show same content page (say /node/12) using different themes, when used in a menu link. I have 'URLs aliases' created (eg:  /ma/testPage, /nj/testPage ) both points to /node/12 (URL aliases module).

I have 'switch page theme' module which points to different themes based on the path (/ma/* points to theme1,  /nj/* points to theme2).

When I view the page using /nj/testPage or  /ma/testPage, it uses the same theme (theme1). As per the rule in 'Switch page theme' i am expecting the same node render using different theme. It doesn't happen like that.  Could anyone help what i am doing wrong?
Or is it not possible to render same node using different theme?


texts: D7 - db_select: order by most recent, commented status

texts:
I'm writing my custom module.
I use the modules Statuses and 'fbss_comments' (part of the Statuses module). Comments are used to comment on statuses.

Using the following code I get a list of results:

 $query = db_select("statuses", "thread")->distinct();
        $query->join("fbss_comments", "comment", "comment.sid = thread.sid");
        $query->fields("thread", array("sid", "sender", "created", "message"));
        $query->fields("comment", array("created"));
        $query->orderBy("comment.created", "DESC");
        $result = $query->execute();

Now the list of results will be sorted by the most recent posted status. I want to achieve the following: sort the result list by statuses with the most recent comments

Some clarification: normally status(100) will be shown above status(30). When I comment on status(30), status(30) should be shown above status(100). On top of this, when I create a new status(101), this status should be shown on top of the result list.

I hope my goal is clear to you, sadly, I have no idea how to achieve this.

Any advice or help is much appreciated

edit: I've managed to order the results by the most recent commented statuses, however, if a status has 9 comments, the status is shown 9 times. Any advice why/how this happens?

edit 2: I probably should use ->distinct(), I've added it after the db select statement, but  this doesn't work (probably because I select two tables)


texts:
I am building a website for multiple summer resorts. I am now concentrating on the restaurants section.

I have a content type - Restaurant.

It has multiple fields but I will just put down the ones that are connected to this question;

field_resort: Term Ref.
field_restaurant_category: Term Ref.

And then the url pattern;

[node:field-resort]/restaurant-guide/[node:title]

I need a block in the restaurant parent page [node:field-resort]/restaurants that then displays a grid with each individual taxonomy term [field_restaurant_category].

What the problem is is that I want to have a page that once you click on one of those categories, takes you to a page that displays teaser views of all the restaurants for that specific food categorie from only that resort while appending the url to keep the resort as the parent.

resort-1/restaurant-guide/[field_restaurant_category]
resort-2/restaurant-guide/[field_restaurant_category]
resort-3/restaurant-guide/[field_restaurant_category]


texts: How do i use views with a custom entity?

texts: I defined a custom entity with a few bundles.  Is it possible to display these using Views?  How do I do that?


texts: Hiding view filter option based on another filter selection

texts:
I have a view with search criteria and the search criteria looks like below:

Age group(options: new born, toddler, pre-school)
Classroom (options: NA, potty-trained, transition, not-trained) All these filter fields are check boxes.

When I select 'new born' as age-group, all of the classroom options should be hidden/disabled except NA option When I select 'toddler/pre-school' all of the classroom options should show up again except NA option

I am using the below code for doing this:

$('#edit-field-agegroup-value-1').click(function() {
    if( $(this).is(':checked')) {
        $("#edit-field-classroom-value-3").prop('disabled', true);
     } else {
        $("#edit-field-classroom-value-3").prop('disabled', false);
     }
    });

This code is working fine. However, when I submit the refresh button the page refreshes and the disabled fields show enabled again. Any help on how this can be fixed?


texts: How to add custom link in views field list?

texts:
I have created a view and added some data field, and I want to add a link field, which has the title "Approve." Whenever the administrator users click on that link, an AJAX call should update the database.

How can I do it?


texts: Using node_view() to display a node doesn't print local menu items

texts:
When using node_view() to display a node (via return from a function that's called in hook_menu()) the usual View/Edit tabs are missing.

Is this expected behaviour?


texts:
How would you use/access D8 Webforms Predefined Options (such as days,months,gender, marital status,country etc,etc) in code, say in MYMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id). Where is the predefined options data stored ?

For example, for country codes options ["AF"=>"Afghanistan","AL"=>"Albania",....,"US"=>"United States",..] how would you get country name from country code.

Your aasistance will be greatly appreciated.


texts: Error 500 when including controller file in Route

texts:
I am trying to upgrade a mailing list from drupal 7 to 8. I am getting an 500 error when I include my controller in the route file. I checked the path in both route and controllers and almost tried removing all values from the class, still I am getting the error my route file is:

mailing_list.admin:
  path: '/admin/structure/mailing_list'
  defaults:
_controller:'\Drupal\mailing_list\Controller\MailingListController::mailingListList'
_title: 'Mailing List'
  requirements:
_permissions: 'administer mailing lists'

My Controller Code is:

namespace Drupal\mailing_list\Controller;
class MailingListController extends ControllerBase {
  public function mailingListList() {
$output = array('table', array('header' => '1'));
}
}

I have removed the lines in controller function to avoid 500 error, but still I am getting 500 error.


texts: How do I remove the text "webform content" at the top of a block?

texts:
I have several Drupal 8 webforms, some of which are embedded as blocks. At the top of each webform, I'm getting the "webform content" text.

How do I safely remove that text?


texts: How to get an import of a very large Drupal database working?

texts:
I'm using Vagrant and OracleVM to run Drupal 7. I've got the site up and running and I'm trying to get my database imported. So far I've run drush cc and cleared the drush cache, and then I did

drush sql-cli < mydb.sql

The drush command is taking a super long time and I'm not sure if it's even doing anything. The database file is just under a gigabyte.

What can I do to get this working, or is there a better method?


texts: Preserve Current Paths before rolling out new Pathauto Alias

texts:
I'm just about to roll out a new Pathauto Alias to include a new taxonomy term, which will modify about 1000 nodes. Is there a way to preserve the current path aliases I have now, and then bulk update all my nodes to the new pattern?

I assume I'll need to use Path Redirect in conjunction with Global Redirect somehow to keep the old paths pointing to the new paths?

Thanks!


texts: How do I perform a redirect to the cart?

texts:
I'm trying to redirect the user to the cart from a custom page using the following code.

return new RedirectResponse(\Drupal::url('cart'));

Is there a function to go directly to the cartrce? If not, what is the route name for the cart page?


texts: What is the best method to customize the display of author information on a node of a certain type?

texts:
Requirements: For nodes of a certain type (blog), I need to show the author information with the author image using a specific Image Style, the user name, the user profile description, and another custom user field.

The method I'm currently using is implementing theme_preprocess_node() to create a variable to pass to my node--blog.tpl.php file that includes the elements I need themed. This means I have calls to theme_image_style() in my theme_preprocess_node() function.

Is this the best method, or is there a "more Drupal" approach I'm missing?

If it helps, here is a snippet of code:

/**
 * Hook theme_preprocess_node
 */
function hotness_preprocess_node(&$vars) {
  // for blog posts, style date and show intro image
  $node = $vars['node'];
  if($node->type == 'blog') {
    // nice date
    $vars['date'] = format_date($node->created, 'custom', 'F j, Y');

    // use image style for blog image
    $vars['blog_image'] = NULL;
    $blog_image = isset($node->field_blog_image['und'][0]) ? $node->field_blog_image['und'][0] : FALSE;
    if($blog_image) {
      $vars['blog_image'] = theme_image_style(array(
        'style_name' => 'introduction-image',
        'path' => $blog_image['uri'],
        'width' => $blog_image['width'],
        'height' => $blog_image['height'],
        'alt' => $blog_image['title'], // to make it easier to the end user I just show title
        'title' => $blog_image['title'],
         'attributes' => array('class' => 'blog-image')
      ));
    }

// I use user_load() because the node object doesn't have the user description.
$author = user_load($node->uid);

$author_image = '';
if(isset($author->picture->uri) && !empty($author->picture->uri)) {
  $author_image = theme_image_style(array(
    'style_name' => 'blog-author-image',
    'path' => $node->picture->uri,
    'width' => NULL,
    'height' => NULL,
    'alt' => t('User .') . $node->name,
    'title' => t('User ') . $node->name,
    'attributes' => array('class' => array('author-image')),
  ));
}

$author_name = l($node->name, 'user/' . $node->uid);
$author_desc = isset($author->field_description['und'][0]['safe_value']) ?
  '
' . $author->field_description['und'][0]['safe_value'] . '
': '';

// put it all together
$vars['author_block'] = $author_image . $author_name . $author_desc;

}
}


texts: I currently have a page template set up in its page-node-946.tpl.php. $content is being populated by that node numbers content. I need to loop through and display a teaser for all content nodes and certain type. I need some instruction on how to do it. Maybe I've gone wrong by trying to do this with a page-node template.


texts:
what is #target_type in EntityAutocomplete?

in EntityAutocomplete it said: #target_type: The ID of the target entity type.

how can i see the list of the ID?

and

can I extend the ID on my own?

Thank you,
AnD


texts: Using Drupal as a server application user front-end (feasability question)

texts:
I am very new to Drupal. I am currently watching videos and reading many online tutorials. I came to Drupal, because I understand it is a good CMS system (at least recommended by many, and the more I learn, the more I agree).

But, the more I learn, the more I am wondering whether it could solve another of my needs: acting as a user front-end for a server-side application. Let me describe this.

I have a couple of experts entering technical information in a system (i.e. database). I understand I can create specific screens with specific fields in Drupal (that's great, no coding) and that it would be stored in the database when ready.
After information is entered by experts, heavy time and cpu consuming asynchronous processes should be started in background and resulting information stored in the database.
Next, users should be able to read results with another screen in Drupal.

Instead of performing the heavy processes on the web-server, I was wondering whether I could use another server to connect to the drupal database instance (with a deamon application written in Java for example), perform the heavy duty tasks, and store the information in that same database.

My questions are:

Is this realistic? Has anyone attempted this?
Is it easy for a 3rd party application to read data from a Drupal database and store results in it? Does Drupal offer specific modules faciliting this? Any documentation or tips available?

Thanks.


texts: shopping cart is empty when I programmically create order

texts:
I create a order with below code

      global $user;
     $product_id = 860;
     $price=intval($form_state['values']['field_suggest_your_price']['und'][0]['value']);
     dsm($price);
     dsm($form_state['values']);
// Create the new order in checkout; you might also check first to
// see if your user already has an order to use instead of a new one.
       $order = commerce_order_new($user->uid, 'checkout_checkout');

// Save the order to get its ID.
        commerce_order_save($order);

// Load whatever product represents the item the customer will be
// paying for and create a line item for it.
        $product = commerce_product_load($product_id);
        $product->commerce_price["und"][0]["amount"]=$price;

        $line_item = commerce_product_line_item_new($product, 1, $order->order_id);
//// Save the line item to get its ID.
        commerce_line_item_save($line_item);
//// Add the line item to the order using fago's rockin' wrapper.
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_wrapper->commerce_line_items[] = $line_item;
//// Save the order again to update its line item reference field.
commerce_order_save($order);
dsm($order);

//// Redirect to the order's checkout form. Obviously, if this were a
//// form submit handler, you'd just set $form_state['redirect'].
drupal_goto('checkout/' . $order->order_id);

but in checkout/orderid  shopping cart is empty, any body know where is my fault?
appreciate any urgency help


texts: Entity references linked to a wrong referent

texts:
On a Drupal 7 multilingual site, I have a content type containing a field_group containing itself entity references fields.

I haven't enabled the i18n submodule "Synchronize translations" ("i18n_sync").

I have a content in French:

contentFR

entityreferenceFR 1
entityreferenceFR 2

I want to translate this content in Italian, so I translate the entity references first, like this :

entityreferenceIT 1 (translation of entityreferenceFR 1)
entityreferenceIT 2 (translation of entityreferenceFR 2)

Then, I translate "contentFR" in Italian, and associate my 2 Italian entityreferences to this new Italian content, like this:

contentIT (translation of contentFR)

entityreferenceIT 1
entityreferenceIT 2

Everything seems to go perfectly well, except that, when I go back to my French content, the references are the italian ones, like this:

contentFR

entityreferenceIT 1
entityreferenceIT 2

If I edit again the French content to set the French references instead of the Italian ones, the switch happens again in the other way:

contentIT

entityreferenceFR 1
entityreferenceFR 2

This is a live production site with 5 enabled languages. We've just enabled Italian and the issue exists only since then. Before, with other languages, everything was working well; the entity references were not linked to a wrong referent.

Also, I've seen this quite similar thread (Node translation syncing problem with entity references) but:

In my case, there's no synchronizing set on the reference field
There wasn't any answer given in the original thread

The enabled i18 modules are: Block languages, Multilingual content, Multilingual select, Path translation, String translation, Taxonomy translation, Translation redirect, Translation sets, and Variable translation. The disabled modules are: Field translation and Synchronize translations.

Do you have any idea why this happens?


texts: copying out Hierarchical Select terms into other textboxes

texts:
I have one Hierarchical Select with 4 depth term. What I need is to copying out every depth term level to other fields/textboxes  at the same form as described by the attached image.

And also, how can every time we change the Hierarchical Select value, it also should change the corresponding fields/textboxes.

Thank you for the help.

------------   extra information on the problem ------------------

@Yogesh

I have mininal knowledge on javascript/jquery, where to save the *.js file and how to call it properly.

I just read from one tutorial that it should save to a "js folder" and called it from the template .info file.  So, following are two images that trying to tell you what I've been doing.  Kindly help me to examine every detail of the images and hopefully you can tell where a did a wrong.

and i call the script from /sites/all/themes/zen/zen.info
with command: "scripts[] = js/isian.js"

Please advise,
Thank you


texts:
I've successfully managed to send email by using drupal_mail and hook_mail, but the next step is to send attachment within the email.
I've read that this is not possible without adding extra modules, like MIME and Mail System.

OK, here's my code that sends email without attachments:

<?php
//The form page callback
function mymodule_news_page($form, &$form_state) {
    $form['title'] = array(
        '#type' => 'markup',
        '#markup' => '
Add news
',
    );
    $form['upload'] = array(
        '#type' => 'managed_file',
        '#title' => t('Upload image'),

    );
    $form['description'] = array(
        '#type' => 'textarea',
        '#title' => t('Description'),
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
        '#submit' => array('mymodule_news_submit'),
    );

    return $form;
}

function mymodule_news_submit($form, &$form_state) {
    $upload = $form_state['values']['upload'];
    $description = $form_state['values']['description'];

    $params = array('upload' => $upload, 'description' => $description );
    drupal_mail('mymodule', 'mymodule_news_mail', 'myemail', language_default(), $params);
    drupal_set_message(t('Message sent!'));
    //dpm($form_state);
}

/*
** Implements hook_mail().
*/
function mymodule_mail($key, &$message, $params) {
    switch($key) {
        case 'mymodule_news_mail':
            $message['subject'] = t('Hello');
            $message['body'][] = t('This is a test for adding news');
            $message['body'][] = t('Image upload: @upload', array('@upload' => $params['upload']));
            $message['body'][] = t('Description: @description', array('@description' => $params['description']));
        break;
    }
}

As you can see I have a form that has three fields: upload, description and submit button.
I'm trying to upload a image, but on submitting I receive an email with filled description and the uploaded image is not in the email, but it shows some numbers like 110...

Now I've enabled the MIME and Mail System module, and from their README module I can see this line: "'attachments':
      Array of arrays with the path or content, name and MIME type of the file (optional)."

I guess this is for uploading files, but there's no other documentation, so it's not clear how can I use MIME mail with hook_mail and drupal_mail().

What do I have to add in my code, so the uploaded file will be sent into the email?


texts: How can I add cache contexts to a region. I have been able to do this to my blocks but have noticed that parts of the region remain cached.


texts: Show child pages in parent node view details in a book

texts:
I'm using the Book module to maintain the parent-child relationship between content. I want to see all child pages expanded when I see a parent node details page.
How can I achieve it?

I tried with THEMENAME_preprocess_book_tree(), but so far I have not been able to achieve that I wanted.
Is this the right hook to use in my case?


texts: Is there a way with either flags or rules or another module to make content being displayed in a slideshow flagged/marked as "viewed"? Then on refresh that content wouldn't display again to that user. Functionality of swiping for the mobile experience is key here. Think of it as a simplified tinder functionality.


texts: How to create a custom node template in drupal8 rendering a view within a node page?

texts:
I am trying to create custom node template in Drupal8. I would like my users accessing "tag" node to be able to view all related content. Therefore I have already created a view presenting all content relating to given tag. Now I want to render this view in a "tag" node page.

Following the https://www.drupal.org/node/2165673 I have create a custom theme. I have created themes/bartikUzbrojeni directory with the following bartikUzbrojeni.info.yml:

name: bartikUzbrojeni
type: theme
description: Modifications to the default Bartik theme
core: 8.x
base theme: bartik

I have also created templates directory within themes/bartikUzbrojeni with file node--tag.html.twig (being generally copy of node.html.twig from bartik directory).

This seems to more or less work (modifications done within node--tag.html.twig are visible within the page) but I have following problems:

The page does not look like Bartik one (the bartik theme does not
seem to be used even though I have marked it as a "base theme"). Please see screen below.
I don't know what is the proper way to edit  node--tag.html.twig so that it renders a view.


texts: Associating form with custom Media source plugin

texts:
I need to create a custom Media source plugin to display a CAD drawing from a remote source. In order for me to display the 3-D drawing I need to do three things:

Get the part number
Load various external JS libraries for displaying the drawing in 3-D
In the Twig template, build a URL that uses the part number that when clicked on, displays. 3-D viewer.
Eventually, download a thumbnail image to display when selecting the item from the Media library.

So for #1, based on wading through code and reading the only doc page I could find on creating a custom Media plugin, I created my own plugin.
<?php

namespace Drupal\my_module\Plugin\media\Source;

use Drupal\media\MediaInterface;
use Drupal\media\MediaTypeInterface;
use Drupal\media\MediaSourceBase;

/**
 * Custom CAD drawing media source.
 *
 * @MediaSource(
 *   id = "caddrawing",
 *   label = @Translation("CAD Drawing"),
 *   description = @Translation("Contains data for hosted #-D CAD image"),
 *   allowed_field_types = {"text"},
 *   default_thumbnail_filename = "generic.png"
 * )
 */
class CADDrawing extends MediaSourceBase {
  /**
   * Key for "Part number" metadata attribute.
   *
   * @var string
   */
  const METADATA_ATTRIBUTE_PART_NUMBER = 'part_number';

  /**
   * {@inheritdoc}
   */
  public function getMetadataAttributes() {
    return [
      static::METADATA_ATTRIBUTE_PART_NUMBER => $this->t('Part Number'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getMetadata(MediaInterface $media, $attribute_name) {

  }

  /**
   * {@inheritdoc}
   */
  public function createSourceField(MediaTypeInterface $type) {
    return parent::createSourceField($type)->set('settings', []);
  }

}

However, what I couldn't find was the form field that allowed the user to simply enter the part number value in the media item. The default Remote video media type has a URL field, which is basically what I want, so I thought I would model after that. However, that form isn't in the plugin; it's in a separate module, the Media Library module as OEmbedform.php. what I haven't been able to figure out is how the form is associated with the source plugin ( I assume it's by some magical auto discovery method).
So my questions are:

Assuming I still need to go the custom plugin route, and that I create a form in my module (e.g. /src/modules/custom/my_module/src/Form/CADDrawingForm.php), how do I associate the form with my plugin?
Is there an easier way to create a custom media type with a text field for storing the part number?


texts:
In Drupal 8, CSS files, images and many other files, are cached by appending a token at the end, as in /sites/default/files/styles/lrg_thumbnail/public/p2i-product_1_zoomout.png?itok=DroPCbms.

Notice the itok=DroPCbms part.

What Drupal function returns this code?


texts: In Drupal 7 I have a web site with dozens of custom templates. I used theme() to pass variables to my templates defined in hook_theme() in a page callback defined in hook_menu. How do you do this in Drupal 8? The theme() function is no longer available.


texts: How do I get the node URL in a Twig template?

texts:
I am trying to get the node URL in a Twig template. {{ content.node_link }} returns the full link, but I only need the URL.

How do I retrieve the node URL?


texts: Update Jquery to a later version but not for edit pages

texts:
I am trying to update Jquery on my website (to Jquery 1.8.3) for the front end only.

I am using the following code below and it works fine. However, as I am using my theme for node/edit pages, the code breaks some of the contrib modules that are displayed on the node/edit pages.

How can I limit the code so it doesn't effect node/edit pages?

Here is the code I am using:

function mytheme_preprocess_page(&$variables) {
  // exclude backend pages to avoid core js not working anymore
  // you could also just use a backend theme to avoid this
    $scripts = drupal_add_js();
    $new_jquery = array(drupal_get_path('theme', 'mytheme') . '/scripts/jquery-1.8.3.js' => $scripts['core']['misc/jquery.js']);
    $scripts['core'] = array_merge($new_jquery, $scripts['core']);
    unset($scripts['core']['misc/jquery.js']);
    $variables['scripts'] = drupal_get_js('header', $scripts);

}

Steps I have tried:

1. Applying an if statement.

I have tried wrapping the code in the following if statement which comes from Method 4 on this page:

if (arg(0) != 'admin' || !(arg(1) == 'add' && arg(2) == 'edit') || arg(0) != 'panels' || arg(0) != 'ctools') {
}

However, this code seems to disable Jquery on all pages.

2. Using Jquery Update

This module brakes functionality on admin/contrib modules. It also seems to have permission errors.

3. Jquery Multi

I can't seem to get this module to work.
(The module requires you to either move your Javascripts to the libraries folder (which isn't an option for me due to my workflow) or to add a number suffix to your scripts (which again isn't an option due to work flow).

Thanks for any help that can be offered.


texts:
I am trying to setup a Drupal 8 Environment on Virtual Machine (Ubuntu) and when I am trying to clear cache, I've got the error:

drupal8@drupal8-VirtualBox:/var/www/drupal-8.0-alpha5$ drush cc all
Command cache-clear needs a higher bootstrap level to run - you will [error]
need invoke drush from a more functional Drupal environment to run
this command.
The drush command 'cc all' could not be executed.                    [error]
A Drupal installation directory could not be found                   [error]
drupal8@drupal8-VirtualBox

I have installed Drush, but getting this error. Can anybody help me with this?