How to add classes to menu items in navigation twig template

There are two ways to add attributes to the <a> tag of a link, in the options of the url object or in #attributes of a link render element.

As I don't know how you can achieve the first in twig and to avoid an extra preprocess hook to do this in php, here is how you can replace the link function with a link render element in twig:

{% for item in items %}
  <li{{ item.attributes }}>

    {% set link = {
      '#type':       'link',
      '#url':        item.url,
      '#title':      item.title,
      '#attributes': { class: ['link-class1', 'link-class2'] },
    } %}

    {{ link }}

    {% if item.below %}
      {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
    {% endif %}

  </li>
{% endfor %}

Edit:

I just found out, that in contrast to the php function l() the twig function link() does provide a 3rd parameter to add attributes, so this is a much easier solution:

{% for item in items %}
  <li{{ item.attributes }}>

    {{ link(item.title, item.url, { class: ['link-class1', 'link-class2'] }) }}

    {% if item.below %}
      {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
    {% endif %}

  </li>
{% endfor %}


Undefined index: und on search-result.tpl.php for Taxonomy Terms

It's either that your field has a set language (not 'und' which stands as 'undefined') or that you have no value for field_my_taxonomy_term.

Either way you should add this control before your foreach (I also rewrite it to fit Drupal best practices) :

<td class="field-item">
  <?php $str = ''; ?>
  <?php if (isset($result['node']->field_my_taxonomy_term[LANGUAGE_NONE]) && $result['node']->field_my_taxonomy_term[LANGUAGE_NONE]): ?>
    <?php foreach ($result['node']->field_my_taxonomy_term[LANGUAGE_NONE] as $obj): ?>
      <?php $str .= l($obj['taxonomy_term']->name, 'taxonomy/term/' . $obj['tid']) . ',&nbsp;'; ?>
    <?php endforeach ?>
    <?php print trim($str, ',&nbsp;'); ?>
  <?php endif ?>
</td>


How can I PUT a new file to a node using services 3 without overwriting the existing file?

Background

Services uses drupal_execute() with the node form to save updates to nodes, which won't entirely merge updates in with existing data.

If the update doesn't set a field at all, then it won't overwrite what's there, so in a sense it does merge data in that case. For instance, in your example, you don't set "title" in your update, and therefore it won't overwrite that field.

However, if you set a field, it will overwrite whatever was there previously. So, in your example, since you are setting "field_dl_file", it will overwrite whatever was previously there with whatever you set now. As you saw, this causes any existing files to be overwritten.

Solution

Probably the best solution (and I assume the one intended by the Services team) is to load the previous value of the "field_dl_file" in your script (via a retrieve call to the REST interface), then call the update with both the new value as well as the old value. In other words, merge the old data in with the new data on the client side (inside the script that interacts with the REST interface).

Another possible solution is to manually merge your "field_dl_file" field with existing values inside node_resource.inc (line 365 or so). I assume the Services team never intended this, and it would require changing the module directly (since there aren't any hooks there), so I can't really recommend it. It would, however, ease the work needed in the client-side script, which could be a benefit depending on your implementation.

Note: I referenced Drupal 6 code, though I'm fairly sure it applies to Drupal 7 as well (that part of Services 3 didn't change as far as I know).


Taxonomy term view - show node fields in the view?

Right above "Fields" that you can't change is "Format".  It's set to "Show: Content" by default.  Change that to "Show: Fields".


Theme the “save” button in a profile page, on a Drupal 6 installation?

Found it! I thought I would post it here just in case anyone wonders the same...
HOOK_FORM_ALTER!

Yay, it was sooo easy with that. With hook_form_alter you can add a prefix and a suffix with the css classes, and that´s it.

This video podcast of mustardseedmedia helped me A LOT.

Cheers,

Rosamunda


How do we pass php code as a twig variable in global custom text field of views

To place PHP code in a field extend a field plugin and override render(). But in your case you should get the result of this code from the existing EntityLink plugin (in UI "Link to Content") and the option output_url_as_text. If you want to use it as Twig variable in another field, hide the entity link field from display and place it in front of the other field.


Panels page variant that targets a single node

Assuming you already have the node override Panel enabled:

Edit the panel page for the node override (node_view for node/%node)
Make a new variant, enable selection rules
For the selection rule, choose String: Url Path
In the criteria, keep Allow access on the following pages selected
In the textarea, add the internal node paths for this nid(s) you want.  To target nid 1234, use

node/1234
Configure the test of the panel as needed.

Just make sure this comes before any less-specific rules, like matches on content type.


How can I read config schema from a config entity?

Found, it can be done by using config.typed service:

$typed_config_manager = \Drupal::service('config.typed');
$node_type_definition = $typed_config_manager->getDefinition('node.type.*');


The most efficient way to query the user table and custom profile info based on UID

There are a few ways your query can be improved. First, there were some multiple queries for the user's id which I removed. Second, your query was selecting from the node table and then inner joining with the users table which can cause some undesired results (e.g. only users who have created content on your site will show up) and it is also less performant.

Here's the improved query. Since all profile values are stored within the same table using a 'fid' field id to differentiate them one has to do an inner join for each value that you want to select. Hence the query has to be a little longer than one would hope.

  SELECT profile_values_firstname.value AS profile_values_firstname_value, profile_values_surname.value AS profile_values_surname_value, profile_values_telnumber.value AS profile_values_telnumber_value, users.mail AS users_mail, users.uid AS users_uid, users.access AS users_access, users.name AS users_name FROM users users LEFT JOIN profile_values profile_values_firstname ON users.uid = profile_values_firstname.uid AND profile_values_firstname.fid = '1' LEFT JOIN profile_values profile_values_surname ON users.uid = profile_values_surname.uid AND profile_values_surname.fid = '2' LEFT JOIN profile_values profile_values_telnumber ON users.uid = profile_values_telnumber.uid AND profile_values_telnumber.fid = '3'


Using drush to install multiple sites, how?

If you want to use 1 DB for multiple sites you should get https://www.drupal.org/project/domain. I haven't tried it yet, looks complicated to set up, so good luck =)

For pointing your site, this video might help, skip to 15:49 http://www.youtube.com/watch?v=Ea_Tqd-NrC4 It doesn't cover diff root directories for diff domains tho.


hook_node_load() is exactly what you're looking for

Act on arbitrary nodes being loaded from the database.
This hook should be used to add information that is not in the node or node revisions table, not to replace information that is in these tables (which could interfere with the entity cache). For performance reasons, information for all available nodes should be loaded in a single query where possible.

The code example from the docs page is actually very good for your use case so I'll include it here too:
function hook_node_load($nodes, $types) {
  // Decide whether any of $types are relevant to our purposes.
  if (count(array_intersect($types_we_want_to_process, $types))) {
    // Gather our extra data for each of these nodes.
    $result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));
    // Add our extra data to the node objects.
    foreach ($result as $record) {
      $nodes[$record->nid]->foo = $record->foo;
    }
  }
}


How can I draw a donut chart based on the number of specific fields on a form?

Yes it's possible to create such charts (which are called Donut Charts) similar to the sample in the Interactive Google Charts gallery (move your mouse pointer over any of the slices in that sample to see the special effects it comes with also). Such Donut chart is actually a Pie chart with a hole in the center, which can be created with the pieHole option.

Below are some more details to get you going ...

Option 1 (without using WebForm):

Use the Comparison of charting modules for potential alternatives to consider.

Some of the modules mentioned there:

Charts, which can be used to Create charts using Views ... as in these Charts previews and/or its demo site. The D7 version of it comes with a choice between 2 supported charting libraries to select from.
Chart, which can be used to Create charts using Views ... as in these Chart previews. It requires the (deprecated) Google Image Charts, and is expected to be upgraded in the near future to use another charting engine. Charting engines being considered are either of these JS libraries:

The JIT (Javascript InfoVis Toolkit).
The d3.js library.

Option 2 (Using WebForm):

There are actually 2 alternatives to pick from:

Webform Charts (used in about 400 sites), to display Webform results in a graphical manner using a charting library.
Webform Chart (used in about 220 sites), which integrates with the "Analysis" tab of a Webform (created with the Webform module) to provide charts for each individual component's analytical data.

The Drupal 7 version of both modules, use the Charts module to actually create the charts (module dependency).

Remarks

The license that comes with the charting library (engine) that is used in the selected Charting module, should be considered also. Some of the typical items to consider are:

Possible privacy concerns.
Flash based libraries (as they were also used in the D6 version of Charts) should be avoided if charts are to be displayed on mobile devices.
Google libraries require a working internet connection (not always available in local DEV environments ...).
Not all libraries are free of charge (some come with commercial licenses).

Disclosure: I'm a (co-) maintainer of Charts and Chart, and the author of that Comparison.


Tracking an authenticated user's first visit to a Panels page and forward them to another page on subsequent visits

You want an access plugin. See What are Ctools plugin (content type, access, etc), and how does one create them? for an intro to how to build one.


Views & custom exposed filters : where do I start?

I guess the best place to start is to look at the way some other module is doing it. Or how views itself does it for some core module :) (i.e. taxonomy or user.
There is at least 3 things you have to do :

tell views you have something for it
provide it :)
tell drupal to load it

the telling can be done by implementing :

hook_views_data in case you define an entire field, or
hook_field_views_data_views_data_alter (no doc if i get it right) if you want to change someone elses field filtering

create a directory views, place a file called your_module.views.inc in it and put the hooks there.

then create a file with a class that will extend the filter

and include that file in the modules info file

dont forget to refresh cache and that should be it :)


How do I add a  after every field element on the node edit form?

The easiest way is using hook_form_alter for each Field add #suffix => '

" to the existing FAPI array for the Field. I would just hard code it per field.

If you need to you could make a for loop and walk through the FIELDs so you dont hardcode the fields by hand ... If you were more crazy you could use an #after_build function too on the $form or set 1 per Field element as needed if you run into problems.


