Solution 1 - Use Charts to create a pie chart
The sample image in your question doesn't look like a pie chart to me, instead it rather looks like a Gauge chart. If you want to try to create a pie chart anyway, using the Charts module, then have a look at this feature request (which allows you to pass "library specific options"). Comment #9 in it contains a patch that you'll need for it (using Google Charts as the rendering engine).
After you applied that patch, you'll be able to pass any of the specific options to the Google Charts charting engine that correspond to the chart you're trying to create.
If applying the patch is not sufficient, then I'd recommend what's written in the "Bonus tip" of Steps to create charts using the views UI, i.e.:

You may find it easier to start with a "Table" display and convert it to a chart display after setting up the data. It can be easier to visualize what the result of the chart will be if it's been laid out in a table first.

In other words: before trying to create a chart, make sure the tabular version of it has the correct data displayed.
Solution 2 - Use Charts to create a Gauge chart
Your sample image in your question rather looks like a Gauge chart. Have a look at the Charts issue about Support for gauge charts. After you apply the patch included in comment # 4 of this issue, you'll be able to use the Charts API to create such Gauge charts (using Google Charts as your charting engine). BTW, you can also use this specific SimplyTest.Me  link (which has this patch enabled).
Here is a sample of 2 such charts I created in my own environment (using that patch):

The first (left) chart is to show a rating like 5.7, and the second (right) chart is to show a rating like 7.2 (both ratings on a scale of 10). Attention: I haven't found any specific option (yet) to show that value of 5.7 (and 7.2) in the Gauge chart, instead of the rounded value 6 (and 7) near the bottom. Though the (red) pointer within the chart seems to correctly reflect the actual values already.
My PHP code for rendering the above 2 Gauge charts looks like so (the various options I used should be self explaining):
<?php

 $chart = array(
    '#type' => 'chart',
    '#chart_type' => 'gauge',
    '#chart_library' => 'google',
    '#title' => t('Gauge Chart'),
    '#min' => 0,
    '#max' => 10,
    '#width' => 300,
    '#height' => 300,
    '#greencolor' => '#00AA10',
    '#greenfrom' => 0,
    '#greento' => 5,
    '#redfrom' => 8,
    '#redto' => 10,
    '#redcolor' => '#FF3333',
    '#yellowfrom' => 5,
    '#yellowto' => 8,
    '#yellowcolor' => '#66BB88',
    '#minorticks' => 5,
  );

echo "<p>Left Gauge chart (= Rating 1) : 5.7 / 10 ; Right Gauge chart (Rating 2) : 7.4 / 10 </p>";

  $chart['rating1'] = array(
    '#type' => 'chart_data',
    '#title' => t('Rating 1'),
    '#data' => array(array('Rating1', 5.7)),
  );

  $chart['rating2'] = array(
    '#type' => 'chart_data',
    '#title' => t('Rating 2'),
    '#data' => array(array('Rating2', 7.2)),
  );

  $example['chart'] = $chart;

  return drupal_render($example);
?>

If you paste the above code in the body of any content type that allows using the PHP filter, and assuming you have a working internet connection (prereq to use Google Charts), you should get a similar chart in your own environment (provided you also enabled the patch mentioned before).
With the above solution that uses the Charts API, it should be possible to use the same technique for adding an extra column in your tabular Views display, using "rewrite results", in which you also refer to the actual value of the Score column for each of your views result rows (so that you get 1 Gauge chart somewhere to the right of your Score column).
Disclosure: I'm a co-maintainer of the Charts module.


theme content type with image from within paragraph

To get the url from an image field you have to go one level deeper, .entity gets the file entity where the URI of the image is stored:

{{ file_url(content.field_person[0]['#node'].field_image.0.entity.uri.value) }}

But digging through multiple levels of nested entities is not good practice, because this produces code hard to debug and maintain. You should look for a  better place to theme the image, for example node--person.html.twig, where you can print the image field, formatted how it is configured in UI:

{{ content.field_image }}


Views templates deleted when core updated

Editing files in themes\bartik\templates\views is hacking core. One ought not to. You should create a subtheme of Bartik and make  your changes there. Then an upgrade will not wipe out your changes.

Clear exceptions to the rule for editing core files are robots.txt, .htaccess and web.config.


Auto create nodes from external RSS source

The feeds module can 'Import or aggregate RSS/Atom feeds'.
https://www.drupal.org/project/feeds

You can set how often it imports and map to fields.

Here's a guide on how to create/edit importers:
https://www.drupal.org/node/638804


Have a look at the view People (User) view, which is located at relative path /admin/structure/views/view/user_admin_people.

This view has a User role exposed filter. You only need to implement the same filter in your view.

You need to select the same filter in screenshot below.


Can I change the default URI scheme in media.variables.inc?

Changing the code in a third-party module is never a good idea: All the times that module is updated, you should download the new version, edit it to change the code you altered, and update the copy used in your site. This means that, in Drupal 7, you could not use the Update manager module to automatically download, and update, the copy of that module.
If then the module code is changed not to use those constants, you should look at the new code, and see how changing it.

Those constants are probably used as defaults for Drupal variables. If those variables can be altered using the settings page of that module, then altering the constants is not necessary.

There are other ways to alter the output of third-party code:

If the module is using those values for a form field shown in a form, another module can alter that form by implementing hook_form_alter(), and associate a different value to that form field.
If the module is using those values in a theme function, another module can override the function used for that theme function, implementing hook_theme_registry_alter(). In Drupal 7, it is also possible to implement hook_preprocess() to alter the variables passed to that theme function.
If the module is using those constants to set a variable used in a preprocess function, another module can implement hook_preprocess() to alter that variable.


You'll either need to add a js behavior that attaches itself to the normal submit event of the form, or create an AJAX Command that invokes a function in your script.

See: https://www.drupal.org/node/2290235


The field name string contained a right to left mark.
See https://stackoverflow.com/questions/54653637/cannot-get-array-key-array-key-not-set/54655517#54655517 to find out how to remove it


There's a module for that.

Imagecache external


How to add new blocks when "The block X was assigned to the invalid region Y and has been disabled"

In D7 I finally got rid of that message by placing an if ($theme == variable_get('theme_default', '0')) around the region assignment. So the block only gets assigned to my (default) frontend theme which actually contains the region the block is assigned to.

function MYMODULE_block_info_alter(&$blocks, $theme, $code_blocks) {
  if ($theme == variable_get('theme_default', '0')) {
        if (isset($blocks['MYMODULE']['MYMODULE_block'])) {
            $blocks['MYMODULE']['MYMODULE_block']['status'] = 1;
            $blocks['MYMODULE']['MYMODULE_block']['region'] = 'header';
            $blocks['MYMODULE']['MYMODULE_block']['weight'] = 2;
            $blocks['MYMODULE']['MYMODULE_block']['visibility'] = BLOCK_VISIBILITY_NOTLISTED;
        }
    }
}


You can create a view to a non-drupal table/database but you need to create a connection to it first using either one of the two connector modules: the Data module or the Table Wizard module.

You can also set it up using the Views API with views_hook_data(). (See documentation on views/help/api-tables.html.)

You'll need to add your new database connection settings in your settings file.

// In settings.php for your site
// Your drupal (site) database needs to be called 'default'
$db_url['default'] = 'mysqli://user:pass@host/drupal_db';
$db_url['oracle_db'] = 'mysqli://user:pass@host/other_db';

Then, in your view hook, define the tables the view should have access to.

$data[$table]['table']['base'] = array(
    'field' => 'Primary key',
    'title' => t('Field name'),
    'help' => t('Field description'),
    'database' => 'oracle_db',
    'weight' => -10,
);


How do I check the entered quantity before the checkout phase in Drupal Commerce?

You can use rules to change the quantity in a line item... so you could force the quantity up and output a system message. I don't know of a way to prevent them from checking out using rules.

So: Condition: Data Comparison: Line item: Product: SKU  equals XX
Condition: Data Comparison: Line Item: Quantity less than X
Action: System message explaining why we're increasing quantity
Action: Data Set Value: Set quantity to X+3

Update: this strategy might work for you.


How to send a mail to a user with views rules when a date is passed?

Part 1: Sending an eMail

Your view needs refinement ...You seem to have 1 Views result (row) for each user to be eMailed, which is OK. But that view must have fields (columns) for each of the fields that you want to use in your Rules Action to create your eMail. So the [name:mail] and [name:language] in your Rules Action should be replaced by some column in your view to make those available. For that you might have to also add a "relationship" in your view to the "user object" (so that eg the eMail ID becomes available).

Have a look at these answers for some more details:

How to make fields available in Rules using the Views Rules module?
How to use Rules to send an E-mail after saving a new comment, to users who checked a boolean in their profile?

Part 2: Saving the changed date

You may have to add an extra Rules Action to "save an entity", because you need to remind the Rules module to also save the date you've updated.


How to make fields required for one type of user but not others? (registration and profile forms)

Required By role

  Field required by role is a module that improves core "required"
  functionality.

  Similar to CCK Required by role brings extra features such as:

  Ready for all entities, including custom entities. Doesn´t need extra
  configuration, just install. Respects previous configuration.
  Configuration per field instance.


limitation on "add more" button: Drupal 7

Sounds like you're after the Multivalue Settings module.

  So you can create fields where, for instance, users have to input at
  least 5 values but can input up to 10 values. Or you can create fields
  that allow 100 values, but only display 20 fields to start with.

HOWEVER (and this is a big however - if I could change the font size I would)

This module should probably only be used as a starting point, and should not be used in production. I'm sure you can get the code you need from it.

  Warning: this module is still very buggy. Actually, it only works in
  very few use cases. I suggest to only attempt using it with core
  fields (not fields from contrib modules). Even this may not work. I'm
  working on fixing things, but don't have much time. Help is welcome.