Can I suppress PHP error messages for authenticated users, BUT display all of them for an admin?

I haven't tested this but I would think you could turn that setting off completely, and enable it again yourself in a custom module:

function MYMODULE_init() {
  if (user_access('a permission only admins have')) {
    error_reporting(E_ALL);
  }
}

Update

Per your comments, it looks like this way doesn't work, but what does work is to do exactly the reverse of the above. That is, to set the error reporting to "All messages" in the UI, and then use hook_init() to surpress the unwanted levels of error message.

I would say your suspicions are correct, that Drupal is handling the errors at a lower level and so turning them off all together stops calling error_reporting() in hook_init() from having any effect.


How do I make block only visible if the 'field_date_value' is in the past?

Pretend you need a block to be visible on a node depending on the value of a date field on the node.

A good example is a website that lists classes as nodes. You want a block visible only on class nodes. You also only want that block visible if the date of the class is in the future.

The classes are created by making nodes of a custom content type called "class". Each class node contains an date field called "class_date" that contains the date of the first day of the class. The date field is a regular ISO date field type. This PHP snippet returns TRUE if the node is a "class" and the "class_date" field is in the future and the block is then visible.

<?php
$node = menu_get_object();
if ( !empty($node)  && $node->type == 'class' ) {
  if ( !empty($node->field_class_date) && !empty($node->field_class_date['und']) && !empty($node->field_class_date['und'][0]) ) {
     $parts = explode('T', $node->field_class_date['und'][0]['value']);
     $date_parts =  explode('-', $parts[0]);
     $class_date = $date_parts[1] . '/' . $date_parts[2] . '/' . $date_parts[0] . ' ' .  $parts[1];
     $on = strtotime($class_date);
     $now = time();
     if ( $on >= $now ) {
        return TRUE;
     }
  }
}
return FALSE;
?>


Have you looked at the Search API pages module. It uses the Search API module and creates a custom search page. You could probably look at that module for clues on how to implement what you are trying to do. The module itself might even provide a lot of the functionality that you are looking for.


As far as I know, this functionality doesn't exist yet (up to Drupal 7).

A feature request is already created at https://drupal.org/node/474684 (for Drupal 8).


Create a view that links to another view

Suppose the name of views are view1 and view2 as content pane.You have to link view2 to view1.

For linking one view to another you would have to follow some simple steps:

In view2 you have an option under PANE SETTINGS 'Link to view' and select Yes.
In view1 also you have an option under PANE SETTINGS 'Link to view' and select Yes.
Now decide the place where you want to display view2.
Suppose its the footer region. Go to the footer region and add a Global:View area.
There you have a list of all views. Select view2 and save the view.

This way you can let one view execute under another view.


I think the Ubercart funds module that is the best answer for your question; the module still has a development snapshot only, though.

This will make you able to transfer funds through your drupal sites to different users.

  Ubercart Funds implements a Site Funds Management System using Ubercart, It integrates features like Deposit Funds, Withdraw Funds, Transfer Funds..etc, which makes implementing most features of a Money site like Paypal or Skrill possible and easy using Drupal.


EntityMalformedException: Missing bundle property on entity of type taxonomy_term

there seems to be an error in

  entity_extract_ids()

in some circumstances the entity info for taxonomy term is wrong ..
(probably with entity translation in my case)

function entity_extract_ids($entity_type, $entity) {
  $info = entity_get_info($entity_type);

  // Objects being created might not have id/vid yet.
  $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
  $vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;

  if (!empty($info['entity keys']['bundle'])) {
    // Explicitly fail for malformed entities missing the bundle property.
    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
    }
    $bundle = $entity->{$info['entity keys']['bundle']};
  }
  else {
    // The entity type provides no bundle key: assume a single bundle, named
    // after the entity type.
    $bundle = $entity_type;
  }

  return array($id, $vid, $bundle);
}

this is 1:1 the code (not patched ..), that needs changes. from common.inc

see here for patches: https://www.drupal.org/node/1270340#comment-9890989

when using EntityFieldQuery and fe. node_load_multiple make sure to pass fully loaded entites !
use node_load_multiple and pass that result.


Admin permissions wiped out after git branching

I was able to determine that rows strangely went missing from the roles table (in particular admin roles) upon creating a new git branch. I have not tracked down why this happens, but I suspect that something in either one of the features or custom modules is causing this to happen.


How do I delete files using the Content > Files interface?

There are a couple of approaches; if you'd rather manage the deletion a bit more tightly, you can use the API to get a list of node (and/or other "thing") IDs that reference a particular file:

$usage = \Drupal::service('file.usage')
  ->listUsage(\Drupal\file\Entity\File::load($fid));

Then you can edit the node/etc, find the offending reference (in your example it looks like that would be within a paragraph of a previous revision), and remove it.

If you just want an interface for deleting files, there's the fledgling Delete Files module. It will even degrade gracefully for deleted files that are still referenced:

  If a file you've deleted is managed by Drupal, this module replaces it with a new empty file to head off potential problems with dangling file references.


I'm not sure what exactly you want to achieve. Maybe this two modules are helpfull for you:

Dependent fields
Conditional fields


How to show fields in the Inline Entity Form display widget?

Use hook_inline_entity_form_table_fields_alter() this is what I am using on a current site:

function MY_MODULE_inline_entity_form_table_fields_alter(&$fields, $context) {
  //Determine the bundle and entity type from $context

  unset($fields['id']); //<get rid of the id field

  //add any fields you need to the $fields array
  $fields['FIELD_NAME'] = array(
    'type' => 'field',
    'label' => t('FIELD'),
    'weight' => 2
  );

}


Reference dialog hyperlink configuration

AFAIK, References Dialog only add links for add/edit/search.

If it's the display of a referenced node that you want to change, just change the field's format (under Manage Display) to "Title, as link".


Why is my $node always null in my custom block (using plugin contexts)?

Thanks everyone - turns out the answer was deceptively simple - I had to remove the block using context & then re-add it. When I re-added it there was an extra option in context to use the current node. Then the context plugin worked!


Use field_create_field() to create the field itself and field_create_instance() to have an instance for the given entity bundle.

When creating fields as part of a custom module, you may or may not want to delete the field when the module is uninstalled.  To do so, you can use field_delete_field() if you want to delete the field and all field instance, or if you want to delete specific instances you can use field_delete_instance().


1. Go to Administration > Content > Feeds (http://www.example.com/admin/content/feed)

  2. Add a Feed (http://www.example.com/feed/add).

  source: https://www.drupal.org/node/2604358#comment-10865318


Is it possible to get client ip in setting.php

In settings.php the drupal kernel is not loaded yet, so the service container is not initialized. Use the php superglobal $_SERVERinstead:

$client_ip = $_SERVER['REMOTE_ADDR'];


View calc and multiple field collection lines

Finally, I found a way to make it work. Although, maybe it's not a good solution but it worked.
Here is steps:

Find file views_calc_table.inc in views_calc module directory.
Change if ($query_alias == 'unknown') { to if ($query_alias ==
'unknown' || $field->field_info['type'] == 'field_collection') { in
line 238 under function add_aggregation_fields(&$view)

Remind，never hack core!


Field that links to a path/url defined with Tokens, is it possible?

The Link field module DOES support tokens in Drupal 7, both in the link title and the link url field. You might be confused by the fact that the token drop down menu is at the top of the link edit form so it looks like it's not for the url field at the bottom of the page. I was confused by this before myself. Also make sure you have the right input field focused on first before you start clicking to add tokens.


Adding a new NOT NULL field to a table causes an error

If the field spec sets 'not null' => TRUE but does not define a default value, the column is created allowing null values and later altered to disallow them (see the mysql driver Schema::addField(), and the $fixnull variable).  The second query attempting add the restriction fails, causing the error.

To fix the error, either

An 'initial' value needs to be added to the spec provided to addField()

Drupal::database()->schema()->addField(
  'MYMODULE_table',
  'created',
  [
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'initial' => 0,
  ]
)

Or a 'default' value needs to be added to the spec provided to addField().
When providing a default value, the spec in hook_schema() should also be changed to match.


There is a good article by Lullabot that covers this: Hiding content from Drupal's search system.


Please see http://drupal.org/coding-standards, as it is hard to read.

However that said, I usually find if ajax is only working once then as the element is replaced Drupal gives it a unique id which then breaks a selector. For example #form after the ajax request becomes #form-1 and is no longer targeted. -check for this in firebug


How to edit/extend/remove pager in the admin back-end?

Views Bulk Operations was written to handle such situations:

  This module augments Views by allowing bulk operations to be executed on the displayed rows. It does so by showing a checkbox in front of each node, and adding a select box containing operations that can be applied. Drupal Core or Rules actions can be used.

You can build a View to filter users by whatever criteria makes sense, and use VBO to delete them all (not just those on the current page) in one go.


To make sure I completely understand your question, I am going to restate it:

User B has created a node from a custom content type and it is assigned to Section One via Workbench Access. User A, who is also assigned to Section One, needs to edit User B's node but is currently unable to.

You're right in that you need to give people in that role the permission to "Edit Any Content" for that custom Content Type. You can access the permission page at admin/people/permissions, scroll to the "Node" section, find the specific content type in the list and select the proper permissions.

I don't know about what specifically you're trying to develop but I do have a couple of notes for you if it's still applicable to your situation.

First, you might want to consider adding a second role that only has the power to edit content from content types you designate in the permissions page. Using your example, let's say User B is assigned the role of "Author", meaning he can create content and edit/delete his own content. User A is assigned the role of "Editor", meaning she can edit any content User B has created but she cannot create her own. If User A needs access to edit content as well as to  create content, you can assign User A to both the "Author" role and the "Editor" role. This means that User B will not be able to edit any content generated from the content type except for his own (if he has the correct permission set for that).

Second, I would recommend taking some time to review the documentation for Workbench Access for more information on configuration and permissions.


Multiple blogs per user, each with a blog profile page

In the end, I decided it was easier to do this with node references and let the user choose a parent from the "add blog post" screen.


If all you're using the wysiwyg editor is for ckeditor, you can use the ckeditor module instead.

  This module will allow Drupal to replace textarea fields with the
  CKEditor - a visual HTML editor, usually called a WYSIWYG editor. This
  HTML text editor brings many of the powerful WYSIWYG editing functions
  of known desktop editors like Word to the web. It's very fast and
  doesn't require any kind of installation on the client computer.

you can tell ckeditor to use the CDN in the Advanced settings of the Global Profile:


Insert the next recurring charge date in custom table when user purchase a product?

I have done something similar although I don't think it's the best way.

I created a rule that is triggered with the event I wanted and then added an action which was custom php. Then use drupal db api to make the update or insert in the table.

https://drupal.org/project/rules
https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_query/7


Since Drupal 7, Field API is in core so you don't have to worry about Fields when editing a node form. In Drupal 6, you have to add an #after_build function to do this.

You need to create a hook_form_alter function to alter the user_register_form. (or hook_form_FORM_ID_alter).

I can't remember the structure of form fields. Install devel module and you can see the entire $form array nicely.

 <?php
    function mymodule_form_user_register_form_alter(&$form, &$form_state) {
      dpm($form); // Make sure you have Devel module installed.
      $field_name = 'field_myfield';
      $value = $_GET['somekey']; // populate this var from the URL params as you mentioned in your question.

      if (isset($form[$field_name][LANGUAGE_NONE][0])) {
        if (empty($value)) {
          $form['#access'] = FALSE;
          drupal_set_message(t('Please use correct URL'), 'warning'); // in case the value is not set, hide the form and issue a warning.
          return;
        }
        // #options is an array like this: array('key' => 'value', 'key2' => 'value2');
        // Make sure you set the key of this array in $value. if your $value is a value, you'll need to array_flip and find the key instead.
        $form[$field_name][LANGUAGE_NONE][0]['#type'] = 'value'; // this element will not be rendered at all
        $form[$field_name][LANGUAGE_NONE][0]['#value'] = $value; // this value will be passed to $form_state['values']
      }
    }

Calling the form using drupal_get_form DOES fire all form_alters as necessary.
If you are trying to use this form with a direct menu router, set page callback in the menu router item to drupal_get_form and
array('user_register_form'), as the page arguments


Separate classes in include file not loading?

The files listed in files[] do get autoloaded, but Drupal's registry needs to "find about" about them first. The .info files aren't parsed & processed on every page load, but rather only during specific system operations. Go to the /admin/config/development/performance page on your site and clear the cache - this will rebuild the registry and your files should then get loaded as necessary.


I found a way to solve that:

// Load user who will take the quiz
$account = user_load($quiz_taker_uid);
// Load quiz and question nodes
$quiz = node_load($quiz_nid);
$question = node_load($question_nid);
// Create a new result id
db_query("INSERT INTO {quiz_node_results} (nid, vid, uid, time_start) VALUES (%d, %d, %d, %d)", $quiz->nid, $quiz->vid, $account->uid, time());
$rid = db_last_insert_id('quiz_node_results', 'result_id');
// Submit the answer
$result = quiz_question_evaluate_question($question, $rid, $long_answer_text);
quiz_store_question_result($quiz, $result, array('set_msg' => FALSE));
// Finish the scoring and properly invoke hooks
$score = quiz_end_scoring($quiz, $rid);
quiz_end_actions($quiz, $rid, $score);


Drupal 7 node reference field formatter for nid

having trouble creating the patch, here is what I did, added

'node_reference_nid' => array(
  'label'       => t('Nid'),
  'description' => t('Display the nid of the referenced node.'),
  'field types' => array('node_reference'),
),

to the node_reference_field_formatter_info() function also added

  case 'node_reference_nid':
  foreach ($items as $delta => $item) {
    if ($item['access']) {
      $node = $item['node'];
      $result[$delta] = array(
          '#markup' => check_plain($node->nid),
       );
      if (!$node->status) {
        $result[$delta]['#prefix'] = '';
        $result[$delta]['#suffix'] = '';
      }
    }
  }
  break;

to the node_reference_field_formatter_view() function

that's it, hope it helps


Almost all Drupal forms can be edited using hook_form_alter(), specifying the form using its id:

Hide "Make title a link" for all fieldable panels panes:

/**
 * Implements hook_form_alter().
 *
 * Simplify form for fpp.
 */
function your_module_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == 'fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form') {
    $form['link']['#access'] = FALSE;
  }
}

Hide "Make title a link" for all fieldable panels panes of the type "your_bundle":

/**
 * Implements hook_form_alter().
 *
 * Simplify form for 'your_bundle' fpp.
 */
function your_module_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == 'fieldable_panels_panes_fieldable_panels_pane_content_type_edit_form') {
    if ($form['#bundle'] == 'your_bundle') {
      $form['link']['#access'] = FALSE;
    }
  }
}


If you want an array of strings maybe your should use a blob in you schema:

 'question_option' => [
          'type' => 'blob',
          'size' => 'big',
          'not null' => TRUE,
          'serialize' => TRUE
        ],

Note that by default 'size' = 'normal' which max storage value is 16KB so if it is enough for you use 'big'; 'big' can handle up to 4GB.
And for properties as follow:

$properties['question_options'] = MapDataDefinition::create()->setLabel(t('Options'))


Better you can go with implementing the field with "imagefield_crop" module instead of doing customization further.


How to clear a field using jquery after Ajax form reload

Try this, it should work. Instead of $(document).on you can also use any outer static element.

$(document).on('change', '#foo--2', function(){
    alert ('change detected');
    'input#bar-datepicker-popup-1'.val('');
});


How do I disable digest subscription notices for all users?

I'm not sure you'll really be able to force everyone out of getting Digests, but if you look in

/admin/config/system/subscriptions/userdefaults

In the Settings Fieldset, above Type of links to send field, there's a checkbox for Digest mode. If that's checked, it may be causing you problems.
I'm looking at this in D7.

My main thought is that user preferences for a digest may override the defaults you've set up, so I'm not sure you'll really be able to completely shut down this feature. I'm also not sure why you'd want to. Getting pinged about a new comment every time it happens can overwhelm someone's inbox if even a moderate conversation is going on. My team likes giving a digest every 3 hours as the default because it will give users about 2 updates a day, but won't overwhelm them unless they change the settings themselves.


Rule with if statement prevents users from saving their user account

As an observation I would advise against using PHP directly in a rule if it can be avoided. Much better to put your logic into a custom action and call it.