You can make a template to alter your user login form.

In template.php:

function YOURTHEMENAME_theme(){
    return array(
        'user_login' => array(
            'arguments' => array('form' => NULL),
            'render element' => 'form',
            'template' => 'templates/user-login-form',
        ),
  );
}

Then create user-login-form.tpl.php in your template folder and print the login form using

print drupal_render_children($form);

Don't forget to clear cache


How do I add a term reference name to the Pathauto pattern for a content type?

It should be something like [node:field-yourfieldname].

On that page underneath each conten-type field, do you not see a "Replacement patterns" title?

If not, install the token module.


I don't think such module exist. But you can write your own module.  Download Count may help you while writing your custom module.


How do I trigger an AJAX submit button on page load?

This was a simple case of targeting the correct element using the code below.

$(document).ready(function() {
    $('#edit-submit').trigger('click');
}


PhotoSwipe display only one image from Views grid form

After some investigations, I hook (?) the views-view-grid-default.tpl.php and wrap the grid  within a:

 ...

block and now the script take correctly all images found in the grid table.

Of course I removed this class from the image field parameter.

Thanks


New Relic shows the token hook being called a lot

I wrote a tiny module to log all calls to the tokens hook, so that I'd have some sort of idea where the tokens were coming from:

<?php

function token_logger_tokens($type, $tokens, array $data = array(), array $options = array()) {
  watchdog('token_logger', print_r($tokens, TRUE), array());
  // Activate to fill up your database fast!
  // watchdog('token_logger', print_r(debug_backtrace(FALSE, 20), TRUE), array());
}

Turns out this was mostly the file_entity module running image alt en title tags through tokens, so that they could be overridden with another pattern if so desired:

// file_entity.file.inc:279

$alt = variable_get('file_entity_alt', '[file:field_file_image_alt_text]');
$title = variable_get('file_entity_title', '[file:field_file_image_title_text]');
// a little further down the line in a loop
$output = token_replace($alt, array('file' => $file), $replace_options);
// a little further still
$output = token_replace($title, array('file' => $file), $replace_options);

That adds up to 2 calls to the token hook per file loaded. If you have a busy website with a fair amount of images, it adds up quickly. About 800 calls each time the homepage is loaded, specifically.

I think I'll patch the file_entity module to cut out tokens for the default option, and verify it makes a difference speed-wise.


How to add pagination to programmatically rendered search result template

I tried with the search_result template and it worked, hope this helps you :

$output['prefix']['#markup'] = '
Test page
';
//This sets up necessary global variables for the type => #pager
$page = pager_default_initialize(5, 2);
$render = [];
  $output[] = [
    '#theme' => 'search_result',
    '#result' => 's',
  ];
$pager = [
  '#type' => 'pager',
];
$output['suffix']['#markup'] = '
' . \Drupal::service('renderer')->render($pager);
return $output;

We just need to set up the global variables which help to process rendered array to output pagers items. And add a pager to the suffix.


I managed in my project by using a custom page template and and an additional get parameter.

Template.php: (In active theme directory)

function phptemplate_preprocess_page(&$vars){
    if( isset($_GET['ajax']) && $_GET['ajax']=='true' ){
        $vars['template_files'][] = 'page-overajax'; # For Drupal 6
        $vars['theme_hook_suggestions'][] = 'page-overajax'; # For Drupal 7
    }
}

I then created a template file (page-overajax.tpl.php) in theme directory with following content:

<div id="overlay-content-wrapper">
   <?php print $content; ?>
</div>

After this (Clear all caches) you can use any path (page, view, node) with ?ajax=true to pass to your *box to load if it supports for AJAX content.

As using with fancybox:

$("a.overajax").fancybox({
    'width': 400,
    'height': 400,
    ajax: {
        type     : "GET",
        cache    : false,
        url      : "user/user-posts?ajax=true",
        success: function(data) {
              $.fancybox(data);
        }
    }
});


Combining Feeds (with teasers) on the homepage?

I used the aggregator module and then added the Views block called "feed_block" on the homepage (and only the homepage).  So the blog posts appear just below my introduction to our organization page (that is published to front and stickied).

The aggregator module has all of my external feeds (from other sites). It combines them into a category (I'm not sure if this part is necessary).

The homepage then displays everything from aggregator and also any locally created blog posts (anything with a content-type of "blog").

I might replace this solution with the Feeds module - as the aggregator module does not remove items when the original item is deleted (unless you remove all items and them update them for that feed). Also the feed_block has a "more" link that is broken. It links to the www.domain.org page, when it should link to the node.


Here is the way, I found for D7...

/**
 * Implementation of hook_action_info().
 */
function MODULE_action_info() {
   $action = array(
    'MY_ACTION_NAME' => array(
      'label' => t('MY ACTION LABEL.'),
      'type' => 'node',
      'configurable' => FALSE,
      'triggers' => array('any'),
    ),
 );
 return $action;
}

/**
 * Action function for MY_ACTION_NAME.
 */
function MY_ACTION_NAME(&$entity, $context = array()) {
  // Your code here.
}

Now just add the action MY ACTION LABEL in VBO list.


Unable to run database updates via Drush - Call to undefined function batch_get()

Run your drush statement with the --debug flag, you will see something along the lines of:

Checking DB credentials yielded error: Unable to find a matching SQL     [debug]
Class. Drush cannot find your database connection details.

Try navigating to the actual sites folder e.g. /var/www/vhosts/EXAMPLE/website/sites/default and run the drush command from the site specific directory.


Using theme hook, how do I get block contents into the $comm line?

If you try to access the entity in a template preprocess hook, there is a much simpler way:

function MYTHEME_preprocess_block(array &$variables) {
  // check for custom content block
  if ($variables['base_plugin_id'] == 'block_content') {
    // the entity is alreary availale in the preprocess hook, no need for another query
    $blockContentEntity = $variables['elements']['content']['#block_content'];
    // my advice: pass the entire entity to the template, so you can access all the block fields
    // in Twig without further preprocessing, similar to node templates, e.g.
    // {{ block_content.field_whatever.0.value }}
    $vars['block_content'] = $blockContentEntity;
    // further processsing only for custom content blocks of type 'js_file_block'
    if ($blockContentEntity && $blockContentEntity->bundle() == 'js_file_block') {
        //...whatever you need in here...
    }
  }
}


How to display all terms for specific taxonomy in views incl. ones without content?

If the goal is to also show terms that have no content related to them, it doesn't make sense to start with the Content Views. How could you get terms information from non-existing relations? You could code a custom solution for that, logic that pulls out all terms and if no nodes are tagged display zero.

But there are ways to go forward with core Views.

Display node count on Terms nodes

Create Views of type Taxonomy term displaying terms for the Vocabulary you want
Add a Relationship Content using field_yourtaxreffield
You should already have the Taxonomy field, now add a new Field Title (or NID) and set it to use the Relationship from the previous step (to show nodes titles)
Turn Aggregation on
Edit the Aggregation settings on the Title field, change it to Count DISTINCT. Now you should be able to see the counts, next to all the terms from your chosen vocabulary, including the one with 0 nodes.
(Optional) you can Override the output of this field with custom text to place the count in brackets. The Text might be something like ({{ title }}), check under Replacement patterns

The problem here is extending this result to list node titles. Adding another content related field messes up the Aggregation results because it breaks them into separate rows and count becomes meaningless in that context.

I don't know if there is a clever way to solve it without an additional module. Maybe someone else can come in with the solution.

If using more modules is ok you can look into Views Field View (instructions on how to use it are in Readme file, you could create Embed display with your content and a term contextual filter, then embed it as the third field in the above Views), Views Aggregator Plus has more aggreagator options, Views Distinct (D7 only, might be used to create a new view with its "Aggregate Repeats" and then use regular Aggregation on it).


Intermittent hook_menu error - call_user_func_array() expects parameter 1 to be a valid callback

You say your code is in my_module.inc, which means you have to tell the menu system that it is in there.

By default drupal will load my_module.module, but because the function is not in there it can't find the function.

As a side note, generally you should put hooks like hook_menu() in the .module file.

To tell the menu system that it has to load my_module.inc for your menu callback, do this:

$items['download/register'] = array(
  'title' => 'Register to Download a Lesson Plan',
  'access callback' => TRUE,
  'type' => MENU_CALLBACK,
  'page callback' => '_protected_download',
  'file' => 'my_module.inc',
);

Note the 'file' param.

Also, I made a couple of other changes:

Removed t() from the title and removed the 'title callback', because by default title callback is t().
Removed the 'path' param and changes the array key for the menu item. The path param was used in drupal 6 but not in drupal 7.


How can I specify a "Text Field" as an "Attribute Field Setting" for a Product Variation in Drupal Commerce?

6/5 Follow up:

Looking into this further, the "Cart" module calls the "Options" module in order to determine which fields are eligible to be "Add to Cart" form attributes:

// If the current field instance is not locked, is attached to a product
// type, and of a field type that defines an options list...

In the "Options" module, it looks for data that is entered/stored as an array, e.g. a select list, taxonomy list, etc.

Thinking this through, it seems like it won't be possible to call the user-entered data in a text field for multiple Product Variations because it isn't stored in req'd format.

There may be a way to write custom code to work around this, but I relented and made an absurd list of "Product Specific Options" that takes care of the use case. Since most products on the site will be imported, the burden on editor/user won't be too high.


Taxonomy Reference Based on Taxonomy Field

Two things come to my mind:

For the view make sure to do a taxonomy or user view and add a relationship to each other.
You can also use the private taxonomy module: http://drupal.org/project/private_taxonomy


I'm not 100% sure how this works with your setup and Mailchimp, But i have all of my site emails sending through SendGrid using the SMTP Authentication Support module. So far none have been sent to spam.

One thing to note about SendGrid: Their free account sends your emails through a shared IP. Sometimes they can get blacklisted from time to time. But you can eventually purchase a private ip through them to ensure even better spam protection.


Problem configuring the MailChimp module

Turns out mailchimp was working fine.  The confusion arose in that the mailchimp api doesnt populate the Lists and Users tab on my Drupal installation from mailchimp.  Instead it pushes Druapl's mailchimp lists to sync with mailchimp.  The refresh lists from mailchimp title can be quite deceiving.


Is it possible to use an Oracle database for Drupal 8?

As of now no. only in Drupal 7 we have.
Drupal 8 supports MySQL 5.0.15 or higher (or MySQL 5.1.30 or higher) with InnoDB as the primary storage engine, and requires the PDO database extension.
https://www.drupal.org/requirements/database

https://www.drupal.org/project/oracle -  drupal 7

see the here for further info the thread is postponed as of now

https://www.drupal.org/node/2037119


Drupal will aggregate all of your style sheets into one when you enable it at admin/config/development/performance (Don't set it during development).

If you feel there is too many redundant stylesheets, you can use a module like Omega Tools which allows you to completely disable stylesheets provided by modules (even core).


Looking for exposed filter for private file name

Here's how to set that up:

Make sure you are not displaying teaser/full nodes. This works only for fields.
Under Relationships add your file field. You should select Content: [field name] (field_field_name:fid).
Create new Filter Criteria and choose File: Name.
Choose appropriate operator and optionally expose it to the visitors.

Hope this helps.


Is it beneficial to export views and store it as a module?

The biggest benefit is that you can have your views stored in a version control system like Git or SVN. I maybe mistaken but I don't think there are really performance benefits on doing this.

Some documentation to help you out: http://views-help.doc.logrus.com/help/views/api-default-views


How to create one node tpl files for multiple content types?

Yes you can. Here is the example:

function YOURTHEMENAME_preprocess_node(&$variables) {
  if ($variables['node']) {
    $node = $variables['node'];
    switch ( $node->type ) {
      case 'type1':  // Replace with your actual content types
      case 'type2':
      case 'type3':
      // looks for node--common.tpl.php in your theme directory
      $variables['theme_hook_suggestion'] = 'node__common';
      break;
    }
  }
}


Force a single value base field to be in a separate table?

Seems the following class is responsible for determining a separate field storage table:
\Drupal\Core\Entity\Sql\DefaultTableMapping::allowsSharedTableStorage

It returns a boolean based on the following 4 conditions:
public function allowsSharedTableStorage(FieldStorageDefinitionInterface $storage_definition) {
  return !$storage_definition->hasCustomStorage() && $storage_definition->isBaseField() && !$storage_definition->isMultiple() && !$storage_definition->isDeleted();
}

The only feasible solution would be to implement your own Storage handler and flag the basefield with "custom_storage" => TRUE


Can't find the "Create prev/next controls" option

You can find it in the manage display tab of desired content type.

Choose the format to Slideshow.

Here is a Great Tutotrial


Submitted values are stored in the $form_state['values'] array so you need to test that instead:

if ($form_state['values']['field_product_id'][LANGUAGE_NONE][0]['value'] == '123') {
  ...
}


How can I schedule a rule to always be run at a specific hour of the day?

How about this:

When you're setting the time in the "Scheduled Evaluation Date" section, change it from 'Direct input' to 'Selection mode', and scroll down to where it gives you the option for 'PHP Evalution'

Paste in the following:

<?php
$midnight = strtotime('midnight');
echo date("Y-m-d h:i:s", $midnight);
?>

This should return something like '2013-03-25 12:00:00' // That's what it's returning for today!

You have to include the php brackets.  The strtotime() function should return back midnight of the current day, so it should work for you. I'm thinking since this is based on your cron running, it will not be exact and this should evaluate a little past midnight and 'midnight of the current' day should be exactly what you need.  Maybe you can find a php tweak that makes this better...

Anyway, let us know if that works!


Basically what you want is an image gallery or slideshow. There are many image gallery modules you can install (ie views slideshow, Flexslider).

Then you need to set the slideshow to have a pager of its own, and in the image field you need to take care of the display multiple part (as it is a multi image field) to display one image at a time.

So you will end up with two pagers. One for the view, and one for the slideshow.

Or if you want you can try the Field Slideshow module. It builds the slideshow from one multi-instance field, so half the work is done for you.


Drupal_add_js is not working inside hook submit

You should do this with #attached.

Like,

if (!empty($form_state['values'])) {
  $form['#attached']['css'] = array(
    drupal_get_path('module', 'ajax_example') . '/ajax_example.css',
  );
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
  );
}


Maybe this link helps you: http://drupalminion.blogspot.com.au/2013/05/how-to-add-driving-directions-link-to.html

I am looking for the same answer


There are a few ways to do this.

The simplest is to add your block view to the header or footer of the new view.  To do this, go to the configuration page for the new view and click Add next to Header or Footer (in the middle column).  Choose Global: View area and then select your view.

Alternately, for maximum control over layout, you can use the Panels module, but it is much harder to set up.

Another option is the Views Field View module.  Here is a tutorial about how to set this up.

One further option is the Viewfield module.


When creating content: Force the checkbox "Provide a menu link" to be checked by default

I looked everywhere for this! The Menu Force module does this:

  This module enables you to make the Menu Settings required on specific content types.

After installing a "Make the Menu Settings mandatory for this content type" tick box becomes available on the settings for each content type.


Define custom twig page template for specific multiple node pages by nid - page--custom.html.twig

You can write a hook_theme_suggestions_page_alter()

/**
 * Implements hook_theme_suggestions_page_alter().
 */
function YOUR_THEME_NAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    if ($node->id() == 2 || $node->id() == 4 || $node->id() == 20 || $node->id() == 40) {
      $suggestions[] = 'page__custom';
    }
  }


Chosen module/jquery plugin not accessible on mobile devices?

I just found on the Chosen jQuery documentation in the FAQ section towards the bottom they say that they have disabled the Chosen module for mobile devices by default as there are bugs with the Menu working properly on those devices. Here is a GitHub discussion about the issue.


Why do my breadcrumbs see double? and How can I control them? A double question?

I had similar problem and find out that theme I was using had breadcrumb override function in template.php which was messing with results.


css and javascript aggregation. Can I still edit files?

You can still edit the original files as much as you like, but you won't see the changes reflected in the front end until you clear Drupal's caches.

You can absolutely still use Firebug to inspect your CSS, but keep in mind that the files have been aggregated, so you won't be able to pinpoint the original file and line that a rule comes from.

That's pretty much why it's recommended to keep aggregation off during development, unless of course you're testing the aggregation itself.


display all products in a single page (without using pager) ubercart

You could use the Views module to create a Page display that lists all your products.

Also, I haven't tried it myself, but here's a blog post on Exposing Items Per Page in Drupal Views. A patch has been committed to the 6.x-3.x version of Views that apparently offers a similar "items per page" select box.


We can alter a views query using hook_views_query_alter. Try to search in your codebase for this string views_query_alter, you should get a function in one of the custom module which is implementing hook_views_query_alter.

If it doesn't help, try to enable query log using devel module, so you will know what query are being executed for that page. Views also gives the sql query that a particular display will run. See if these two sql queries don't match. You can see the diff and then try to figure out which module might be adding the additional conditions to that query.


Boost bypasses execution of Drupal's PHP and serves static files.  So unless you have other problems, it should always be much faster than the standard Drupal cache.  Be aware that it only works for anonymous users.

View source on your pages when running boost and make sure they have a comment at the end that says cached by boost.  Boost puts that comment there by default.  If you haven't disabled it, and it's not there, boost isn't working properly.  It's usually caused by incorrect or missing .htaccess rules.  If you don't see this comment, you won't see an error on the status page.  Your site will work normally, but is not being cached.

It looks like this:

</body>
</html>
<!-- Page cached by Boost @ 2012-10-30 15:01:23, expires @ 2012-10-31 15:01:23 -->


How to template a view and be able to manipulate the content with it?

You should create new display modes for the content in question, and provide twig templates for them (e.g. node--type--display-mode; I am unsure of the pattern). Then you can change the View to show the rendered entity, and select that display mode, which will use the twig template for it.

This will be a lot easier IMO for what you are trying to do and make the View itself more maintainable long term. For example, maybe you wind up having to make multiple views... editing all those fields via Views is going to become a real pain real fast. Changing the field configuration in the display mode settings of the respective entity type will be reflected in the View immediately without changing the View itself (unless caching is enabled, then clear it).

See: http://www.mediacurrent.com/blog/drupal-8-theming-without-panels for some background.


Ubercart Discounts (Alternative) needs Content module

Content is the core module of CCK. You can find it under the CCK section of your module install page.


How can I get a count of users with a certain role?

You should create a view with filter criteria "role" then you expose it and allow multiple selection.

Then you can create an header or footer (always in view) and add this piece of code

<?php
  $view = views_get_current_view();
  print $view->total_rows;
?>

You should have the php filter enabled.
This works for me.


Custom form handler not found (call_user_func_array() error)

Use '::uso_cancelForm' or [$this, 'uso_cancelForm'].


Node paths with custom prefix based on taxonomy

Create a new field on the Category Taxonomy called something like "Title Prefix" and then use this Field to create a custom path for the article


In views-view.html.twig is not appropriate to style your row and fields.

To style them first you need override template "views_view_'format_style'" (format style specified when you edit/create a view). Here you can style row and access 'fields' variables (use kint(row) to see them).

Something like:

{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  {{ kint(row) }} {# devel #}

 {{row.content['#node'].getTitle()}}
 {# access fields #}

    {{ row.content }}

{% endfor %}

For style fields its better override field template.

For example field--node--body--article.html.twig:

{% set mode = element['#view_mode'] %}
{% if label_hidden %}
  {% for item in items %}
    {% if mode == 'full' %}

{{ item.content }}

    {% elseif mode == 'teaser' %}

{{ item.content }}

    {% endif %}
  {% endfor %}
{% else %}

{{ label }}

    {% for item in items %}

{{ item.content }}

    {% endfor %}

{% endif %}

source : In Drupal 8 view.html.twig file how do I access the view content such as individual field title and/or field content?

http://twig.sensiolabs.org/doc/tags/for.html


It is a permissions issue...basically your web server needs permission to write to 'sites/all/modules' for Drupal to be able to get the new module folder there without using FTP.

However, it's a security risk to do this, so if your server is already configured in such a way that stops the apache/php daemons from writing to those folders you should keep it that way.

The better way to install modules automatically in Drupal is to use the Drush command line tool. You can issue a couple of commands:

drush dl views
drush en views

And the module will be automatically downloaded and installed on your site. Drush is infinitely more powerful than that (you can perform all sorts of administration tasks easily from the command line) so if you haven't come across it before I'd thoroughly recommend giving it a go.


How can translations 'inherit' CCK values of the node in the default language

I've found a solution that works for my needs. There's probably a better way:

Modules used: Views Bulk Operations, Node Clone, Views Bonus Pack, Language Assign, Feeds

Assumptions: you have a CSV file or MySQL database with translations of your pages in another language. It's not necessarily to have this - it just makes things faster.

Install the Node Clone module and Views Bulk Operations (VBO) module. Add this patch to expose the Clone feature to VBO.
Clone the nodes you need in VBO. This will append 'Clone of' to the title of each cloned node.
Set the language of the new nodes, again using VBO and Language Assign.
Install the Views Bonus Pack to get CSV export functionality. Create a View that uses the CSV Feed style, and add the title field and any other fields you need translated. Add a filter that displays only fields where the title starts with 'Clone'.
Export the nodes using the View created in the previous step.
Now, you can either manually add your translations to the CSV file by replacing them with the relevant translations, or you can use your new CSV as a reference file to add the right node ids to your original CSV with the translations. Basically, at the end of it, you have a file like this:

-->

| Node ID | Original Title | Chinese Title  | Body         | Some other field |
| 234     | Hey You        | ????           | Blah, blah   | Blah ...         |

Now, you can install the Feeds module, override the default CSV import, changing only the mapping and content type to use. Map the field 'Node ID' to the node ID (or the original title to the node title), and change the Update options to 'Update node.'
Go to http://yoursite.com/import. Do your import. I did, and now I'm happier.


Drush command can't find Drupal module function

It sounds like your site is not being selected.  Try calling your command with your cwd in the same folder as your settings.php file (e.g. cd sites/default); that should work.  You may also create an alias for your site, and call your command from any directory via drush @site mycommand


The 'super user' (user 1) has privileges that you won't be able to completely emulate for other users. There are hard-coded bypasses in functions like user_access() that allow that user to do pretty much anything they want.

Permissions are granular in Drupal, so the idea is you give a certain role a certain set of permissions based on what they should be allowed to do.

To get as near as possible to another role being able to do everything the super user can, you just need to go to admin/people/permissions and tick all of the permission boxes for the administrator role. I'd advise checking each permission (if only this once) as you do this, to make sure you're definitely giving that role the access you expect.

When you then assign the administrator role to other users, they'll essentially be able to do anything on the site that you've allowed them to do through the permissions page.


How do I use a drush alias to connect to a docker container?

So this one threw me for a while this evening as well.

Here's what ended working:

$aliases['docker'] = array(
  'uri' => 'http://localhost:8080',
  'php' => '/usr/bin/php',
  'root' => '/var/www',
  'remote-user' => 'root',
  'remote-host' => '0.0.0.0',
  'ssh-options' => '-p 8022 -o PasswordAuthentication=no -i ~/.ssh/id_rsa',
  'path-aliases' =>
  array (
    '%drush' => '/root/.composer/vendor/drush/drush/drush'
  )
);

The remote host of 0.0.0.0 ended up doing the trick. Seems that if you use localhost or 127.0.0.1 drush doesn't actually try to ssh in.


The Encrypt module:

  provides an application programming interface (API) for performing two-way data encryption. It allows modules to encrypt data such that it can be decrypted using the same key that was used to encrypt the data. This is useful for storing sensitive information.

Emphasis mine. That's its purpose, to provide an API that other modules can use to encrypt data before it's stored in the database (or elsewhere I guess).

As an API module, it provides no functionality unless you make explicit use of it; either by installing one of the modules listed that uses it, or by writing a custom module that does so. The emphasis is on you (or the writer of a contrib module) to actually do something useful with this module:

  It is up to the module calling encrypt() to manage and store the encrypted data.

The important thing to understand is that it doesn't (and couldn't) protect users from having their data sniffed over a public network. For that you'll need to use HTTPS, no exceptions. All this module does is offer an encryption/decryption service for your server-side app.


Autocomplete on a custom field on the registration form no longer working

What you say suggests it's this line that's the issue:

 if ($_SERVER['HTTP_REFERER'] == url('user/register', array('absolute' => TRUE))){

so there's presumably some difference between the referrer URL and the one generated by the url() function. You might add lines above it to record the two values using watchdog: that would confirm you are reaching that point in the code and help diagnose the issue.


May be this can be a good way to start with
1.I think you will need views_infinite_scroll module for the list view.
2. Set your views listing path as path/%
3. For list view set row classes as nids
3. Now with custom jquery code you take the nid from url and do a $.scrollTo(..) and nids set as row classes may help you finding the appropriate position to scroll to.
does it make sense?


Save image in any weight and immediately reduce it

I'm finding that drupal 7 does that out of the box (although it's possible I have a module doing it.  Rather than fixing the size of the file, set the max pixels for the image and drupal will resize it (and thus reduce the size) on upload.


Send mail to email addresses from webform when a content is saved

Enabled the PHP filter module and the list item is available in the PHP evaluation area. So fetch the email is as <?php print $list_item->data['component_id']['value'][0]; ?>. Works pretty well :)


There's a setting under the Global Redirect settings to Remove Trailing Zero Argument:

According to the description for this option:

  If enabled, any instance of "/0" will be trimmed from the right of the URL. This stops duplicate pages such as "taxonomy/term/1" and "taxonomy/term/1/0" where 0 is the default depth.

That should fix the problem you're having.


Calculate the sum for 3 CCK fields with Rules in Drupal 7

I found the answer:

For Event I used:

After updating an existing commerce product

For Conditions I used:

Entity has field

Parameter: Entity: [commerce-product], Field: field_stock1

Entity has field

Parameter: Entity: [commerce-product], Field: field_stock2

Entity has field

Parameter: Entity: [commerce-product], Field: field_stock3

Entity has field

Parameter: Entity: [commerce-product], Field: field_totalstock

For Actions I used:

Calculate a value

Parameter: Input value 1: [commerce-product:field-stock1], Input value 2: [commerce-product:field-stock2]; Provides variables: Calculation result for Stock1  and Stock2 (stock1_plus_stock2_result)

Calculate a value

Parameter: Input value 1: [stock1-plus-stock2-result], Input value 2: [commerce-product:field-stock3]; Provides variables: Calculation result for stock1-plus-stock2-result and Stock3 (stock1_plus_stock2_result_plus_stock3)

Set a data value

Parameter: Data: [commerce-product:field-totalstock], Value: [stock1_plus_stock2_result_plus_stock3]

You can see what I wrote on http://ucreateawebsite.com/DRUPAL/dalexgrup/pt.


View to display user points and the reason for the points

I have userpoints active on one of my sites, and the display you are looking for is integrated with the module.

Look at the user account, there should be a tab (Points) (/user/$uid/points).

To create your own page, introduce a required relationship to the users table, then a contextual filter using that relationship on user:uid. When the configuration screen comes up, under 'When the filter is not in the URL' provide a default value > UID from currently logged in user. This should get your view working.

Note: The relationship must be created first, then it is available for the contextual filter.

Edit: Step by step.

Add new view: (/admin/structure/views/add)

In the 'Add View' screen, enter view name, and choose to Show 'Userpoints Transactions' of type 'all'. I chose a Table format to show fields. The rest is adjustable later.

Click 'Continue and Edit' to go to the edit screen.
Add a relationship for 'Userpoints Transactions:User'. Check 'Required' and 'Apply all displays'. This will bring the users table into the view.
Create a contextual filter on 'users:uid' using the relationship you just created. Configure the default value provided as 'UID from logged in user', and Apply.
Add whatever fields you wish and format the view.

This is the export:

$view = new view();
$view->name = 'users_points';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'userpoints_txn';
$view->human_name = 'Users Points';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Users Points';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
/* Relationship: Userpoints Transactions: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'userpoints_txn';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['required'] = TRUE;
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Field: Userpoints Transactions: Description */
$handler->display->display_options['fields']['description']['id'] = 'description';
$handler->display->display_options['fields']['description']['table'] = 'userpoints_txn';
$handler->display->display_options['fields']['description']['field'] = 'description';
/* Field: Userpoints Transactions: Points */
$handler->display->display_options['fields']['points']['id'] = 'points';
$handler->display->display_options['fields']['points']['table'] = 'userpoints_txn';
$handler->display->display_options['fields']['points']['field'] = 'points';
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'users-points';

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';

Second Edit:

The descriptions shown in the screen print you showed me are not stored in the database, but are generated on the fly when the page is requested.

Here is how you complete the view.

First, install and activate the Views PHP module.

Second, go into userpoints.views.inc and change 'field' => 'nid'; on line 435 to 'base field' => 'nid';. Then insert the following code after line 466:

$data['userpoints_txn']['txn_id'] = array(
      'title' => t('Transaction ID'),
      'help' => t('The transaction ID for the points allocation.'),
      'field' => array(
          'handler' => 'views_handler_field',
      ),
      'filter' => array(
          'handler' => 'views_handler_filter_string',
      ),
      'sort' => array(
          'handler' => 'views_handler_sort',
      ),
  );

This will make the Transaction ID accessible to views. (The necessary changes are included in a patch file linked at the end of this answer.)

Save your view in its current form to clear its temporary cache, then go to /admin/config/development/performance and clear your caches.

Return to your view, and add 'Userpoints Transactions:Transaction ID' as a field, and set it as excluded from the display.

Then add another field. In the 'Add Field' screen, filter on Global, and select 'Global:PHP'.

To configure the field, Create a label of your choosing, and in the Output box add the following:

<?php
$transaction = userpoints_transaction_load($row->txn_id);
$value = userpoints_create_description($transaction);
echo $value;
?>

Note: Do not place anything in the Value box! It is used for another purpose.

Save your view, and you are good to go.

BTW. The changes necessary in userpoints.views.inc are in a patch attached to the Features Request issue I opened on D.O.


programmaticaly extract the shipping service name

I am not a developer, just found a code sample from @googletorp on the link below. Just modified that and got the result.

https://www.drupal.org/node/1555994#comment-5963680

    foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    if ($line_item_wrapper->type->value() == 'shipping' ){
    $form['merchant_defined_data6'] = array(
    '#type' => 'hidden',
    '#value' => $line_item_wrapper->commerce_shipping_service->value(),
  );

  break;
  }
}


How to select quarters in a date field not the actual date?

I also could not find a widget that provides this functionality but I would stick to the date field.

You need 2 things:

A widget that allows you a selection like that.
A custom format for the display of your field's value. The default date format will not help here since PHP does not provide the quarter.

Keep in mind that the storage for the values will be a normal date but you could i. e. interpret "2017-01-01 00:00:00" as "Quarter 1 2017", "2017-04-01 00:00:00" as "Quarter 2 2017", etc.

You can find further information on how to create your widget and formatter here:

Widget: You can also take a look at the date_popup sub module of the date module.
Formatter


How can I disable meta tags provided by the Metatag module for a custom route?

Edit – @AlfredArmstrong pointed me to the hooks provided by the Metatag module itself. And there's hook_metatags_alter() you can implement to completely disable all meta tags added by the Metatag module. Much shorter than my original answer.

/**
 * Implements hook_metatags_alter().
 */
function MYMODULE_metatags_alter(array &$metatags, array &$context) {

  // Exclude meta tags on 'player' route.
  if (\Drupal::routeMatch()->getRouteName() === 'player') {
    $metatags = NULL;
  }
}

Original answer – I've had similar problems before. You can override or unset meta tags added by the Metatag module implementing hook_page_attachments_alter() like in the following example.

/**
 * Implements hook_page_attachments_alter().
 */
function MYMODULE_page_attachments_alter(array &$attachments) {

  // Check for the route you want to override.
  if (\Drupal::routeMatch()->getRouteName() === 'player') {

    // An array of tags you want to unset.
    $unset = [
      'description' => 1,
      'abstract' => 1,
      'keywords' => 1,
    ];

    $meta_tags = $attachments['#attached']['html_head'];
    foreach ($meta_tags as $key => $meta_tag) {

      // And now unset them.
      if (isset($unset[$meta_tag[1]])) {

        unset($attachments['#attached']['html_head'][$key]);
      }
    }
  }
}


How do I verify that the form input date is valid?

If the date is valid, then the form state will return an object of type Drupal\Core\Datetime\DrupalDateTime, and otherwise it will return an array with the invalid values. Since the invalid date format will be caught elsewhere, the custom code need only check if the value is an instance of DrupalDateTime:

if ($date_of_meeting instanceof DrupalDateTime) {
  $formatted_date_of_meeting = $date_of_meeting->format('l, j F Y');
  $node->setTitle($name_of_meeting.' on '.$formatted_date_of_meeting);
}


How to grant User Points after Quiz questions are answered correctly?

If using Quiz 7.x-5.x

Assuming you're using the 7.x-5.x-rc3 version of the Quiz module, you can take advantage of integration with the Rules module that this new release comes with.

To do so, have a look at the delivered rule, which looks like so:

{ "rules_send_results_at_the_end_of_a_quiz" : {
    "LABEL" : "Send quiz results at the end of a quiz",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "TAGS" : [ "quiz" ],
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : { "quiz_result_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "quiz-result-unchanged:is-evaluated" ], "value" : "0" } },
      { "data_is" : { "data" : [ "quiz-result:is-evaluated" ], "value" : "1" } }
    ],
    "DO" : [
      { "mail" : {
          "to" : [ "quiz-result:uid:mail" ],
          "subject" : "[site:name]: Your results for [quiz-result:nid:title]",
          "message" : "[quiz-result:uid:name],\r\n\r\nYou finished the quiz [quiz-result:nid:title] on [quiz-result:time-start]\r\n\r\nYour score: [quiz-result:score]%\r\n\r\nYou can access the result here: [site:url]node\/[quiz-result:nid:nid]\/quiz-results\/[quiz-result:result-id]",
          "language" : [ "" ]
        }
      },
      { "mail" : {
          "to" : [ "quiz-result:nid:author:mail" ],
          "subject" : "[site:name]: [quiz-result:uid:name]\u0027s results for [quiz-result:nid:title]",
          "message" : "[quiz-result:nid:author:name],\r\n\r\n[quiz-result:uid:name] finished the quiz [quiz-result:nid:title] on [quiz-result:time-start]\r\n\r\nTheir score: [quiz-result:score]%\r\n\r\nYou can access the result here: [site:url]node\/[quiz-result:nid:nid]\/quiz\/results\/[quiz-result:result-id]\/view",
          "language" : [ "" ]
        }
      }
    ]
  }
}

After you enable Rules (and Rules UI, a submodule of it), just clone the above rule (using the Rules UI) and replace both Rules Actions with a Rules Action to grant an amount of User Points that you may want to be related to [quiz-result:score] (note that this token is also shown in the Rules example above (within the Rules Action).

If you're not familiar with how to use Rules to grant user points, then have a look at the answer to "How to grant userpoints only for modifying nodes last changed at least 20 days ago?" (which also includes a Rules example to make that happen).

If using Quiz 7.x-4.x

For the 7.x-4.x version of the Quiz module, you may want to try the patch from fago (aka the Rules maestro ...), attached to issue # 1300420, which has a description like so (note the last phrase in it ...):

  ... adds basic rules integration to quiz. It includes an event when users have finished taking a quiz, a condition to check whether a user has passed a certain quiz and an action to clear quiz results for a user.

  Patch works for me.


Custom module is not showing up for regular user

user_access(), the access handler used by default from Drupal when no other access handler has been set, returns TRUE (the user has access to the menu) only when the permission string is one defined from a module, and the user has that permission.

If "ask question" is not a permission defined from any module with hook_permission() (Drupal 7 or higher), or hook_perm() (Drupal 6 or lower), then you will get an access denied error.

Once you are sure a module (including the one you are developing) defines the permission you want to use, be sure the same permission is assigned to any of the roles the currently logged-in user has. For example, if the user has the role of editor, then the permission you are using needs to be assigned to the editor role, or to the authenticated user role.


Please provide the markup that's currently produced by this code. The PHP logic looks fine but it's not cleat if $field->label_html has a value that will trigger and of the if statements. As a bare minimum you should be getting:

<table width=100% border=1>
</table>


How can I display filter guidelines/tips below field for text formats?

namespace Drupal\my_module;

use Drupal\editor\Entity\Editor;
use Drupal\editor\Element;

/**
 * Defines a service for Text Editor's render elements.
 */
class CustomElement extends Element {

  /**
   * Additional #pre_render callback for 'text_format' elements.
   */
  public function preRenderTextFormat(array $element) {

    $element = parent::preRenderTextFormat($element);

    $format_ids = array_keys($element['format']['format']['#options']);

    // Early-return if no text editor is associated with any of the text formats.
    $editors = Editor::loadMultiple($format_ids);

    // Hide the text format's filters' guidelines of those text formats that have
    // a text editor associated: they're rather useless when using a text editor.
    foreach ($editors as $format_id => $editor) {
      // Display filter guidelines.
      $element['format']['guidelines'][$format_id]['#access'] = TRUE;
    }

    return $element;

function my_module_core_element_info_alter(&$types) {

  $types['text_format']['#pre_render'][] = 'my_module.element.editor:preRenderTextFormat';
}

function my_module_module_implements_alter(&$implementations, $hook) {
  switch ($hook) {
    case 'element_info_alter':
      $group = $implementations['my_module'];
      unset($implementations['my_module']);
      $implementations['my_module'] = $group;
      break;
  }
}

Above piece of code worked me and defined this service.


Rename "-none-" option for select list field type

Implement hook_form_alter() or hook_form_FORM_ID_alter() and use the following code:

$form['field_name'][LANGUAGE_NONE]['#options']['_none'] = t('Select');

example:

function MODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
    $form['field_name'][LANGUAGE_NONE]['#options']['_none'] = t('Select');
}

The t() function is for translation.  It may not be required, but it is good practice to use instead of hard-coded strings.

To remove - None - as a choice all together, you could unset the key using hook_form_alter as well.

example:

function MODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
    unset($form['field_name'][LANGUAGE_NONE]['#options']['_none']);
}

If you're not using it already, be sure to install the Devel module so you have access to the dpm() and dd() functions.  They are incredibly valuable when playing with Drupal forms.


Where to add CSS and Javascript directives so they are inserted into the header?

The best way to do this is to add the files inside your theme's info file. However you shouldn't need the jquery file, this is included in Drupal core.

scripts[] = scripts.js
stylesheets[all][] = style.css

Morea bout info files here: http://drupal.org/node/171205


How to debug invalid plugins derived by the GraphQL module?

I am a little late but you can enable dblog core module and see if any errors are printed to the watchdog table by running drush wd-show after an attempt to access the explorer page.


I believe this is due to your browser cache, not drupal cache. If you clear your browser cache or go incognito in chrome you should see your changes.


Quick and dirty, if all you are wanting to accomplish is to add class="img-rounded" to the <img> tag, you could do this right before you render $item:

<?php $item['#item']['attributes']['class']='img-rounded'; ?>

(Quick and dirty because this assumes no one else somewhere along the line has added or will be adding a class to your image.)


How can I alter the title of a node upon save?

I'm not sure why exactly you need the ID, if you don't care about it, wouldn't the date or something like that suffice too?

If you really want the ID, then you need both hooks, because you can't save the node without a title. So you need to set a dummy title in presave and update it again in insert. I'm not sure why saving there didn't work for you, it should, I've done similar things. If you provide the full exception message and stack trace, maybe I can help figure it out. Note that by default the sql content entity storage catches the thrown exception and re-throws a different one and our exception handling can't handle that. You need to print out the original exception stack trace where that happens, with print $e->getTraceAsString().


$(...).accordion not a function error in drupal7 views accordion module

Install the jQuery Update module and set jQuery of your website to 1.7+.


How to create a view displaying nodes posted in the logged-in user groups?

In Views you can use  User: Current under "Filter Criteria" to filter the view results.


Quick tabs: Passing current nid to a view

Ok I've worked it out. The URL that QuickTabs references is the System URL, so the NID is there and can be referenced just by %1.

I knew there would be a simple answer! Hopefully this will help someone else.


How to display date and time picker for base field on custom entity

setSettings(['datetime_type' => 'date']) - this seems to be to blame. See the switch in the source here which effectively says if type is 'date' (implemented as a const) then only show the date form element, otherwise show the date + time elements.


path issue with translated (entity_translation) nodes

Entity Translation 7.x-1.x-dev solves this.

Hint provided in the Packt Drupal-7-Multilingual-Sites book:

  Pathauto works fine for nodes using the node translation model as each
  language  has a separate node. At the time of writing, for feld
  translation, the Pathauto and  Entity Translation module maintainers
  have been ironing out some issues. To get   the automatic URL aliases
  to work in Drupal 7 for feld-translated nodes, you must  use at least
  Entity Translation version 7.x-1.0-alpha2, if available, or the most
  recent  dev version.


How to make a block visible on a particular page and as well as on taxonomy term page?

Well from what I understood from your question, you can use following lines of code in your template file where you want to display the block:

if(arg(0) == 'taxonomy' && arg(1) == 'term') {
  $tid = (int)arg(2);
  $term = taxonomy_term_load($tid);
  $taxo_term = $term->vocabulary_machine_name;

  if ($taxo_term == "your_vocabulary_name") {
    print render($page['your_block_region']);
  }
}

PS: I dont know if this is very standard(drupal) way to achieve this but it has        worked for me.


How to provide link to styled image in a services feed

I think the Image URL Formatter module will help.

Image URL formatter module offers 3 options that are not contained by views:

support Image styles
support multivalues, there is a "Multiple field settings" when image field is multivalue.


Where does Drupal store its url/domain name?

Check https://www.drupal.org/node/776864 under Troubleshooting - No user login. It might help.

Basicly, it says Enable clean URLs, check Apache config, check .htaccess, you probably want to uncomment rewritebase. Also check that "$cookie_domain" is not set to your old domain.


How can I get a summary from a view into another view?

You can combine the Views Field View module with the Views Aggregator Plus or with the Views Calc module.

Views Calc:

  Adds simple calculations to a views table. You can SUM, AVERAGE, COUNT, MIN, MAX, or AVG selected columns. A plug
  in theme makes the view look more spreadsheet-like (right justifies
  numeric fields, shades calculated columns and rows, and underlines
  calculated rows).

Views Aggregator Plus:

  In addition to what Views and Views Calc do, this module:

  enumerates group members
  produces tallies, i.e. textual histograms
  aggregates on Views PHP code-snippet evalutations
  can filter out result rows on regexp patterns
  gives you sorting on Views' Math expressions
  can process Webform submissions
  lets you add your own custom aggregation functions

  ... and it puts summary statistics at the bottom of your aggregated
  table as well!


To analyze the performance of each multisite you will need to coorelate web server logs with performance logs or use an APM service like Newrelic where you can watch PHP at a very granular level as the cron jobs run.

Unfortunately, there is no easy fix for your problem. Multisites can only be used when the sites are not complex or demand a lot of processing. I believe you have a decision to make.

Keep using the multisite function of Drupal and deal with the performance issues you have in complicated and creative ways. Create ways would be using multiple servers and databases to offload the cron jobs to so it does not impact the websites.

OR

Break the sites up into different Drupal installations and use a code repository to manage the multiple sites.

You should read the articles written by Pantheon on Multisites. They had the same problem as you and realized the problems (performance) with multisites and devised another way to run complex multisites.


I think you can use the Signup Module for this. The Signup form itself can be modified and changed for your needs. Have a look at the file signup_form.inc in the signup/theme folder. Copy the theme_signup_user_form($variables) function to your template.php in your theme and start modifying the form.


Yes, there are a few methods.

One uses what Drupal considers filters.  I a not sure what the best starting point for these is, but the API reference for hook_filter_info should be a decent read.

Another is via preprocess and process functions.  Again, I am not sure what the best online starting point for these is, but take a look at the API reference and search for "process" and "preprocess".

The concept of Drupal 7 render trees along with field templates / template functions can also be thought of as a way to process content for display.

My copy is at work, but I think both filters and preprocess/process hooks are discussed in Drupal 7 Module Development.  I can't remember if render trees and field templates are in that book or their theming book.


Configuration values in Kernel Test are null

Turned out to be a very silly mistake...
I instatiated the service before installing the config with $this->installConfig(['mymodule'])


How to print the HTML content of the text field in Drupal 6 programmatically

You can use content_view_field

  content_view_field : Render a single field, fully themed with label
  and multiple values.

Code

$node = node_load('NODE_ID');
echo content_view_field(content_fields("field_example"), $node, FALSE, FALSE);

Reference

Print a formatted CCK field with PHP


I do not see any problem here. You can do it like this:

Add the view
Add the fields
Add NID, exclude it from display, and move it to top of list
Open the field setting which you want to change, expand the Rewrite results fieldset, and check "Output this field as link"
As link path input, enter node/[nid] (this is the token)


When you're not satisfied with the existing view modes you could create your own using either your own tiny plugin (see ready code) or use Display Suite. The new view mode will appear in Views UI for selecting.

I'd recommend however the true theming technique by using Views and fields. There you have more flexibility and control over the markup. You can do many things using Views UI (such as turning off the wrapper markup, linking a field to its content, overwriting some attributes, etc.) When you find out you cannot do something in Views UI this might be a reason for using a .tpl.php file at one of the output levels - in your case the style or row variants would be your friends)

It's recommendable that you watch some Views tutorials, such as NodeOne's Taming the Beast series or by Mustardseed Media (even if for Views 2 only) to get the idea how to tailor Views output to your needs.

Hope this helps.


Editing the 'default front page' base URL

Have you tried the below changes in your settings.php and .htaccess?

 /sites/default/settings.php

$base_url = 'http://www.example.com'; // NO trailing slash!

and

.htaccess

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # RewriteBase /drupal

Try using this.


Change edit link URL in the content administration page

Go to YOUR_SITE/admin/config/search/path/delete_bulk check All aliases and click in Delete aliases now!


What some people call a "dofollow" link is just a normal link - i.e. a link that is not tagget with the rel="nofollow" attribute.

In other words, this what a dofollow internal link looks like:

target

There is no dofollow (or similar) attribute you can add to the link.  The absence of nofollow is what you're looking for.


It looks like I had my profile2 fields mixed up with my account fields.


How to prevent button to use validation function?

You are looking for two Form API entries:
#ajax['prevent']:

Description: A JavaScript event to prevent when 'event' is triggered. Defaults to 'click' for #ajax on #type 'submit', 'button', and 'image_button'. Multiple events may be specified separated by spaces. For example, when binding #ajax behaviors to form buttons, pressing the ENTER key within a textfield triggers the 'click' event of the form's first submit button. Triggering Ajax in this situation leads to problems, like breaking autocomplete textfields. Because of that, Ajax behaviors are bound to the 'mousedown' event on form buttons by default. However, binding to 'mousedown' rather than 'click' means that it is possible to trigger a click by pressing the mouse, holding the mouse button down until the Ajax request is complete and the button is re-enabled, and then releasing the mouse button. For this case, 'prevent' can be set to 'click', so an additional event handler is bound to prevent such a click from triggering a non-Ajax form submission. This also prevents a textfield's ENTER press triggering a button's non-Ajax form submission behavior.
Values: String. Possible values: One or more jQuery events, with multiple events separated by space characters.

#limit_validation_errors:

Description: Provides an array of sections which are parts of $form_state['values'] which should be validated, implying that sections which are not listed should not be validated. This is normally used in multistep forms in the case of a "back" button, for example, where '#limit_validation_errors' => array() would mean not to validate anything as form values on the current page are to be discarded anyway. #limit_validation_errors does not have any effect if #submit is not set. More discussion is in the form_set_error() documentation.
Values: array indicating sections of the $form_state['values'] which should be validated.


Convert an already created custom content type into a new module

Use Features. It's main job is to export such configuration into code. While not primarily intended to be manipulated afterwards, it's definitely possible, as I've done so several times myself.

You can even add custom directly into the generated .module file and features will respect and keep that if you do further changes from the UI later.

This way you can keep using the UI to make most of the changes to the content type, yet keep custom logic in the same module.


Change entity.field.FieldFormatter for a custom view

The correct way to implement this, is to use "Display modes":
add custom "Display mode" for entity, and set the another formatter for images field. In the View settings set it to use that "Display mode" to display entity.


How to change date format in Views Calendar Pager?

This is an issue in the calendar module that has been fixed in the 3.x-dev version. There is still no setting to set the header the way you want but at least it doesn't default to the 1st of each month without hacking the module.


How can I sort taxonomy term using attachment in drupal view

If u are creating view of taxonomy term, then it gives you option for sorting taxonomy term using name, However if u are using content type view and u want to show attachment, then add Global:View in attachment fields, and choose a view of taxonomy, with passing contextual filters in it.


Tried to Inline CSS with AdvAgg but still get errors in Google

Your setting for Inline CSS on specific pages is wrong. The path you should set is:

node/*


What is an alternative and easy way to test if Webform is in fact sending mail?

Try one of the Mail Logger or Maillog modules. That will enable you to see whether there is an email actually being created. I personally used to use the second, with D6 though.


myform_validate() and myform_submit() functions not responding

1 . You can add how many submit handler you want by using this

 $form['actions']['submit']['#submit'][] = 'mymodule_what_ever_function';

if you want to add a submit handler after default submit handler one callback the next callback to be called you can use this, This submit handler will be called after submit call back.

form['#submit'][1] = test_function;

To unset submit handler

submit handler

unset($form["actions"]['submit']);

$form['#validate'][] = 'test_validation_function';

function test_validation_function($form, $form_state) {}

this function will call before submitting the result.

Add these handlers and once clear your Drupal cache

Still you face issue look in to this url for example will help you out

https://www.drupal.org/node/717740


To achieve this you have to use Rules as well as Scheduler module. Please follow the documentation links: Rules documentation: https://www.drupal.org/documentation/modules/rules Scheduler documentation: https://www.drupal.org/node/108984

You can also refer: http://www.webwash.net/tutorials/how-send-follow-emails-using-rules-scheduler-drupal-7


display only selected terms in custom node template

For specific node you need to use $info = node_load($nid) where you find your field value using $info->field_name. Using that field you can use foreach something like foreach($info->field_name as as $key => $items).


menu item for current page is missing a href tag for anonymous user

I fixed this issue by overriding menu.html.twig. You could override menu--main.html.twig instead, if you just want to target the main menu:

menu.html.twig

  ##REPLACE THIS LINE:## {{ link(item.title, item.url) }}
  ##WITH THIS LINE:## {{ item.title }}
  {% if item.below %}
    {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
  {% endif %}

I submitted a bug report here: https://www.drupal.org/node/2695619


How to install patched Paypal module in Drupal Commerce?

You have to make sure that the temporary directory is configured at admin/config/media/file-system is writable.

In my case /tmp is writable, as per the settings in the screenshot below.


Drupal Views: Contextual Filters for certain fields

Sure - that's a lot easier in Drupal 7 / views 3 than it used to be. You're displaying this block on a node page, correct? All you need to do is add a contextual filter of 'Content: Nid' and then add a 'default value' of type 'content id from url'.

That will pull the node id from the current url and pass it as an argument to this filter, restricting the output of your view.


How to make the radio field checked by default?

I canno't comment to suggest you a solution, but it's probably due to the module field_group (or fieldgroup).

You should try the same content type configuration by using field_collection, because i have never faced any issue with this module.

1/ You create a new field type : field collection. You setup the field with an unlimited number of occurrences.

2/ You go to structure > field collection and add your fields.

I hope it help

Cheers.


At a guess...

field_gallery, and other fields, are render arrays; that means they have extra elements in them for the meta data (so called # properties). slice doesn't know the difference between a render array child element, and a # property, so it just chops the array up the same way it would any other. The first item in the array is probably a # property, hence nothing is being rendered.

The first example works because you're referencing a specific child of the render array by key, which is then rendered immediately.


Open Outreach distribution image not displayed & unable to upload new image

It appears that, by looking at the code that causes that "Illegal choice public in Destination element" error you got, "Public" is not an acceptable choice in the element with name "Destination". Not sure if this rings any bell, but maybe it helps somehow.

After you find the solution (reason) for this problem, you probably also solved the remaining error as you mentioned about ' ... "Destination *" message ...'


paragraph template suggestion based on parent content type

Add a theme name suggestion:

mytheme.theme:

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function mytheme_theme_suggestions_paragraph_alter(&$suggestions, $variables) {
  $paragraph = $variables['elements']['#paragraph'];
  $parent = $paragraph->getParentEntity();
  if ($parent) {
    $suggestions[] = 'paragraph__' . $parent->bundle() . '__' .  $paragraph->bundle();
  }
}


Maybe you're hitting your server's max_execution_time. It's quite likely with such a big number of nodes, and this operation taking a long time is normal.


How to get and apply current page query parameters from current AJAX request

No, HTTP_REFERER is not reliable and yes, the solution is to add the query parameters of the current request to each AJAX link. Form API does the same for form elements:

RenderElement::preRenderAjaxForm:

    // Add all the current query parameters in order to ensure that we build
    // the same form on the AJAX POST requests. For example,
    // \Drupal\user\AccountForm takes query parameters into account in order
    // to hide the password field dynamically.
    $settings['options']['query'] += \Drupal::request()->query->all();


couldn't load site name in html template

There's no $site_name variable added to html.tpl.php, but you can add it yourself quite easily with a preprocess hook:

function MYTHEME_preprocess_html(&$vars) {
  $vars['site_name'] = variable_get('site_name', 'Default');
}


Get fields out of an entity returned by EntityFieldQuery

It can't - an EntityFieldQuery will only ever load the entity ID, and the bundle keys.

There's no choice but to use node_load_multiple() (or the equivalent if using a different entity type).

$nodes = node_load_multiple(array_keys($results['node']));

Bear in mind that the $conditions parameter of node_load_multiple() is deprecated; in favour of EntityFieldQuery as I understand it.

You could theoretically subclass EntityFieldQuery and override the execute() method to return the fully loaded entities - but you'll also need to extend the class so it always knows what entity type it's querying for; otherwise it won't know which key to use in $results.


Bulk import select element options of a Webform from CSV

It's easier to enter the values editing the webform via Source(YAML).

The CSV values can be easily processed into a format such as " 'label': 'value' ".
Then when editing YAML source it's just a list you can Copy & Paste.

For the record, it would end up looking like this (and so on):

select_field:
 '#type': select
 '#title': 'Title'
 '#options':
   'label1': 'value1'
   'label2': 'value2'


A problem in your code is that you are missing

return $data;

You also need to define the base for the table:

$data['attendance_percentage']['table']['base'] = array(
  'title' => t('Attendance'),
);

Should be enough.

Also remember you need to clear cache.


Multisites with shared files folder – good or bad idea?

This should not work. Managed files should be automatically removed once there are no more entries in the file_usage table for them. I see you say that it's not happening on your setup, but maybe that's a permission or some other issue. That's not how it's supposed to work.

I'm curious how you plan on this working, in any case. If you're using file fields, then Sites B and C would have no way to know that you uploaded a file to Site A, so how it is useful? You say that you're using a file manager. Is it like IMCE or something where you are just browsing the files by directory? If you upload a file through something like that, it wouldn't get an entry in the files_managed table, so it would not be automatically deleted. That would make sense.


How to add a tabbed menu on group main page (panel)?

I got a working and straight solution (tabs are panel style) using panels_tabs.

panels_ajax_tab seems more nice (and more clean from a designer point-of-view), but it is also more cumbersome as it only accepts mini-panels as tab elements, and then I'm not sure how to pass the group information down from the main panel to the mini-panel and finally the embedded view panel.

Further panels_tab load all the page at once and then just hide the unused tabs, so if too many views are loaded the page can take pretty much long time to load !


How to programatically update existing user profile field in drupal 7

You just need to load the user using drupal function

profile2_load_by_user($account->uid, $type_name = NULL)

$account->uid => user id

$type_name => one of the profile types of profile 2 if any otherwise NULL

   $profile =  profile2_load_by_user($account, $type_name = NULL)
   $profile->field_headline[$lang][0]['value'] = 'update Software Engg';
   profile2_save($profile);

For more information Click Here

Hope it will work for you!


Display content not updated from specific date

When you create your filter criteria you have an Operator drop down list that will offer the option like Is not equal to or is empty (NULL)

Then you can expose this filter and set the date manually or use an offset from the current date.


Do you have it setup with a multiselect picklist for the floors and locations they can be at? It doesn't sound like there is much of a problem, what are you choosing in the filter that is not working?

The exposed filter works on an AND logic by default so:

Show me
- Anyone at EAST AND on 2ND FLOOR
- Anyone at WEST AND on 2ND FLOOR

The employee will show up when you select EAST AND 2ND, EAST AND 3RD, WEST AND 2ND, but won't if you chose WEST AND 3RD.


Blank row when adding field collection item

At first i thought it was a javascript problem or something like that but as Geoff pointed out it was a permissions problem:

The permissions on the field collection itself were public, the permissions on the fields inside allowed anonymous users to edit existing items but not create new values for those fields so that gave me an empty form when creating a new item of that field collection.


Drupal 7 webform module is not sending email properly

I found the solution for the problem, it's really easy by the way. I hope this is helpfull for somebody else.

What we need is go to:

admin/config/system/mailsystem

Then press "New Setting" link, select "Webform" in the combobox, leave the "key" field empty and save configurations.

Then a new option is enable as shown in the image:

Then we only need to select the right class for Webform module and save.

That's all, i think this should work for other modules too.


Secure pages and installing new modules (AJAX error)

I got this same error, but the cause was unrelated to secure pages, so it may not apply to your case.  Mine resulted from upgrading to Drupal 7.3 and having uncommented the two lines in the .htaccess file "To redirect all users to access the site WITHOUT the 'www.' prefix." When I commented those two lines, my module installer started working again.  So if you have those two lines in .htaccess uncommented, try commenting them out and see if that makes a difference.


The only way to do this is using field access (hook_entity_field_access()) and denying view access to fields that you don't want to be visible.

The primary use case that the default rest.module/entity integration aims to support is data synchronization. My standard suggestion for anyone who wants to offer public services on a site or build a custom frontend is to consider writing and defining services tailored for that specific use case.

It's also quite possible that more flexible solutions will be developed in contrib, one of those is relaxed, I don't know if it helps with this specific use case, though.


Earliest point in page load to issue a redirect?

You should create an EventSubscriber! This post gives a pretty good code example.

I'm doing exactly this and I had some issues when the media's file changes, the redirect will be cached and still point to the old file. To get around this I use the page_cache_kill_switch service which you can inject into your subscriber or just call like:

\Drupal::service('page_cache_kill_switch')->trigger();

One other note is that you'll want to make sure you only fire the redirect when the route \Drupal::routeMatch()->getRouteName() == 'entity.media.canonical'. This will make sure you only redirect when trying to view the entity vs edit or etc.


global webform submissions admin page per user

You literally read my mind because I just added this feature to latest dev release of the Webform module for Drupal 8

@see Users can view all their submissions across all webform instances.


Entity Validator failing Integer for not being integer

You can add constraints to entities, fields or properties. You get then an entity, field object (FieldItemList) or a value to validate. So if you want to check the field value use FieldConfigInterface::addPropertyConstraints:

->addPropertyConstraints('value', ['Range'=> ['min' => 0]])


How to get the highest value of a specific field in a multivalue field collection

Try the Computed Field module

Computed Field is a very powerful field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of fields. So start cooking up your PHP based values!


How to change path of file from absolute to relative?

Install any one of the below modules.

Pathlogic
Portable path


How can I integrate the job news API into my site to access data through the API?

With Feeds module you can import data from other sources to your Drupal installation. I would create a new content type for the jobs, and import the data with Feeds module into this newly created content type.


Views remove link to content based on publication status

With Views's support for Twig, you can now implement conditional hyperlinking without any hook modification to your view.

Add a Content: Path field to your view with Exclude from display checked.
Add a Content: Publishing status field to your view with Exclude from display checked, using the True/False Output format.
Add a Image (field_my_image_field:target_id) relationship to your view that targets your specific image.
Add a File: URI field to your view with the Exclude from display checked, using the File URI as the Formatter, and the Display the file download URI checked.
Finally, add a Global: Custom field with custom Twig that can check the publishing status value for displaying the link and use the excluded fields as replacement patterns.

For example:

{% if status == 'True' %}

{% else %}

{% endif %}


Rotor banner, Toggle the display of an image banner and rotor banner view based on view results

You can display the image field of the node if the rotator banner is empty by outputting that field into the Empty Text field of the view that you are displaying. So you would only need the view's block in the region that you have both blocks currently. Make sure you have PHP input enabled in your empty text.

If the banner content is exclusive to that node's page, you can add a Node Reference CCK to the banner content type and tie the nid argument in views the the node reference field by adding that node reference field as a relationship in your view.


I was able to make it work by doing a vigorous edit of the original migrate script, removing all the fields and their mappings, except for the key. Adding the new field, allowed me to rerun the migrate script and the new field was imported while leaving the other content intact. I am still able to use the rollback and other functions of the script.


Boost module's "Cache every page except the listed pages" option

I know this question is moldy old bread, but I wanted to answer for future searchers.

If a page has been cached by boost and then you exclude it, the cache will need to expire or be manually cleared before the exception will be used.

This is probably why you were still seeing the cached page when you added an excluded page.


"Translate" tab does not appear for every content

The "Translate" tab is handled by the Translation module that comes with Drupal; the Internationalization module that handles the translation for nodes just overrides the page callback for that tab.

function i18n_node_menu_alter(&$items) {
  if (isset($items['node/%node/translate'])) {
    $items['node/%node/translate']['page callback'] = 'i18n_node_translation_overview';
    $items['node/%node/translate']['file'] = 'i18n_node.pages.inc';
    $items['node/%node/translate']['module'] = 'i18n_node';
  }
  // Take over node/add pages for string translation
  $items['node/add']['page callback'] =  'i18n_node_add_page';
  $items['node/add']['file'] = 'i18n_node.pages.inc';
  $items['node/add']['file path'] = drupal_get_path('module', 'i18n_node');
  // @TODO avoid iterating over every router path.
  foreach (node_type_get_types() as $type) {
    $path = 'node/add/' . str_replace('_', '-', $type->type);
    if (isset($items[$path])) {
      $items[$path]['title callback'] = 'i18n_node_type_name';
      $items[$path]['title arguments'] = array($type->type, $type->name);
    }
  }
}

In order to have that tab visible for a node, the multilingual support for the content type must be set to Enabled, with translation.

In Drupal 8, that is done in admin/structure/types/manage/<content type ID>, but the option is titled Enable translation.

In Drupal 7, that is done in admin/structure/types/manage/<content type ID>.

In Drupal 6, it is done in admin/content/node-type/<content type ID>.


Field type "date" is not in the list of available field types

You need to install the date module:

http://drupal.org/project/date

Then enable the date module and that will give you the option to add a date field to your content type. Depending on your case you might want to check also the popup calendar module that is part of the date module to ease the date input.


How to add "rel" attributes to all external links throughout the website?

By implementing hook_link_alter in either a custom module or your theme.
The code (untested) would be similar to:
/**
 * Implements hook_link_alter().
 */
function MODULE/THEME_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}


How to use simple modal jquery plugin to get a dialog of table?

Here is snippet which can be helpful for you to add open the link in simple modal plugin

// Get the click action on link
$('.abc-modal').click(function() {

// Get href attribute.
  var href = jQuery(this).attr('href');

 /*  Three things here
 1. Append a div to the pop-up body
 2. Keep it hidden.
 3. load the content on the link to the div(#content is the id from where you want to load the content to the pop-up) */

      $('

').hide().appendTo('body').load(href+' #content', function(){
        }).modal({
        overlayClose: true,
        autoResize: true,
        minHeight: 600,
        minWidth:800 ,
        opacity:80,
        overlayCss: {
          backgroundColor:"black"
        }
      });
      return false;
    });


Pages with embedded views - a good aproximation?

You better use Panles Module to display everything in a single page and It allows you create complex layouts

  The Panels module allows a site administrator to create customized
  layouts for multiple uses. At its core it is a drag and drop content
  manager that lets you visually design a layout and place content
  within that layout. Integration with other systems allows you to
  create nodes that use this, landing pages that use this, and even
  override system pages such as taxonomy and the node page so that you
  can customize the layout of your site with very fine grained
  permissions.


How can I create a view page that takes taxonomy machine name and has depth?

You can use the contextual filter Content: Has taxonomy term ID (with depth) without adding a Relationship.  Use this settings for the contextual filter:

When the filter value is NOT available: Provide default value
Type: Taxonomy Term ID from URL
Make sure Load default filter from term page is checked.

Please note: When you visit a pathauto destination path, in this case with a source of /taxonomy/term/% pointing at /vocabulary_name/term_name, drupal passes the source path as a query variable, and your view still uses the source path to gather information.  This means your path in the view should not change, it should stay as taxonomy/term/%


If you want to import Taxonomy with Hierarchy along with the existing tid then follow the following.
Configure your import configuration some thing like this

id: taxonomy_migration
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
 - CSV
migration_group: null
label: 'Taxonomy migration from CSV'
source:
  plugin: csv
  path: test.csv //path of file
  header_row_count: 1
  keys:
    - tid //unique key which is used for mapping while importing other content related with this taxonomy
process:
  parent: //this is for your parent term id
    plugin: migration_lookup
    migration: taxonomy_migration //this is the current migration id which will help you to make parent child on taxonomy
    source: pid //parent id source from your csv file
  name: term
  tid: tid
destination:
  plugin: 'entity:taxonomy_term'
  default_bundle: test_taxonomy //your vocabulary machine name where you want to import
migration_dependencies: null
migration_dependencies: null

now your csv file will be like this

now you can check your taxonomy, result will be like in the image below with existing tid.


explicit "switch to mobile theme" link with Theme Key

One way would be to nest each theme switching rule inside another rule using

system:cookie = theme=theme1

     Theme switching rule here

system:cookie = theme=theme2

     Another theme switching rule here

You will need to set up your theme switching links to create a cookie using your method of choice, PHP or jquery.cookie

An example using jquery.cookie could be something like:

template.php:

function THEMENAME_preprocess_page(&$vars) {
  drupal_add_library('system', 'jquery.cookie');
}

Your theme switching links:

Switch to Theme1
Switch to Theme2

Keep in mind that this is not page caching friendly.  If you want this to work for anonymous users, you will need to disable page caching.


Should work fine as long as your module name is "projects"

Did you clear all the site caches after adding the code. Drupal won't detect and start using that hook until you have