But looking at the code you supply, you should note that the user account referred to in the rule and the global current one need not be the same (an administrator may edit someone's profile, for example). You should be using the account passed in to the rule throughout, not site:current-user. Also the user update condition, IIRC, may be called when a user object is saved in other circumstances than a profile edit, so the redirect won't be appropriate.

So in order to be sure the user is editing their own profile, you should add a condition to the rule which compares the account's uid to that of the current user to make sure they are the same.


Just incase someone stumbles upon this, Martin's solve above breaks URL fragments as it overrides the URL options completely. The better approach is here:

{{ link(item.title, item.url.setOption('attributes', {'class' : 'main-nav__link'})) }}


Updating core to a specific version with Composer

I was in the same position. I used :

composer require drupal/core:^8.5.10

And it worked. Cheers.


Using the Profile2 module, how to access contextual information to place a views block on profile page?

Using the View Default Argument From Context Module I added this code to it.

function views_arg_context_profile2_view($entity, $view_mode, $langcode) {
  context_set('user', 'uid', $entity->uid);
  context_set('profile', 'pid', $entity->pid);
}

Now there is an option in Views Default Argument to pull the ID from context and I place either user or profile in the appropriate text field and it works fine.


In a preprocess hook (preferred):

/**
 * Implements hook_preprocess_HOOK() for page.html.twig.
 */
function MYTHEME_preprocess_page(&$variables) {
  if (isset($variables['node'])) {
    $variables['image'] = $variables['node']->get('field_image')->first()->view('full');
  }
}

Or in Twig:

{{ node.field_image.0|view('full') }}

To use |view install the module https://www.drupal.org/project/twig_tweak


Display Suite vs. EVA for displaying a view as field

I think the best contender for EVA is Views Reference Field:

EVA: Entity Views Attachment
Views Reference Field

Both have stable releases. Main difference is the workflow. EVA is perfect if you want to impress your co-workers with the ability to attach a View to a content type like magic. Views Reference Field gives content editors the power to add Views to content themselves. Both modules don't need a block display, EVA provides its own and Views Reference Field can use any display type.


Drupal 7.36 configuration error: Call to undefined function field_attach_load()

It looks like this issue has cropped up because of a myriad of potential causes, and some have been fixed while others have not.
The first step, assuming this is an installation from scratch, would be to empty your database and try again.  I've had the initial install go wrong once and just trying again went fine.
There is an extensive list of fixes at https://www.drupal.org/node/481758.  In the unlikely case of Drupal's issue queue going away, here is the main text.  I'd recommend going to the link and reading through the (extensive) comments to see if specifics match your situation.

In certain circumstances, the following error (or something similar) may be displayed during the installation process:

Fatal error: Call to undefined function field_attach_load() in ~\modules\user\user.module on line 270

This error seems to be caused by a problem during the Drupal system installation, causes installation to fail after only creating 31 database tables, and will make requests to the front page of the site display a 'Page not found' error. This seems to happen as a result of various different configuration problems, browser issues, etc. Some of the things you should try to change before throwing your hands up in frustration:
7: Make sure you're not reaching the configured max_execution_time for PHP is not being reached.
25: Switch back to the default php.ini, restart Apache, and see if install works.
27: Make sure dependencies[] = field is defined in your install profile's .info file.
34: Using a different browser (e.g. use Chrome instead of Safari) during installation may help.
36: Switching the bundled jQuery to version 1.7.1 might fix the problem, at least for Safari users.
37, 42, 54: Dropping the entire database and installing again might fix the problem.
45, 141: Limiting the database name length to < 8 characters may fix the problem.
57: Make sure the database user Drupal is using has all permissions for the database (GRANT ALL ON [db]).
59: Make sure your browser's cookies are enabled when performing an installation.
61: Restarting php-fpm fixed the problem.
66: Setting the $cookie_domain variable in settings.php fixed the problem.
82: The problem could be related to install.php not loading field.attach.inc at whatever bootstrap level it is running at.
88: Make sure the $base_url variable in settings.php is correct.
92: Ensuring the database name had only lowercase ASCII characters fixed the problem.
108: Make sure your Apache configuration doesn't do anything that might cause cookies to be dropped.
135: If it's an install in an existing Drupal directory, temporarily move all the modules in sites/all/modules out of the Drupal tree while installing.
137: Disable the php opcache module before proceeding with installation As you can see, there are a TON of different things that can cause this issue. The root cause is installation
fails during module installation, and won't ever continue past that point until the database is dropped and recreated again.


Next time I should look into the docs first...

According to node_access(), it doesn't consider the returned value NODE_ACCESS_IGNORE, which I return, if the user doesn't violate my permissions, so that other modules still can deny access, if their permissions might be violated.

So the answer of my question is: I should use drupal_static() to avoid duplicate calculations.


I was just having the same issue.  Using a custom tpl.php for the node seems to fix it.

Cheers,


Is there a Drupal Wiki documentation site?

http://drupal.org/documentation is home to our documentation.  While not usually referred to as a "wiki", most pages are editable by anyone with a drupal.org account.

Also consider connecting with the Documentation Team - there are other users who can help you get started.


You mentioned you tried ctools_automodal which is a quick way to accomplish creating a link in a view to open in a modal. With the module, you can use hook_menu_alter to add 'modal' => TRUE to the link menu router item. Nothing else is involved. Ctools_automodal handles all the rest. That means you don't need your own example_modal_page page callback, and you don't need to call ctools_modal_render. Let the Ctool_automodal module do that for you.

If your path has a wildcard, then ctools_automodal will need an actual wildcard variable defined and a "_load" function. In your example above, your path is selectbook/%. If you change it to "selectbook/%selectbook" and defined a selectbook_load function then ctools_automodal should recognize it as a modal path. Here's an example:

/**
 * Implements hook_menu().
 *
 * The sole item call in hook_menu is driven from a URL that is built
 * from rewrite rules within a view. When activated, it should render
 * the new modal window.
 */
function example_menu() {
  $items['selectbook/%selectbook'] = array(
    'title' => "Perk Modal",
    'page arguments' => array(1),
    'page callback' => 'example_modal_page',
    'access arguments' => array('view content'),
    'modal' => TRUE,
  );

  return $items;
}

function selectbook_load($selectbook) {
  // Todo: Do something with selectbook, like load an entity.
  // For this proof of concept, just return it.
  return $selectbook;
}

function example_modal_page($selectbook) {
  // If you loaded an entity in selectbook_load, then you have that
  // fully loaded entity in $selectbook.
  return "Test Modal";
}


You should consider using Search API module, which can handle Solr and facets, and enables you to use Views to create the search page and has a very good UI for creating search index with facets ect.

I've used it several times and have been pleased with the result.


You don't need to use a hook you need to use the API function user_save(). Which is a very weird function because unlike all other save functions, it has a separate argument for the things that you want to change.

Something like this should work, in your submit callback:

<?php
// Make sure you are working with the fully loaded user object.
$account = user_load($GLOBALS['user']->uid);
$edit['data']['your_stuff'] = $whatever;
user_save($account, $edit);
?>

FYI: user_save() is no more in Drupal 8 and instead behaves like all other entity save functions/methods in 8.x, by calling $account->save() after changing $account. See the following change record for details: http://drupal.org/node/1554986


Any alter hook and preprocess hooks that is defined inside a module can also be defined inside the theme as well. So if you are using Bartik theme you can open the Bartik's template.php file and use

function bartik_form_alter(){}

UPDATE

Checking the Is it possible to define hook functions in template.php instead of the module? can also be helpful.


Wizard for generating a dynamic legal document

For the longer list, you can add a content type (Structure -> Content types) and add checkbox fields for each question, where the text of the question is the value displayed by the checkbox when it is selected (the "On" value). An alternative way would be to add a Checkbox field with multiple values. I suggest this because by default, just the value of the checkbox(es) is shown on the resulting content when you save and view it.

For the list of questions, it depends on how many questions we're talking about. A slightly tedious but straightforward way is to use the Rules module along with another content type that contains the questions.

This installs itself to Configuration -> Workflow -> Rules.

For each question, you add a triggered rule that checks the response and sets the value of the other content type (let's call it Template) to whatever it should be. You could probably do this one with one rule as well. In this case, I'd set the stored values in the database for the Questions type fields such that they match or somehow contain information about the names/values of the fields in the Template content type. It would basically be a mapping of sorts, and the rule could set the value of the Template based on this.

You may also need to store a reference to the Template content corresponding to the set of questions in the Questions type. The easiest way to do this is to install References and add a Node reference field to the Template content type. Then, you can have a rule that creates a new template and associates it with the Questions content when you save a new Questions content item, for example. The other rules would then have some saved content for which to set field values (otherwise, you'd wind up creating new Template content every time or something).

These are some thoughts on this. It's not the most elegant, but it might get you started or at least on the right track.


Sounds like you can just create a URL redirect with Redirect, and send to an external URL. No need to create a node.


"This is a debugging block" on Permissions page

If you are using the Omega theme debugging blocks are always visible to uid=1. Check out this issue.


No body text saved when creating a node with I18n and specific language set

It should be showing 'und' for language neutral nodes. Have you checked the value of the $node->language parameter?

You could also try creating one of these nodes with the user interface. Then install the devel module and use the php executor (whatever.com/devel/php) to load the node and output with dpm() to see the contents of the node. You probably have something wrong with the structure.

Example (after the sample node is created):

$node = node_load(21);
dpm($node);

That will output the node contents for you to help you better explore what you are creating.


You don't. You implement hook_views_default_views() in yourmodule.views_default.inc and place the export there.

See Using default views in your module for a detailed guide.


Add to cart form AJAX not working when loading a product display via AJAX

The reason why it redirects after adding to cart is because the add to cart form doesn't use ajax by default. Wich causes it to redirect the user when submitted.
If you want it to use ajax you'll have to alter the submit button via a
HOOK_form_FORM_ID_alter.

For more info on the form ajax functionality
FAPI ajax

However by doing so you'll alter all the add to cart button forms on your entire website to use ajax.

So a better solution might be to create a custom add to cart form just for the product_quick_buy view-mode and display that instead of the standard form. This form can then use ajax to call it's submit handler.

Also I think your ajax link implementation for the hook_menu doesn't follow the coding standards.

function tweaks_menu() {
  $item['product/get/ajax/%'] = array(
    // -- your code --
    'delivery callback' => 'ajax_deliver', // Tells drupal we'll be returning an ajax renderable array
  );
  return $items;
}

function tweaks_get_product_ajax($nid) {
  $node = node_load($nid, NULL, false);
  $node_view = node_view($node, 'product_quick_buy');
  $html = drupal_render($node_view);
  // Instead of printing we're generating an ajax renderable array and return that
  $commands[] = ajax_command_html('YOUR_JQUERY_SELECTOR_HERE', $html);
  return array('#type' => 'ajax', '#commands' => $commands);
}

More info about ajax links Tutorial on ajax links


Display referenced user's email address instead of username

You are on the good track with solving your problem using Entity Reference Views Display. Once you have that Display type ready, you can edit your Entity reference field to use that Views display.

Your question seems to have two parts, one is displaying user information in Views, and the other is making the Entity reference field use the Entity Reference Views instead of a Select list.

Entity Reference Views in Drupal Core—Needs work

There are efforts to make using Views as Widgets on Entity reference field forms in Drupal Core: View output is not used for entityreference options. You can patch your installation using the patch from that Issue.

Or you can use the already suggested module Entity Reference Views Select until it's all sorted out in core: Similar support to be ported to core. Follow the instructions from the module about how to configure your Entity reference field.

Showing user information in Views

Since your Entity reference field is referencing Users, it makes the most sense to create a View of type User.

Show Users, but don't create a Page or a Block. When you Save the View create a new Display of type Entity Reference.

Add Email and other fields you want to show on the Create node form when selecting users.

Whatever fields you see in this Display, you will see when selecting users on the create/edit node form.


Problem in uploading an image to my drupal site

You check the permissions on the sites/default/files folder. Using linux you could execute sudo chmod -R 755 <foldername> from your terminal.

A good idea could also be to check your log files in order to track down the error. For example if you are running apache you could check the /var/log/apache2/error_log to see what goes wrong.


How to add an image field to a custom fieldtype?

The image field type has no property image, the main property is target_id inherited from the file field type. The easiest way to define a custom image field would be to extend the three core image field classes another time, now in the namespace of your module.

See how ImageItem defines a new compound field by extending FileItem overriding propertyDefinitions() unsetting two properties and adding four new image specific properties.

An alternative solution would be Paragraphs, more overhead (while a compound field stores the data of all fields in one table, Paragraphs needs a table for each field and also for the paragraph entity itself), but it provides unlimited nesting of field types.


How to create a page showing certain roles?

Create a view (using Views module) of users with a grouping by role. You can add a filter for the specific roles that you want to include.


Add Option to Centre Images on Content Pages

With CK Editor Module. Install CK EDITOR Image module, which enables the third alignment option to center the image also.

Here is the link to download the Module. https://www.drupal.org/project/ckeditor_image

Note: CK EditorImage only supports for Drupal 7 and its previous versions.


With the module Draggable Views, you can set up an administrative view to set the order (with the standard drag and drop interface), and then you can create other views that display the contents following that order.
There is a comparison of node/entity ordering modules here
Draggable Views:

DraggableViews makes rows of a view "draggable" which means that they can be rearranged by Drag'n'Drop.
Have you ever rearranged Blocks?, sorted Taxonomy terms? or reordered Menu items at the Drupal administration pages? All these pages use the tabledrag.js javascript that enables Drag'n Drop on HTML-tables.
With DraggableViews you can apply this tabledrag.js to any Views-generated table.
Features:

Order any type of entity.
Set different order for different set of arguments.
Create one view that sets the order, and create as many views as you like that shows that order.
Use core tabledrag.js or jQuery UI draggable javascripts to set the order.


Why is jQuery UI toggle not working in my theme?

jQuery is added by Drupal core and is available globally.

Clear cache at Admin > Config > Performance

Check your script.js has been added to the html source.


How to override jQuery from contrib module

To override the JavaScript file added to a page from a module, you need to implement hook_js_alter(). The example code shown for hook_js_alter() is the code used by the jQuery Update module uses to change the jQuery library used from Drupal.

  // Swap out jQuery to use an updated version of the library.
  $javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';

In your case, if mymodule.module is the module that needs to change the JavaScript file, and the file added is script.js, then the following code can be used to achieve your task.

function mymodule_js_alter(&$javascript) {
  $javascript[drupal_get_path('module', 'editablefields') . '/editablefields.js']['data'] = drupal_get_path('module', 'mymodule') . '/script.js';
}

The same code works for a theme too. The difference is that instead of using drupal_get_path('module', 'mymodule'), the code should use path_to_theme(). *

Using hook_js_alter() would work also for JavaScript settings added by Drupal, external JavaScript files, and inline JavaScript code. What changes is how the array is structured in those cases.

* I didn't test the code I am suggesting to use for a theme.


Shipping rules for group of countries (ex. UK or ITALY)

The OR and AND-groups takes all conditions inside of them with the chosen operator.

Your:

Condition 1: IT
--OR
----Condition 2: FR

Will be converted into ([Condition 1] AND ([Condition 2])).

Try putting both Condition 1 and Condition 2 in the OR-group:

--OR
----Condition 1: IT
----Condition 2: FR

This should be converted into ([Condition 1] OR [Condition 2]).
If that's what you're after.

Edit: Just a couple of minutes too late :)


Can a Event Service be coupled to a route

If you want to restrict the event subscriber to a route then check for the route name:

public function onResponse(FilterResponseEvent $event) {

  $route_name = $event->getRequest()->attributes->get('_route');
  if ($route_name !== 'my.route.name') {
    return;
  }

  ...

}

Although in Drupal it might be best practice to get the route name from the current_route_match service:

$route_name = $this->routeMatch->getRouteName();

which you then need to inject in the event subscriber.


Child & Grand Child terms of Parent Term from URL

You can create a Block that displays Child and Grandchild terms (in terms of hierarchy within a Taxonomy Vocabulary) on a taxonomy term pages with the use of an additional module Views Contextual Filters OR to tell the Views to show children OR grandchildren.

Contextual filters always work with the AND operator, so this module is necessary to loosen that circumstance.

Create View of type Taxonomy term
Filter it to show only the Food Vocabulary
To show Children of a term on that term page we can use the Parent term Contextual filter with these options:
When the filter value is NOT available
Provide default value
Taxonomy term ID from URL
Load default filter from term page
When the filter value IS available or a default is provided
Specify validation criteria
Taxonomy term ID
Food

Now if you enter a term ID into Preview you will see the Child terms of that term. This takes care of the Parent-Child.
To filter Grandchildren we have to introduce that level of connections into View. Add the Parent Relationship
Add another Parent Relationship and make it use the first one, this is how we get Grandparent info
Add a new Contextual filter Term ID and make it use the second Parent Relationship and other options the same as above.

Now if you enter all/[TID] you will see the grandchildren terms of the [TID].
To make the Contextual work with OR go to Query settings and enable Contextual filters OR option.

To test enter the term ID twice into Preview [TID]/[TID].
Add the Field Name from the Taxonomy term Category and make it use the first Parent Relationship (that is the Parent, not the Grandparent), you can Exclude it from display later
Under Format Settings set the Grouping field Nr.1 set the Parent field (you might want to use the HTML List as the Format)

The results will show the grandparent first and its children, then grandchildren under their parents.

If the grandparent showing their children is not necessary for you, which it probably isn't, because it will be implied from circumstances by being on the grandparent page, you can edit the Filter from step 2 and make it use the second Parent Relationship, this will only show Grandchildren grouped by Parents.

Place the Block in a region and limit the Pages to /taxonomy/term/*.

Alternatively you'd have to use Views Field View to insert one view into another, which can be performance heavy. I'm not sure how the above compares, it does use some LEFT JOINs too which aren't so performance friendly.


Commerce - access denied on checkout page

I found out that there is a difference between how Zend and HHVM interprete the php key() function.

In the Drupal commerce_checkout module there is a function that returns the first key of an array by using the php key() function (commerce_checkout.module, line 480).

/**
 * Returns the page ID of the first checkout page sorted by weight.
 */
function commerce_checkout_first_checkout_page() {
  return key(commerce_checkout_pages());
}

On the default Zend rendering engine this returned the desired result of the first array key. But in HHVM this returned nothing. I believe this is because the pointers of the array were not flushed by HHVM (maybe for performance reasons), and they were flushed in the Zend engine.

I don't think it was a good idea of the creaters of this module to use the key() function to get the first key of the array anyway

I now rewrote this function to this:

/**
 * Returns the page ID of the first checkout page sorted by weight.
 */
function commerce_checkout_first_checkout_page() {
 return reset(array_keys(commerce_checkout_pages()));
}

Getting the keys of the array first and then with reset() rewind the array's internal pointer to the first element and return the value of that first array element.
Of course the key() function did the job on the standard Zend engine, but for HHVM this didn't.

I will report this issue to the maintenance crew of the drupal commerce module, and hopefully it will be commited into the next release. I don't think there is anything wrong with the way HHVM interprets the key function (if I am right in thinking this is the root of the problem). I think the key() function just shouldn't be used like this in this situation.


You have two options. Either go back to using _form_alter() hooks to handle it, or you can extend twice:

module 1 node for extends module 2 node form which extends node form. Then make sure to call the parent::validateForm and parent::submitForm from your validate and submit handlers.


Creating child nodes when creating parent

Your main problem here is you won't be able to create a reference to the created node in a form submit as the node id hasn't been created yet. I'm not actually sure at what point it becomes available in the node process either. hook_node_save is still too early and it's the last node specific hook you can do this with.

I would skip trying to do this programmatically and use rules and entity reference field. Have your rule fire after a new node is saved. then have it create a new entity (node) and set data value (entity_reference) to the newly created node. much easier to maintain than code.


Webform - Submit values from Drupal 7 from to external url

In Drupal forms, form_alter hooks can be used to change almost anything in the form. Additional submit handlers can be handled, validation can be done, elements can be added, etc.

But for all of these to work, Drupal need to be the responsible party in both form build phase and the form submit phase.

When you set $form['#action'] = url('https://[url path to external site]');, you are actually removing Drupal from that latter responsibility.

Check the altered form - you will see that the form tag's action is set to the external site.
When the form is submitted, browser sends all its data to that external site, and Drupal no longer can validate or perform submit functions in the form. I think this is the misconception happens.

If you don't want Drupal to validate the form, record the webform submission or do anything after the form submission and let the remote site do everything for that submission, your code will work just fine. You can remove $form['#submit'][] = 'webform_extra_submit'; part and the webform_extra_submit function itself.

However, if you do want to record the submission and submit the data to that remote site as well, you can do it like this:

function webform_extra_form_alter(&$form, &$form_state, $form_id)
{
   //only want form with nid 1171 to submit externally
   //Note that "webform_client_form_1171" means modify the Webform form for the node with NID "1171". Adjust to match whichever webform node's form you're modifying
   if($form_id == 'webform_client_form_1171')
       {
            $form['#submit'][] = 'webform_extra_submit';
       }
}

// Adds a submit handler/function for the app signup form (Webform ID #1171)

function webform_extra_submit($form, &$form_state) {

    $options = array();
    // Array keys are matching the key that the remote site accepts. URL encoding will be taken care later.
    $options['data'] = array(
        'firstName' => $form_state['values']['firstName'],
        'lastName' => $form_state['values']['lastName'],
        'email' => $form_state['values']['email'],
        'name' => $form_state['values']['name'],
        'phone' => $form_state['values']['phone'],
    );
    $options['data'] = http_build_query($options['data']);
    $options['method'] => 'POST';
    $url = 'https://[url path to external site]';

    // Put your additional headers here. Cookie can be set as well.
    $headers = array('Content-Type' => 'application/x-www-form-urlencoded');

    $options['headers'] => $headers;

    // Submits data to the remote server from the drupal server. User will remain in the Drupal form submission chain.
    $response = drupal_http_request($url, $options);

}


You should use the ctools_modal_text_button function to render your "popup-opener" links.

ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();
$link = ctools_modal_text_button('Open popup', 'codeexpertz/nojs/page', 'alt here', 'no-class');

You can have a look what the Modal Entities modue does in the modal_entities_generate_link() function for additional style settings.


User-submitted reviews of multiple aspects of a business?

In Drupal 7, you can create a review as a custom content type.  Staff could be rated as "very unhelpful" to "very helpful" using a field of type list (integer).  Quality of clothing could also be done with a list (integer).  For the time customers spent at the store, the field type to use depends on what you will do with the data later.

You could then create custom displays for this content type using Views.  Views integrates with Display Suite as well so you could use that if you liked, though I'm not sure it's the best solution.

As for the averages, you'll need to know some PHP, but you can use the Computed Field module.  Even if you are not very familiar with PHP, there are many examples on that module's documentation page.

If you're new to Drupal and all of this is very confusing, I highly recommend the book Using Drupal published by O'Reilly.  The second edition just came out recently and covers Drupal 7; it contains an explanation of how to use fields/content types and views (chapter two) as well as how to build a job posting site (chapter three) and product review site (chapter five), two examples that would probably be highly informative for you.

Good luck!


Yes. These classes are hardcoded into Drupal and are not only used for visible styling but also for the jQuery code that "animates" the forms (validation, autofill, auto focus, etc.)

HTML elements can have multiple classes. You could just add the classes to the Drupal form and then create your own theme. By creating your own theme you could not theme the default Drupal classes and instead just theme the classes from Base CSS.


Why are responses for AJAX POST calls in admin UI so delayed

It was apache's mod_security

I'm not sure exactly what was going wrong, but my host (ANHosting) was able to fix the problem.


Take a look at the implementation in user_login_block(), particularly this line:

$form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE));

This will add the destination parameter to the URL, which takes precedence over any other arguments passed to drupal_goto() (like $form_state['redirect']).
Depending on how you create your modal, the easiest way would therefore be to simply append the destination argument for the current page to the form action.


How to hook "/system/ajax" with javascript in Drupal 7

You can use hook_menu_alter and define your own custom callback function like below.

function demo_pane_menu_alter(&$items) {
  $items['system/ajax']['page callback'] = 'demo_pane_taxonomy_autocomplete';
}


Access the field class from within FieldItemList (D8)

You first need to understand that the entity object in question does not have a property called myfield.

Drupal uses something called magic properties to mask the get method required for retrieving the field item list. See FieldableEntityInterface::get() for more information.

The second thing you should know, is that drupal treats all fields as multi value. That means that a field that is defined to have a single value would still be represented a list with a single item.

Finally, to answer your question, you can either use the FieldItemListInterface::get() method to get the field item object, it you can access it as though it was an array.

$entity->get('myfield')->get(0);

OR

$entity->myfield[0];


The devel module has an option to log the query times into the database, and you can then run your own analysis on this and do whatever you like with it.

This is something to be careful about as it is a lot of data and can add up quickly. However, for more sophisticated/aggregate analysis, it's quite useful.

After enabling query logging, you can see some results at http://yoursite.com/devel/queries


Custom field permissions based on workflow or rule/action

You can probably do this with Conditional Fields.

  Define dependencies between fields based on their states and values.

  Conditional Fields for Drupal 7 is an user interface to the new States API, plus the ability to modify fields appearance and behavior on certain conditions when viewing content.


"New" Marker for Comments does not vanish

Trying this out in vanilla Bartik doesnt have issues.
I couldn't say for sure without looking at your "modifications". But on digging a little deeper I assume it's one of the following

The reason for your issue is most likely your modifications to node.html.twig(or node--article.html.twig)

You would have rendered 'comments' outside of

<article{{ attributes}}>
</article>

in your template.
You would have removed a required attribute "data-history-node-id"
from

<article>
</article>

tags in your template

Details:

/history/NID/read always returns the current timestamp

The module in question here is the new core 'history' module.
The path "/history/NID/read", if you check history.routing.yml, resolves to readNode() in HistoryController
In there you can find a call to
history_write($node->id());
first and then followed by a call to
history_read($node->id())
which would return the current timestamp (because it has just updated it in the previous history_write line)

According to the function description

  "Marks a node as read by the current user right now."

so it is used to mark a node as read by the user and not to get a node's last read timestamp.

The new marker logic is at core 'comments' module
comments/js/comment-new-indicator.js
processCommentNewIndicators() function.

The following line will not return a value

    var $node = $placeholder.closest('[data-history-node-id]');

if the $placeholder(marker) was not inside  tag with attribute "data-history-node-id"
if the article didn't have the attribute "data-history-node-id". Make sure you don't remove it from your node.html.twig (or equivalent)


Get all fields for a given content type including title

The node title is not a field handled from the field API. If you want to know if a content type has a title, you can use the following code.

$types = node_type_get_types();

if (isset($types[$content_type]) && $types[$content_type]->has_title) {
  $title = $types[$content_type]->title_label;
}

The code you are looking for is the same code used by Drupal to sort the fields (and extra fields) in admin/structure/types/manage/article/fields.

The function that handles that page is field_ui_field_overview_form().

Basing on the code of that function, I wrote the code you would need to get the list of fields, and extra fields, with their label, and weight.

  $fields = array();
  $instances = field_info_instances('node', $content_type);
  $extra_fields = field_info_extra_fields('node', $content_type, 'form');

  // Fields.
  foreach ($instances as $name => $instance) {
    $field = field_info_field($instance['field_name']);
    $fields[$instance['field_name']] = array(
      'title' => $instance['label'],
      'weight' => $instance['widget']['weight'],
    );
  }

  // Non-field elements.
  foreach ($extra_fields as $name => $extra_field) {
    $fields[$name] = array(
      'title' => $extra_field['label'],
      'weight' => $extra_field['weight'],
    );
  }

Notice that the extra fields don't contain just the title, but every extra field for which a module returned information in hook_field_extra_fields(). There are modules that add fields to the node editing form, and implement hook_field_extra_fields() to allow the users with the right permission to decide the order in which their fields appear. For example, if you have installed the Mollom module, the page I shown in the previous screenshot becomes the following one.

Notice also that it is easy to notice which fields are not implemented using the field API if you look at admin/structure/types/manage/article/fields: For those fields, the Field column doesn't contain a link. That is what happens for the fields labelled Title, and Mollom.


How to clear cookie with cookie name on from submit?

By setting it to one hour ago time with empty value I managed to make it working according to my requirements.

function custom_overrides_link_node_form_submit($form, &$form_state) {

  if(isset($_COOKIE['section'])) {

    unset($_COOKIE['section']);
    setcookie("section", '', time() - 3600);
  }

  if(isset($_COOKIE['topic'])) {

    unset($_COOKIE['topic']);
     setcookie("topic", '', time() - 3600);
  }

  if(isset($_COOKIE['language'])) {
     unset($_COOKIE['language']);
     setcookie("language", '', time() - 3600);
  }

}


How to Send an email with the list of products ordered in its body?

If what you're looking for (= the list of products) is not available, then just (a) make it available first and (b) wait with your Schedule Rules Component action (to send an eMail) until it is available. Read on for more details ...

The trick to do so is similar to what is shown in the Rules example included in my answer to "How to concatenate all token values of a list in a single field within a Rules loop?". In your case, you could make it work like so:

Add some new Rules variable that will be used later on as part of the eMail body, before the Rules Action to schedule the Rules Component. Say you name the variable prod_list_var_for_email_body.
Add a loop to iterate over the list of links to the product pages. Within that loop, for each iteration, prepend or append the value for each list_item to that variable prod_list_var_for_email_body (see where we're going???).
Make sure that the Schedule Rules Component action is your last Rules Action, after the loop completed. And finetune the details (configuration) of your Rules Action to Schedule Rules Component. When doing so, you'll be able to select the token for file_list_var_for_email_body to include anywhere in your eMail body.

Easy, no?


I'm not sure exactly what your problem is, but it's probably faster to simply try re-installing again from the start than to troubleshoot your installation.  It's hard to estimate how much time it will take to troubleshoot when you don't know what's wrong but you know roughly how long trying to install it again will take.

Although I use MAMP with Drupal myself, if you're a first-time user it might be easier to try Acquia Dev Desktop, which is an "Apache server in a box" like MAMP but already includes the latest version of Drupal and is ready to go as soon as you install it.  Acquia is a company run by the founder of Drupal so you know you're in good hands.

Alternately, although not specifically a Drupal company, Bitnami offers Drupal as an "Apache server in a box" like MAMP as well as as a virtual machine and as a cloud server on Amazon cloud.

There's also Pantheon, which is a Drupal platform that will let you register an account and create Drupal sites in the cloud for free (note that Pantheon will, however, charge you if you decide to take your site live on their service).

I listed many options; of them all, Acquia Dev Desktop is the simplest to set up and get running.


Is it possible to disable taxonomy hierarchy?

If the Relation input is not exposed in the Form Display, then you are going to need to use a hook_form_alter to hide the Relation input.

Also, note, that the drag and reorganize on the vocabulary overview will still support hierarchy. You'll need to alter that form as well to disable it.


Change the the title on the `?q=user` page

There are a number of ways you can do this:

Create a template file for user pages in your theme that renders the title differently
Create a custom module that alters the title using hook_menu_alter
Use Page Manager (part of ctools) and Panels to customise the layout of the user page
Likely other ways I don't know about

Number 1 is probably the most common, 2 is only really okay if you're already writing a custom module that changes user page behaviour, 3 is a more advanced method that basically lets you pull apart the page and put it back together how you want.

The simplest version of #3 would be to create a new variant of the user/%uid path with exactly the same content, and just set the title in the page manager UI using tokens.

Searching for keywords from the various options should provide you with plenty of tutorial material.


How to add CSS classes to a Views-generated block? (NOT to its generated content, the block itself!)

First. You have "hash" - because you view machine name is too long.

Second - you can add your own classes to view


How to limit the words in search api autocomplete suggestion?

Try below code, and you can trim $label as you want.

/**
 * Implements hook_search_api_autocomplete_suggestions_alter().
 */
function HOOK_search_api_autocomplete_suggestions_alter(array &$suggestions, array $alter_params) {
  $used_labels = [];
  /** @var Drupal\search_api_autocomplete\Suggestion\Suggestion[] $suggestions */
  foreach ($suggestions as $key => $suggestion) {
    $suggestion->setUrl(NULL);
    $label = $suggestion->getLabel();
    $suggestion->setSuggestedKeys($label);
  }
}


How to convert an image field to an entity reference field

In a mile high explanation:

add entity reference field to content type.
you can use rules, or a php-script to load all the nodes for your content type.
loop through each node, get the field value fid of the image paragraph field, assign it to the entity reference field.
save the node

After all the above is done, remove/delete the paragraph bundle.


Can you create new users without entering email, then prompt user upon first login?

Use Force Password Change module.

This module allows administrators to force users, by role, individual user, or newly created user, to change their password on their next page load or login, and/or expire their passwords after a period of time.


This behaviour is usually caused by the form being rendered too late in the page build process (for example by calling echo render(drupal_get_form('form_id')); directly in a template file).

By the time the form submits, the session messages have already been prepared for rendering, and so when more messages are added by your form's validation, they don't display until the next page load.

Without knowing exactly where you're rendering/preparing the form is hard to offer advice on how to fix it. I think it would suffice to say that if you're rendering the form directly in a template file, you should move it to a preprocess function at least.

The better way would be to prepare and render the form at the module level, rather than the theme level, as that will be processed early enough in the page load for this problem to disappear.

To address your comment:

I think the problem is definitely where you're calling the form building function from. You should be able to just take that code and put in a preprocess function, preferably in a module file as that pretty much guarantees the call won't come too late:

function MYMODULE_preprocess_page(&$vars) {
  if ($_GET['q'] == 'some/path') {
    $vars['the_form'] = module_invoke('my_module', 'block_view', 0);
  }
}

Then just print it if it's available in page.tpl.php:

<?php if ($the_form): echo $the_form; endif; ?>


Workbench moderation allowing a role to unpublish content?

You need to make transitions for the backward states through moderation (eg, Published -> Needs Review, and Published -> Draft) on admin/config/workbench/moderation/transitions

Then, on  on admin/people/permissions#module-workbench_moderation, assign the permissions appropriately to the roles you want to allow to push things backwards


How to enable user search in Apache Solr?

There is the Apachesolr User module, which has just a development snapshot release for both Drupal 6, and Drupal 7. It is used from 76 sites, 72 of which run Drupal 7.

Basing on the module description, it could suit for you.

  This module will add users to apache solr. It is compatible with the latest beta of Apache Solr search integration.
  It now exposes the User entity type as an indexable entity type so it can be indexed properly. All Apache Solr hooks are available to modify the way you are indexing users.

Looking at the issue queue for the module, I found Only users with the "Bypass content access control" permission are able to search for users when Apache Solr Access is enabled. Before using the module I would rather wait that issue is fixed. If you aren't using the ApacheSolr Access module, you should not have the issue reported there. That is what a user commented.


Local Drupal installation can't copy files to another computer on network

Go to the MAMP console under "General" tab, go to the setting for "Run Apache/MySQL server as user".

It should be setting to www (Apache) / mysql (MySQL).
So you need to change it to username (Apache) / username (MySQL).

Save and restart the servers

Refresh the browser, then change it back to www (Apache) / mysql (MySQL), save and restart, and everything should be working


In short, yes memcached will benefit both anonymous and authenticated visitors (even if you also use Varnish).

Memcached and Varnish operate at different layers.  Varnish caches entire HTTP requests (and sometimes edge-side includes, but this is less common in the Drupal ecosystem). Memcached stores frequently used data within the application, and it is a replacement for the cache_* family of database tables.

Memcached will speed up anonymous requests when the Varnish cache misses or is bypassed.


How to have display suite extra show up as layout options when creating blocks?

May I suggest a different setup?

I would go for DS + Bean, that would allow you full Display Suite capabilities in your Drupal.
It will effectively give you block types that you can manage like nodes (Fieldable as well as managing their Display View Modes using DS).
Plus, the world of BEAN is wonderful => https://www.drupal.org/node/1475632
And it made it into core in D8 for a reason!

Here is two quick screenshots (after 30 seconds of clicking):

Manage display for a block type

Add a new block (using a new Block Type called Standard) via Content>>Add Block>>Standard.

Hope this helped, even though it deviated from the OP a tiny bit!


mymodule_admin() is not the function that does the trick saving your variables. It's system_settings_form().

You can retrieve variables saved by system_settings_form() using variable_get() function.
So, in your case, you can get the value like this:

$txtSubscription = variable_get('txtSubscription', '');

Second parameter of the variable_get function will be returned if the variable is not set (not necessarily empty).
Notice that we used the same key as your form array's key.

During the Drupal bootrap, all variables are loaded to $GLOBALS (Thanks to kiamlaluno for the correction). Do not use this to store all your data because all of these variables will be loaded on every bootstrap.


Is every image style I have for each image upload auto-created?

The styled images will be created on first request, creating a new file with the styled image. This will not only save space if you have tons of image styles but also CPU power - because if you attach 10 images to a node and want to create 12 (as you mention the number) different image styles, that will put quite a load to generate all the styled images in one go. Doing this when needed is far better management of resources.


How do I display the file size and format of attachments on a node templates?

There's a module which provides a Twig filter for that: Format Bytes

In twig when you get the value of a file, the size is in simple bytes and if you're intending to show it to your end-user, it's not user-friendly, this simple Twig filter helps with that and renders the file size in it's respected: 'B', 'KB', 'MB', 'GB', 'TB'

Example usage:
{{ node.field_attachment.entity.field_file.entity.filesize.value | format_bytes }}

The alternative would be to do the same formatting that module does in your own preprocess function for the template.


How to add special character validation on specific field in form registration process

Try using Field Validation  Module it simplifies your work!!

If you want to code it then check this post It solves the same issue

Try changing your code:

 $special_character_list = '\'^£$%&*()}{@#~?><>,|=_+¬\-\[\]';
  if(preg_match('/[' . $special_character_list . ']/',$form_state['field_employer_name']['und'][0]['value']['#default_value']) !== 0)


Pass Webform Submission Back to Form Template

Just configure your webform, so the "redirect URL" is the following:

node/[node:id]/submission/[submission:id]

Now after submission you will see the result overview page of that submitted form


Set entity reference revision field value?

You need to store also the revision id, see Programmatically append multiple paragraphs to entity reference field on node.

Or simply set an entity, from which the field can get the data it needs in both cases:

$node->field_test_entity_reference->entity = $target_node;
$node->field_test_entity_revision->entity = $target_node;
$node->save();


Using template on subsite for certain node type

Activate twig debug and use the browser inspector to see the template precise name available for your content-type
Do a cache rebuild when the temaplte is created to make it happen.


How to go to external website from within a module?

You should use drupal_goto to redirect to a URL.

drupal_goto($external_url, array('referral' => $referral_url));


Modify text of error message for required field

Quick and easy fix is to use the String Overrides module. Here is a quote about it (from the module's project page):

Provides a quick and easy way to replace any text on the site.
Features:

Easily replace anything that's passed through t()
Locale support, allowing you to override strings in any language
Ability to import/export *.po files, for easy migration from the Locale module
Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.


How to check with Rules if a new element has been added to a list in a node?

You're counting the wrong thing...item data is a bit further down the rabbit hole (inside the language array):

$count_new = count($node->field_lista_gestori[$node->language]);
$count_orig = count($node_unchanged->field_lista_gestori[$node->language]);


You can find the configuration on admin in the /admin/config/people/accounts but if you want to notify the user programmatically without taking care of what is the config you can use _user_mail_notify function.

_user_mail_notify documentation


Disable "Operating in maintenance mode. Go online."

Drupal 8 version:

function mytheme_preprocess_status_messages(&$variables) {
  if (\Drupal::state()->get('system.maintenance_mode')) {
    $message_count = count($variables['message_list']['status']);
    if ($message_count > 1) {
      array_shift($variables['message_list']['status']);
    }
    else {
      unset($variables['message_list']['status']);
    }
  }
}


How do I programmatically update a UUID?

Haven't tested this but I believe this is the route to go if you must add the uuid in this manner.

$uuid = 'd12da227-890b-4eb7-86b1-93937e7d6d91';
$p->set('uuid',$uuid);
$p->save();

Let me know if that doesn't work.


Not sure if there is a dead simple solution. I know that by using Services and Services Views you can use offset and limit as arguments when calling the service.

So that the URL could look like: http://example.com/rest/views/articles?limit=5&offset=2


In your edit view, click on Advanced (located on the right side) For Contextual Filters click add. Search for "nid" and select Content: Nid

Under When Filter Value is not available, select the 2nd one (provide default value). For Type, select Content ID from URL.

This will filter your view, and show you the fields only from the current "Block content type" node that you're viewing.


What is the best way to tell anonymous users apart?

Session variables seem to be the way to go

Don't forget that session variables rely on cookies

  Have I missed any options?

The traditional solution would be to use the ip address as a fallback if cookies are disabled.
PHP does support an alternative to cookie-based sessions -- it can rewrite the URLs to include "?PHPSESSID=xyz". However, securing this can be difficult.
Another approach would be to use html5 local storage and do all the cusomizations on the client-side. This will work in all modern browsers regardless of cookie or firewall settings.


How do I add a custom script on a specific page?

You could do this:

<?php
$node = menu_get_object();
if ($node && $node->nid == DONATE_NODE_ID):
?>
<script></script>
<?php endif; ?>

But a better way would be to:

Wrap your script in Drupal.behaviors:

(function ($) {
  Drupal.behaviors.NameOfYourTheme = {
    attach: function (context, settings) {
      // Your JS code goes here.
    }
  }
})(jQuery);

Call drupal_add_js() in hook_preprocess_page(). This code would go to template.php:

function YOUR_THEME_preprocess_page(&$variables) {
  $node = menu_get_object();
  if ($node && $node->nid == DONATE_NODE_ID) {
    drupal_add_js(drupal_get_path('theme', 'YOUR_THEME') . '/path/to/js.js');
  }
}


Views don't seem to be working properly on localhost with Chrome

I think your chrome cache is loading the 'old' page

clear your chrome cache:

when in chrome press shift+ctrl+del
then check ´Empty the cache´
click clear browsing data.

should be fixed now ;)


how to show a panel node only to authenticated users?

I think that Content Access module should help You because it gives You ability to grant access to content type (panel) or - after select "Enable per content node access control settings " option - to single node.


What is the purpose of a configuration schema file?

Drupal does not check the configuration schema at runtime when the configuration is loaded - the configuration is assumed to be correct.
The schema is used in the tests - when running tests, configurations are automatically validated against the schema to ensure they are correct. Presumably you have developed your module with tests, and by the time you make your module publicly available you will have your tests running and verifying that the configurations you are shipping are valid.
The contributed config_inspector module is very useful for validating and debugging configuration and configuration schema.


Nivo Slider lists up the images instead of sliding

I think there's an installation priority issue with Nivo Slider module and Libraries API module or Nivo Slider library files.

Since you installed all required modules and placed Nivo Slider library files in the right location as explained in the installation steps:

  To install Nivo Slider:

  Download the latest version of the Nivo Slider jQuery plugin and
  extract it to sites/all/libraries or sites/sitename/libraries as you
  require.
  The extracted folder must be named nivo-slider. Enable Nivo
  Slider and all of the modules that it requires.
  Configure the jQuery
  Update module to use jQuery 1.7 or higher.

Now you need to disable Nivo Slider module by running this command drush pm-disable nivo_slider, then you need to uninstall Nivo Slider module by running this command drush pm-uninstall nivo_slider, then install Nivo Slider again by running this command drush en nivo_slider.

Don't forget to clear Drupal cache after you finish uninstalling and installing the module; just in case.


This displays data after all the filters, arguments, etc are applied. It's kind of like the raw output. You're theming will be displayed when the actual page is loaded with the block enabled for that page.


Sorting view results using contextual filters on Drupal 8

There are two parts to this question: getting the Contextual filtering to reduce the results to only the term IDs you specify in the URL, and using Aggregation for counting and sorting the results according to that count.

Contextual filter for Taxonomy term ID

Create your Views list of nodes with the Taxonomy reference field showing the tags, and configure that field to show all values in the same row
Add the Contextual filter for your Taxonomy term field or for the Field Has taxonomy term ID and configure it:
When the filter value is NOT available
Provide default value
Taxonomy term ID from URL
Load default filter from node page, that's good for related taxonomy blocks
Filter to items that share any term
When the filter value IS available or a default is provided
Specify validation criteria
Taxonomy term ID
[your vocabulary]
One or more IDs separated by , or +
More
Allow multiple values

Test this by entering the term ID (number) into the Views Preview field. You should see the results reduce to show nodes tagged with that term. Also test for more than one term, enter, for example, 3+5 to show nodes that are tagged with either terms 3 or 5, or 3,5 to show nodes tagged with both terms 3 and 5.

If you want to use term names instead of term ID numbers, then instead of using the taxonomy term reference field as the Contextual filter, you'll have to first add a Relationship for that field, then you will have the Taxonomy Name Contextual filter available. You configure it similarly as above, be careful about case options. You test it by entering the term names into Preview: firstTerm,secondTerm.

Count with Aggregation

Turn Aggregation on in the third column of Views settings
Click on Aggregation settings for the Taxonomy field (from step 1. above) and change the Aggregation type to Count DISTINCT.

This field will now show the count how many terms are shared.
Add the Sort criteria for your Taxonomy terms field, and set its Aggregation to Count DISTINCT and you'll probably want to sort descending. You should have no other sorting added except this. You will see the nodes sorted by the number of tags shared with the contextual filter.

Test this the same way as above, entering term IDs, or term names if that's what you're using.

In the end you'll have to test in a real page to check that the Contextual filter has been configured properly. Build and test in steps, don't first build everything and only test because if there's something wrong it will be more difficult to figure out what and you'll have to start from scratch step by step anyway.


Give flagged products in search API a higher search score?

You could have a view that shows flagged nodes by user and a view attachment for the index filtering out nodes that the user has flagged.


How to get all Fields of specific FieldType?

You code is OK, only that you are trying to read the protected property field_type. Instead use the method:

$field->getType()

Reference: public function FieldDefinitionInterface::getType()


From my personal experience, I would run these tree commands like this:
drush cc all; drush dl freds_module; drush en freds_module --yes. I use semicolons to separate my commands. You can also use the ampersand(&&), drush cc all && drush dl freds_module && drush en freds_module --yes. Here, if one command fails, the rest will not run.


How to enable special characters in Drupal Menu?

I guess that you can review in the nice_menus.module file, specifically in theme_nice_menu_tree() module function to parse/filter/encode/replace each hexadecimal string that seems be pushed by menu_item_link($mid) or $mid string. Remember do this kind of test with a copy of your production site. I have not tried this suggestions, sorry, I only guess after a rough review of the code. I think that could be useful. - @cigotete


How to Automatically Manage a LARGE Number of Views Pages Under ONE?

All you have to do is to add a wildcard to the URL pattern of your view like /students/% and then use this as argument for the contextual filter.

Similar to how the default "Taxonomy term" view does it (screenshot attached):


You can do that by passing a context function in Javascript that replaces the $-placeholders in your style object. I gave an example in this answer. The linked answer only changes the icon based on term rather than changing the marker size, but the principle's the same. Let me know if I can be of more help.

Edit: Sorry, I hadn't looked at your example when answering. That map doesn't involve clustering, so I think you can do it purely via the GUI. First you need to get the number as a field in Views and then use the appropriate placeholder (which you can see when you preview the data overlay display of the view) in the pointRadius field of the map's style.

Details

Make sure that the report count is a field in the OpenLayers Data Overlay display of your view.
Look at the preview of this display and note down the placeholder for the field - something like ${field_report_count}.
Go to Structure -> OpenLayers -> Maps and edit the appropriate map.
Go to Layers & Styles, scroll down to OVERLAY LAYERS and look for the line which starts with the name of your view (it should end with - OpenLayers Data Overlay). Note down the name of the style in the STYLE column.
Go to Structure -> OpenLayers -> Styles and edit the style you noted down from step 4.
Put the field name you noted down from step 2. in the fields pointRadius and label. (I've never used the label field but I assume it does what you want.) You can also change the labelAllign, labelXOffset and labelYOffset fields if you want.


Is it possible to pass classes to twig include template

Yes @Clive, it's correct. I can simply declare a variable called "card_classes" and it is passed to the sub-template. During my tests I targeted an incorrect base template. It was my problem :-/
In the included template :
{% if card_classes is not defined %}
  {% set card_classes = [
    'card-view',
    'row',
    'row-cols-1',
    'row-cols-md-2',
    'row-cols-lg-3',
    ]
  %}
{% endif %}

{% if title %}
  <h3>{{ title }}</h3>
{% endif %}
<div{{ attributes.addClass(card_classes)}}>
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row col',
    ]
  %}
  <div{{ row.attributes.addClass(row_classes) }}>
    {{ row.content }}
  </div>
{% endfor %}
</div>

By checking if card_classes variable is defined or not, I can set default classes in the included template itself, or override the default classes in the base template.
And now in base templates :
{# use default classes #}
{{ include('@my_theme/views/views-view-unformatted--card-template.html.twig') }}

or to override
{# override default classes by another set of classes #}
{%
  set card_classes = [
    'card-view',
    'row',
    'row-cols-1',
    'row-cols-md-2'
  ]
%}

{{ include('@my_theme/views/views-view-unformatted--card-template.html.twig') }}


Deliver ajax commands on successful form submit

You return the ajax commands in your ajax callback function.

function my_module_form_ajax_submit(array $form, array &$form_state){
  if (count(form_get_errors())) {
    return array(
      'track_id' => $form['track_id'],
      'courier' => $form['courier'],
    );
  }
  else {
    $ajax_commands = array();
    $ajax_commands[] = ajax_command_invoke('myModal', 'modal', array('hide'));
    $ajax_commands[] = ajax_command_replace('form-finished-wrapper-'.$node->nid, t('Submited Successfuly'));
    return array('#type' => 'ajax', '#commands' => $ajax_commands);
  }
}

I'm not sure what you were trying to do with your original callback, so I couldn't incorporate it.


How can I create newsletter template by Simplenews

from this tutorial website I found after a quick google search:
http://www.wdtutorials.com/2012/07/06/drupal-7-how-create-newsletters-simplenews#.VCEqY_l_uVM

Using templates
First select the theme you like to use to render the emails in

/#overlay=admin/config/system/mailsystem

There are 4 template files you can override in sites/all/modules/simplenews/theme:

simplenews-block.tpl.php
simplenews-multi-block.tpl.php
simplenews-newsletter-body.tpl.php
simplenews-newsletter-footer.tpl.php

Just copy them to your theme templates folder (like themes/bartik/templates) and edit them.


I think Commerce Cart Expiration (https://www.drupal.org/project/commerce_cart_expiration) will do what you want. But I've only used to expire carts that are older...48 hours, for example. That works fine with cron, but for shorter periods, you'll need something else.

From the readme:

The module also provides a block which displays the time remaining. Its content gets refreshed by javascript just like a countdown. To show up the block, add the 'Cart expiration' block to your preferred region under admin/structure/block.
You can configure this blocks content on the block configuration page. Use the token [commerce-order:expiration-formatted] to get a format that can be manipulated by javascript.


You could try this, if your using a node template:
{{ node.computed_field.value * 100 }}


LDAP SSO does not authenticate user on homepage

This works now after unchecking this setting in the SSO-Module konfig:


In the boostrap theme there is a file

  theme/menu/menu-tree.func.php

This file contains a function

  bootstrap_menu_tree__primary

This function wraps the menu as following:

'
' . $variables['tree'] . '
';

So you have to give the wrapper of your menu those classes and make sure the structure is exactly the same as the primary menu.

Hope this helps you out.


Sending an email blast only goes to certain users

Default PHP mailer has a lot of issues, and sometimes mails are not received or accepted by the servers as this a common method for sending spam.

A good practice is to use the SMTP module (https://drupal.org/project/smtp) for sending emails. You need to connect it to a server (eg. google) for authentification and then it replaces the default drupal php mailer.