Tokens for taxonomy term parents in Pathauto

I just tested the tokens that I suggested in the comments with field_tags on articles and it works perfectly, no idea what your problem is, make sure you use the latest versions of pathauto and token.

Token: /articles/[node:field_tags:0:entity:parents:join-path]/[node:field_tags:0:entity]/[node:title]

Tag hierachy: A > B > C

Alias for an article tagged with C: /articles/a/b/c/pathauto-test


How could I use both Rendered Entity and Fields in a view?

Figured out this IS possible, just have to switch things around.

Format to show Fields rather than Rendered entity. Then you have the option to use the rendered entity as a field. Something like this:

shows up in the Add fields list.


How can I remove old polls/results in Drupal 7?

You can remove the links by either copying the poll-results--block-tpl.php template file to you theme and removing the line that prints $links or with template_preprocess_poll_results(&$vars) in your template.php file in your theme and removing the line that sets the links variable.

poll-results--block.tpl.php

<?php print $title ?>

  <?php print $results ?>

    <?php print t('Total votes: @votes', array('@votes' => $votes)); ?>

template_preprocess_poll_results(&$vars)

function template_preprocess_poll_results(&$variables) {
  if (isset($variables['vote']) && $variables['vote'] > -1 && user_access('cancel own vote')) {
    $elements = drupal_get_form('poll_cancel_form', $variables['nid']);
    $variables['cancel_form'] = drupal_render($elements);
  }
  $variables['title'] = check_plain($variables['raw_title']);

  if ($variables['block']) {
    $variables['theme_hook_suggestions'][] = 'poll_results__block';
  }
}


Is there incremental deployment module for Drupal 7?

There is no Drupal 7 version of Incremental Deploy. In fact, the Drupal 6 version is no longer supported.

You have several options to duplicate the functionality. The closest match is probably Data Export Import -  https://www.drupal.org/project/data_export_import

Other options are the Migrate module - https://www.drupal.org/project/migrate or migrate_d2d - https://www.drupal.org/project/migrate_d2d

Modules for migrating specific content types are also available. For example, for taxonomies, Taxonomy CSV import/export - https://www.drupal.org/project/taxonomy_csv


MarkupInterface interoperability with other PHP frameworks

TLDR

(this summarizes conclusions from the comments below)

The MarkupInterface is available on packagist as part of the drupal/core-render package, which provides all the classes from Drupal\Component\Render\* without any heavy dependencies (only drupal/core-util). It does not give you TranslatableMarkup, though.

If you let your package depend on drupal/core-render, you can use MarkupInterface as a return type.

Implementations within Drupal modules, which call t() and return a TranslatableMarkup object, would satisfy the return type from the interface.

Implementations outside of Drupal would instead return FormattableMarkup, or HtmlEscapedText, or a custom implementation of MarkupInterface. Or something else, if the interface allows alternative return types (e.g. native string).

You need to decide if you accept this dependency, or do something else instead.

Original (longer) answer

The ultimate goal of having the two names spaces in Drupal is

Drupal\Component is for classes that do not need a bootstrapped kernel.  In other words, these do not need a running Drupal system. These classes may depend on other classes outside Drupal\Component (eg, Symfony) or other classes in Drupal\Component, but not Drupal\Core
Drupal\Core is for classes that require a bootstrapped kernel.  These full from Drupal\Core, Drupal\Component, and elsewhere.

Take date/time objects.

DrupalDateTime is in Drupal\Core because leverages the translation service.
DateTimePlus is inDrupal\Componentbecause it adds some enhancements to the native\DateTime` class.

So, in theory, Drupal\Component can be used in anything. That said, the composer.json files for each component may not be accurate for dependencies and minimum PHP version.

In your case, MarkupInterface and FormattableMarkup should be able to be used outside of Drupal. TranslatableMarkup relies on the Drupal translation system, which needs a booted kernel to operate.

TranslatableMarkup essentially just extends FormattableMarkup, and acts a bridge to the string translation service. So, that on its own doesn't buy you much unless you need everything that surrounds translation (language management, the UI, etc).

All of that said, I am not sure how much you will really gain from this. Ignoring the translation parts, FormattableMarkup is a component, but they are really best used as part of the rendering service, which is part of core.  For the purposes of making your own API, I would start with seeing if you can just leverage FormattableMarkup on its own.


Show newest nodes for each taxonomy term in Views

I was trying to achieve a similar thing. I've managed to create a view that gets one article for each taxonomy term using 'Taxonomy term: Representative node' under 'Advanced > Relationship'.

There is also 'Content: Taxonomy terms on node' there which might be more what you're looking for.

Once you've got the relationship you can pull out fields and base filter criteria on that relationship. My view only returns 1 content type for instance.

Make sure your view is on Taxonomy not Content.


Anyone knows a good tutorial to learn how to create install profile?

Developing installation profiles covers the majority of install profiles, well worth a look at to get started.

There is a how to guide here as well.


Creating views or facets search with multiple flags

I found out that if I add all of the flags (each one individually) as a relationship, so I end up with 20+ relationships, I can expose each one in a field to visitors and that way they can click through what type of flags they want to see and don't.

It's not pretty, you will end up with 20+ true/false select boxes but its working.


How to debug a rule that doesn't want to fire?

Flag Module

"User on whose behalf to flag" will not be ignored in this case.

When a flag is global, users don't necessarily have the required permission to toggle it.  Be sure that the user role is allowed to flag or unflag the flag in question.

A nodes 'published' status is a good example of a 'global flag' (though it has nothing to do with the flag module.)  When published is TRUE content is visible, when FALSE it's hidden.  Though the flag is global, only those with the 'publish content' permission can toggle it.  The Flag module works similarly.

Rules Module

Rules has a built-in debugger that is useful at times.  It can be found at admin/config/workflow/rules/settings

I generally end up falling back on dd() or dpm() though when debugging rules.  Rules is an incredible module for sure, but debugging at times can be a pain.


Schedule an email to be sent to new users a week after registration

My way to do this is to schedule a cron job at X time. You can check here how to do this https://www.drupal.org/node/23714 or use Ultimate Cron (https://www.drupal.org/project/ultimate_cron).

If you choose to use the Drupal core, implement hook_cron() where you will check the users that are registered by one week ago( table users_field_data, column "created"). Getting all the users then it only remains to send the email. Here is an example of sending email using mail Manager:

$mailManager = \Drupal::service('plugin.manager.mail');
  $module = 'module-name';
  $key = 'key1'; // Replace with Your key
  $to = \Drupal::currentUser()->getEmail();
  $params['message'] = $message; // Create this variable $message with the concret meesage.
  $params['title'] = 'Title example'; // Replace with a title.
  $langcode = \Drupal::currentUser()->getPreferredLangcode();
  $send = true;

  $result = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
  if ($result['result'] != true) {
    $message = t('There was a problem sending your email notification to @email.', array('@email' => $to));
    drupal_set_message($message, 'error');
    \Drupal::logger('mail-log')->error($message);
    return;
  }

  $message = t('An email notification has been sent to @email ', array('@email' => $to));
  drupal_set_message($message);
  \Drupal::logger('mail-log')->notice($message);

All these need to be integrated into hook_cron() function.


How to add an element into a nested array in twig?

I managed to solve the problem via hook_preprocess.
Here's the code

function mytheme_preprocess_table__forum_topic_list(&$vars){
    $vars['header'][0]['attributes']->addClass(['col-xs-9', 'col-sm-6']);
    $vars['header'][1]['attributes']->addClass(['col-xs-3', 'col-sm-2']);
    $vars['header'][2]['attributes']->addClass(['hidden-xs', 'col-sm-4']);

    $vars['rows'][0]['cells'][0]['attributes']->addClass(['col-xs-9', 'col-sm-6']);
    $vars['rows'][0]['cells'][1]['attributes']->addClass(['col-xs-3', 'col-sm-2']);
    $vars['rows'][0]['cells'][2]['attributes']->addClass(['hidden-xs', 'col-sm-4']);
}


It turns out the documentation is just a lie...

https://drupal.org/node/2126017

These values worked:

0-800
800-1000
1000-1200
...
1800-2000
2000-


Why are there so many different ways to translate menus?

Method 1 points to the node translation. Method 2 is a translation of the link but goes to the same path. For most people method 1 is the way to go. But method 2 could be handy as well.

Maybe life would be easier if you just build it in one language and use Google Translate Elements JS addon. It really depends on the needs of your users. For my client I had to use method 1.


Here is your answer: Page manager search. It works with the Search API module. Here is an excerpt about it from the module's project page:

... adds the ability for Page manager pages to be searchable via the Drupal core Search module or the Search API module.
Support for:

Drupal core Search module.
Search API module (via the Entity API module)

Note: this is a new module.


How to get the actual value of a field in Views?

I'm assuming you are using Drupal 6, since you mentioned about PHP filed.

below is the code to retrieve value from a field and where ['tid_1'] is the token for a field. I think this is similar for Drupal 7 too.

<?php
$static = $this->view->display_handler->get_handlers('field');

$b=$static['tid_1']->last_render; //$b contains the value of the field
$d=$static['tid_2']->last_render; //$d contains the value of the field
//use your logic
 ?>


First, it is important to note that true randomizing is an expensive operation.  The method involving Views will work with little effort, but if the site experiences very heavy traffic it could tax your database server to a point where it collapses.

The easiest way to accomplish this would be to create a View displayed as a block and filter by the appropriate content type.  Use a "Global: Random" sort to randomize the content and configure the paging options to show only one result.  Make sure you are displaying "fields" and not full nodes, then add the node title as a field.  It should be configured by default to link to its content, but verify this in the field's settings.  Instead of displaying the title of the page, you will want to display the text "Random" which can be accomplished by using the "Rewrite the output of this field" setting.  Then you can place the block where you want and style the link via CSS to look like a button.  Clicking on the button will then take you to a seemingly random node.

For a more scalable solution, you might want to move away from Views and leverage JavaScript for the randomizing.  On the backend you would queue up a handful of nodes and have JavaScript decide which one to display, thus taking the randomizing task off of the database.  It will be limited to the handful of nodes you pre-select, but your database will thank you in the long run.


How to set Permission based on roles for Views Data Export

This issue has been fixed in the 7.x-3.0-beta8 version. See the issue thread here.


How to use node data in content type as hierarchical select

It looks like you need Reference field option limit, or module with similar functionality:

This module allows reference fields of several types to have their widgets' available options limited by the values of other fields in the current entity.
This is best illustrated by examples:
(...)
Example 2: sports and teams
Suppose you want news stories to be marked as being about a sport and a particular team for that sport, perhaps using taxonomy terms for both. To make editing easier, you would probably like want the 'team' dropdown to be limited to just teams for the current news story's sport.
To achieve this with this module, add the 'sport' field to both news story nodes and team taxonomy terms. Hence the team 'Chudley Cannons' would have as its sport taxonomy term 'Quidditch'. (This probably entails taxonomy term reference fields on terms themselves... which was bound to happen with FieldAPI sooner or later.)
Thus, when editing a news story node, selecting 'Quidditch' as the sport will cause the team reference field widget to update to show only teams which also have 'Quidditch' as their sport.

If this module is not exactly what you want, it can be a good start for coding own functionality. At least it solves all AJAX interactions for you, so only part you might need to alter is the actual selection.


You can execute the following query.

if ($mlid = db_query("SELECT mlid from {menu_links} WHERE link_path = :path AND menu_name NOT LIKE :menu", array(':path' => 'node/add', ':menu' => db_like('shortcut-set-') . '%'))->fetchField()) {
  db_update('menu_links')
    ->fields(array('menu_name' => 'navigation', 'plid' => 0))
    ->condition('mlid', $mlid)
    ->execute();
  db_update('menu_links')
    ->fields(array('menu_name' => 'navigation', 'plid' => $mlid))
    ->condition('link_path', db_like('node/add/') . '%', 'LIKE')
    ->condition('menu_name', db_like('shortcut-set-') . '%', 'NOT LIKE')
    ->execute();
}
else {
  // There isn't any row for node/add.
}

What the code does is the following.

It finds the database row where the link path is node/add, and where the menu name doesn't start with shortcut-set-, which is the menu name used from the Shortcut module for its shortcut sets; as the default shortcut set used from that module contains a link that points to node/add, the code exclude that link. If there are other rows that would point to node/add, you need to edit the first query to exclude them.
For the row found from the first query, it changes the menu name to navigation, and plid (the parent link ID) to 0.
For any row whose link path matches the SQL regular expression node/add/%, it sets plid to the mlid previously found.

In the code I used db_like(), even in this case was not strictly necessary. The purpose of db_like() is escaping any character that for the SQL regular expressions has a specific meaning. Suppose that I would change the code to find any database row whose link path is node/%, where % is the character that is really present in the link path; without db_like(), the query would find any row where the link path starts with node/, which would include more rows than the ones where the link path is node/%.

As the code is using two update queries, it should use transactions. In that way, if the second query would fail, the database would be left in a consistent state, which means that the rows for node/add, and node/add/[content type] will be part of the same menu. If the first query is executed, and the second one fails, you would have node/add that is part of a menu, while any node/add/[content type] link would be part of a different menu (or some of the node/add/[content type] links will be part of a menu, and other node/add/[content type] links will part of another menu).

if ($mlid = db_query("SELECT mlid from {menu_links} WHERE link_path = :path AND menu_name NOT LIKE :menu", array(':path' => 'node/add', ':menu' => db_like('shortcut-set-') . '%'))->fetchField()) {
  $transaction = db_transaction();
  try {
    db_update('menu_links')
      ->fields(array('menu_name' => 'navigation', 'plid' => 0))
      ->condition('mlid', $mlid)
      ->execute();
    db_update('menu_links')
      ->fields(array('menu_name' => 'navigation', 'plid' => $mlid))
      ->condition('link_path', db_like('node/add/') . '%', 'LIKE')
      ->condition('menu_name', db_like('shortcut-set-') . '%', 'NOT LIKE')
      ->execute();
  }
  catch(Exception $e) {
    // One of the queries failed; rollback the database to the previous status.
    $transaction->rollback();
  }
}
else {
  // There isn't any row for node/add.
}

PS: As the only way to find the menu item is too look for its link path, there could be more than one row using that link path. It is important the code excludes those rows that are not the correct one, and that is what my code does when it excludes the rows there the menu name starts with shortcut-set-. Unfortunately, it is not possible to write code that generic enough to work in any condition.


How to add another condition to a specific active facet?

The solution is quite simple :

function mymodule_search_api_query_alter(SearchApiQueryInterface $query) {
    if(preg_match('/PRETTYPATHID/',url($_GET['q']))){
        $base_filter = $query->createFilter('AND');
        $base_filter->condition('MYFIELD', NULL, "<>");
        $query->filter($base_filter);
    }

}


When should the dependency from a Drupal core module be explicit?

As in all versions of Drupal, if your module depends on another module, you should always explicitly declare it as a dependency.


Field API field_schema for text field error

This is because your value suppose to be string, however you given array as per these errors:

Warning: preg_match_all() expects parameter 2 to be string, array given in _media_generate_tagMap()
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain()

Since you're sending array, the column count doesn't match in your SQL query.
This is what you're sending:
INSERT INTO {field_data_field_tab} (entity_type, entity_id, revision_id, bundle, delta, language, field_tab_tabtitle, field_tab_tabcontent)
VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7_value, :db_insert_placeholder_7_format);
Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 17 [:db_insert_placeholder_2] => 17 [:db_insert_placeholder_3] => tabbed_page [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => ss [:db_insert_placeholder_7_value] => ss [:db_insert_placeholder_7_format] => full_html )

which can be broke down into:

Fields: entity_type, entity_id, revision_id, bundle, delta, language, field_tab_tabtitle, field_tab_tabcontent
Placeholders: :db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7_value, :db_insert_placeholder_7_format

So you've 8 fields, but 9 placeholders.
Fix
To fix it, you've to check passed value of $item['tabcontent'] and make it a string. For example:
'#default_value' => !empty($item['tabcontent']['value']) ? $item['tabcontent']['value'] : '',

See also:

Errors when using a field of '#type' => 'text_format'


Have a look at this example implementation which creates a new OG Permission View unpublished content and uses Node Grants to decide who can view unpublished nodes. You now can configure which OG Role in your groups are allowed to view unpublished nodes.

<?php
define('MY_MODULE_REALM_VIEW_UNPUBLISHED', 'my_module_view_unpublished');

/**
 * Implements hook_og_permission().
 */
function my_module_og_permission() {
  // Add OG permission to view unpublished nodes.
  return array(
    'view unpublished' => array(
      'title' => t('View unpublished content'),
      'description' => t("Allow user to see unpublished content within the group."),
      // Determine to which roles the permissions will be enabled by default.
      'default role' => array(OG_ADMINISTRATOR_ROLE),
    ),
  );
}

/**
 * Implements hook_node_grants().
 */
function my_module_node_grants($account, $op) {
  if ($op != 'view') {
    return;
  }

  $grants = array();

  // Handle access to unpublished nodes.
  // Get all OG Group IDs the user is allowed to view unpublished nodes in.
  $entities = og_get_entity_groups();
  foreach ($entities['node'] as $entity_id) {
    if (og_user_access('node', $entity_id, 'view unpublished')) {
      $grants[MY_MODULE_REALM_VIEW_UNPUBLISHED][] = $entity_id;
    }
  }

  return $grants;
}

/**
 * Implements hook_node_access_records().
 */
function my_module_node_access_records($node) {
  // Node is unpublished and belongs to a OG group.
  if (!(empty($node->status) && $groups = og_get_entity_groups('node', $node))) {
    return array();
  }

  foreach ($groups['node'] as $nid) {
    $grants[] = array(
      'realm' => MY_MODULE_REALM_VIEW_UNPUBLISHED,
      'gid' => $nid,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 10,
    );
  }
  return $grants;
}


If you're on Cpanel just point both domains to same siteroot folder.

Otherwise create a symbolic link of folder2 to folder1 where folder1 and folder2 and siteroots of each domain.


The Field Type API are more strict in Drupal 8 so that Web Services and Forms  follow the same validation path. This is not always the behavior that we want.

Looking at your question again, I think that using an allowed values callback on the field would work as well.

I provided some alternatives based on the restrictions that core places on list fields below #1 as well in case the following doesn't work as intended. These could be useful for other people doing similar things.

#1: Try to use allowed values callback for the field instead

Set an allowed_values_callback for the list field.

function gamodule_allowed_values_callback(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = TRUE) {
  // @todo make this a bit more conditional based on the parameters above.
  $result = db_query("SELECT ga_id,name FROM ga_projects");
  $row = $result->fetchAll();
  $row = json_decode(json_encode($row), True);
  foreach ($row as $key => $value) {
    $matches[$key] = $value['name'];
  }
  return $matches;
}

Note that the documentation for callback_allowed_values_callback mentions using opt groups, but this functionality has a bug and is broken in 8.

#2: Migrate list field to text field

Make a Select list Field Widget for text fields. Migrate your data over.

Risks

A lot of work to re-architect.
May confuse a development team inheriting the site.

#3: Override the AllowedValues constraint plugin

Use hook_validation_constraint_alter to provide your own Constraint plugin (see Symfony 2 Constraint documentation).

Risks

Site is incompatible with a couple of contrib modules doing the same thing (select_or_other, cck_select_other).

#4: Make sure all possible allowed values are in the list field

Don't use a custom table to store allowed values. Set the allowed values in list field configuration. Write a field widget plugin.

Write your own Field Widget that restricts options based on some other parameter like your query.

#5: Override Core handling of list field plugins with your own implementation

Use hook_field_info_alter to not use Core code at all. Write your own List Field Type plugin with a better Options or Allowed Values implementation.

Risks

May confuse a development team inheriting the site.
All list fields now behave this way.


role delegation module : how to fine-tune the 'edit-administer-users' permissions?

The two modules you will need:

Rules:

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules). It's a replacement with more features for the trigger module
  in core and the successor of the Drupal 5 workflow-ng module.

and Context Redirect:

  This module provides a Context reaction which redirects to a given
  internal or external url if the context conditions are met.

  You could use this module to redirect users of specific roles to a
  page of your choice, or redirect them based on a path in the site
  (node/2, 'page.htm') to another page or external URL
  (ht-p://www.google.com). Dozens of conditions can be cooked up with
  Context and redirect users to where they need to go.

set up a new rule, have it react on a url (based on whatever url you want to restrict)
set a condition that the user be of the role for which you are trying to limit access
set an action - presumably a redirect to a different page, or perhaps a custom page that tells them they don't have permission to view that url


Can't find the place to add in image caption

The project page is somehow missleading and most of the info there is for D6 version. But at the bottom, it clearly states:

jQuery caption
  Less module code
  No configuration needed
  Better javascript captioning logic

You can also refer to this issue for more info.


Is there any drupal module to export/import all ubercart products with product details(attributes)

I would use start by having a look at UberCart Feeds with  uc_feeds_product_importer  they should help you get the job done.


How to overwrite Paragraphs Item on subpages?

Instead of putting it into the template, a better solution would be to use the hook_entity_view_alter to add the classes based on some conditions.


How can I make content type appear as a table?

Use the Views module to show all your Students in a view and then with the help of the Views link area module create a link to Create Students.

  The Link Area module provides an "area plugin" for Views 3. It allows
  customized links to be placed in the header, footer, or empty text of
  any view.

  The obvious use case is to create a list of all nodes of type "foo"
  and then add a header link to the node/add/foo page. By making it a
  real link rather than just a blob of HTML in a header text area it
  gets all of the special handling and clean URL friendliness and
  base-path portability that any Drupal link gets.


in hook_init, removing the first slash should solve the problem. If not, check for permissions.

drupal_add_css("/".drupal_get_path('module', 'mymodule') . '/style.css');

Should be

drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css');


How to get form values in URL as keys of an array

Try adding:

$form['price']['#tree'] = TRUE;

This tells the form builder you want to nest field names. Otherwise it will just use the most immediate element keys for the field names, as you have found.

This is actually useful behaviour most of the time, as it means you can group fields in containers such as fieldsets without affecting their name attributes.


$block = module_invoke('module_name', 'block_view', 'block_id');

  $form['block'] = array(
    '#markup' => render($block),
  );


Add CSS class to  element using webform and template file

I believe your edit is correct. You should add the class in a preprocessor function within template.php.

A similar question and answer can be found here.


Drupal 7 Views Multiple Jump Menus in single page not working

I did not get any help from community as well for the solution of this. I have to customized the code which resolved my issue. I have to put the form_alter hook for that jump menu form and apply

$form['jump']['#attributes']['onChange'] = 'javascript:location.href = this.value; return false;';

Hope this helps you guys.


How do I hide the download button on the audio player?

Create a subtheme if you haven't already.
Find the file core/modules/file/templates/file-audio.html.twig and copy it to your subtheme's templates directory.
Edit the following line in the file.

Original line:

<audio {{ attributes }}>

Change it to this:

<audio {{ attributes }} controlsList="nodownload">


Views: sort criteria -> Post date, not start from latest but latest-3

Yes, in the Use Pager options, you can specify an offset, which by default is 0, but can be any number, which, amusingly, in the help section offers:

The number of items to skip. For example, if this field is 3, the first 3 items will be skipped and not displayed.


In hook_ENTITY_TYPE_view which you use to render your pseudo field there already is the $entity available. Which in your case must be a node object. You simply can get any field value from there.

So all you need to do is to add a Drupal default checkbox/boolean field to your content type, from the UI probably, hide it from display, and then output your pseudo field depending on its value, per node.

/**
 * Implements hook_entity_extra_field_info().
 */
function MYMODULE_entity_extra_field_info() {

  $extra['node']['article']['display']['foo_bar'] = [
    'label'       => t('My pseudo field'),
    'description' => t('My pseudo field description.'),
    'weight'      => 0,
    'visible'     => TRUE,
  ];

  return $extra;
}

/**
 * Implements hook_ENTITY_TYPE_view().
 */
function MYMODULE_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

  if ($entity->bundle() == 'article') {

    // Get the choice.
    $editors_choice = $entity->field_editors_choice->first()->getValue();
    $editors_choice = isset($editors_choice['value']) ? $editors_choice['value'] : FALSE;

    // And fire accordingly.
    if ($display->getComponent('foo_bar') && $editors_choice) {
      $build['foo_bar'] = [
        '#markup' => 'This is my custom content',
      ];
    }
  }
}


writing form action path programmatically

The action is stored in the form's #action property, so assuming your form is represented by the $elements variable in the template, something like this should do it:

<form accept-charset="UTF-8" id="user-login-form" method="post" action="<?php echo $elements['#action']; ?>">


How to link the file icon to the file and to hide the filename?

The problem with generic file display is that icon is not linkable, therefor a CSS solution is useless.

So in order to make the icon linkable you need to create another file display formate or alter theme_file_link

My solution is to add additional display formate, code as follow:

/**
 * Implements hook_field_formatter_info().
 */
function mymodule_field_formatter_info() {
  return array(
    'mymodule_link_icon' => array(
      'label' => t('Linkable icon'),
      'field types' => array('file'),
    ),
  );
}

/**
 * Implements hook_field_formatter_view().
 */
function mymodule_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {

    case 'mymodule_link_icon':

      foreach ($items as $delta => $item) {

        $file = (object) $item;

        $url = file_create_url($file->uri);

        $icon_directory = variable_get('file_icon_directory', drupal_get_path('module', 'file') . '/icons');

        $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));

        $options['attributes']['title'] = check_plain($file->filename);

        $options['html'] = TRUE;

        $link_icon = '' . l($icon, $url, $options) . '';

        $element[$delta] = $element[$delta] = array('#markup' => $link_icon);
      }

      break;
  }

  return $element;
}

After you implement the above code in a module and enable it, make sure to change field formatter option in your view to Linkable icon


Drupal test runner (simpletest) has a few issues on Windows, including the inability to work with contributed database drivers (SQL Server).

As of today, exactly 3 patches are needed for this #2294731, #2748883, #2605284 (can't post the links due to not having reputation here...).

If you want to see a working example, this post explains how to run the Drupal test suite on AppVeyor that is a Windows based Continuous Integration Service.

http://www.drupalonwindows.com/en/blog/continuous-integration-and-testing-drupal-appveyor

There you will find an example cmd/powershell script with all commands needed to setup drupal and run the test suite (on windows) including commands to automatically apply the mentioned patches.


Drupal 7 permission to editor type user showing certain admin menus

sorry for being stupid. if you give the rights to "toolbar" in permission area. toolbar will show up :) you can also use Content access


jQuery dialog is duplicated when set on a form that uses AJAX

The behavior you describe is not related to the dialog function. From your provided code you can see that dialogs are created with all elements that have the identifier ".my-modal".

So I suppose within your AJAX call the original dialog element is not replaced by another version of the dialog, but a further element having the class "my-modal" is added to your markup.

You should investigate your AJAX callback function, whether it replaces the original markup or adds elements.


In Views template files you have access to the following objects:

$row
$fields['field_my_field_value']->row
$fields['field_my_file_value']->content

You do not have access to multiple image objects in your case. You should call an external function to retrieve data for each item.

$arg = (object) array(
  'type' => $fields['type']->raw,
  'vid' => $fields['vid']->raw,
);
$files = filefield_get_node_files($arg);

foreach ($files as $file) {
  print theme('imagecache', 'preview_body', $file['filepath']);
}


How do I add an ID to the ul tag of a menu?

You can make use of theme_menu_tree

function theme_menu_tree($variables) {
  return '
' . $variables['tree'] . '
';
}

http://api.drupal.org/api/drupal/includes%21menu.inc/function/theme_menu_tree/7

You can print this menu tree

template_preprocess_menu_tree

hereis api

Pre process the menu tree OR Call the menu theme to print it as you want.
Thats all.


Require visitor to fill a form to view contents

I don't have experience with the Webform module, but I think that you could create a rule to grant access to a referenced node when the user submits the form.

Basically, you need to add an entity reference field to the webform content type, reference the webform with the particular node, and create a rule that on the form submission event grants the current user access to the referenced node.
In Content Access and ACL, you should set the access per-node and per-user.

You'll need Entity reference, Webform, Rules, Webform Rules, Content Access and ACL modules.


Calendar widget link to list a day's events

I have got it: If you go to the Day view under the Calendar view, you can change the format to HTML list and show fields. From there, add the fields of the calendar event you want to show.


Add bootstrap button to rewrite output views

It might not be what you need, but in Bootstrap you can create buttons using the <a> anchor, which will not be filtered out by Views.

  <a class="btn btn-default" href="#">
        [clone_node]
  </a>


Looks like you did all the steps correctly, How To Create Combined Search Filters In Views?, which leads me to believe that this is a bug.

Upon looking at the View's issues, I found Combined fields filter not working with entity reference.

Therefore, you will have to use it as a standalone, not combined, filter until this bug is fixed, which does not look like it will be any time soon.


How to add Span before my <a tag only for main menu 1st level items

you have forgotten the '#' before localized_options, title & href.

function mytheme_menu_link($link) {
  if (empty($link['#localized_options'])) {
    $link['#localized_options'] = array();
  }

  $link['#localized_options']['html'] = TRUE; //let l function know that our link title includes html
  return '<span>'.l($link['#title'], $link['#href'], $link['#localized_options']).'</span>';
}

for main menue only use theme_menu_link__main_menu($var)


IF the current version of Drupal is working out for you and you don't need more features added than you can stick around on 7 for a long time.

The problem is that D7 will not receive any feature updates and most modules will not be updated for D7 aswell.

It is hard to say the exact date of when D7 will not be supported anymore but most likely in 3-4 years.

but the bug/security fixes will continue till the end of this year most likely.

source: https://www.ostraining.com/blog/drupal/drupal-7-end-of-life/


You can try the Ultimenu module. It has Drupal 8 version too and it's stable.

https://www.drupal.org/project/ultimenu

  Ultimenu is the UltimatelyDeadSimple™ megamenu ever with dynamic
  region creation.

  The module manages the toggle of Ultimenu blocks, regions, and a skins
  library, while leaving the management of block, menu and regions to
  Drupal.


Is it possible to modify help text on a vocabulary page?

When creating a vocabulary you have the option of turning on/off the ability to arrange terms in a hierarchy. If you choose "Single Hierarchy" for example then the help text will change to read: "VOCAB contains terms grouped under parent terms. You can reorganize the terms in VOCAB using their drag-and-drop handles."

See http://cgit.drupalcode.org/drupal/tree/core/modules/taxonomy/taxonomy.module#n78

... Otherwise you can create a custom module that implements hook_help and check for $route_name = entity.taxonomy_vocabulary.overview_form. As long as your module's hook_help fires after taxonomy_help() your's should win. See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension%21module.api.php/function/hook_module_implements_alter/8.4.x to control whose module wins when implementing a hook


How to send the emails related to the user account in HTML?

The mimemail module is what usually would be the right solution for this, but is seems to contain an error, so that it does'nt add HTML to the user account mails.

Check issue here, mimemail issue.


How to set default form values based on query string, if the form uses AJAX file upload

I forgot to post the answer.

To keep the data persistent between AJAX calls, you should store it in the $form_state variable. This is how it worked in my case:

Check if I already have the data in $form_state.
If not and if there is query string, get the data, sanitize/validate it and store in $form_state.

This way it works even for AJAX calls where query string parameters are not available.


Did you try drush @site help?  Simply running drush help will show only the globally-available commands; you must change your working directory to the folder with your settings.php file or use a site alias to select a specific site to see the help for drush commands defined in that site's module.

Sometimes, the Drush command cache can get in your way.  Run drush cc drush to reset it.  Since drush @site bam-destinations is working, this is probably not your issue.

If you are still having trouble after trying these things, also try upgrading to the latest version of Drush (HEAD of master), as some fixes that may be related have been committed post-Drush-5.4.  Also try drush @site help bam-destinations and drush @site bam-destinations --help.  If you're still having trouble, please post a bug report in the Drush issue queue.


Referencing logged user and node relations.

I dont use Rules Link alot, I have used Rules Link Event and Rules. Anyways this issue queue item for Rules Link describes how to setup Parameters for a Rules Link:

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

From the issue:

  For your example, add the product sku field to your view and pass the
  token for that in the views rules link field settings under:
  Additional parameters for the rules link

  Edit the rules link component, click the configure rules tab, under
  settings, add the additional parameter. I assume it could be string,
  integer or whatever that matches your sku. The view is going to pass
  that parameter as a variable to use in the rules link component rules
  so you can do whatever you want with it from there.

The issue queue explains adding 1 parameter. but it does sound like it supports additional parameters to send to Rules, so just assure your View is passing 2 parameters instead of just the 1 in the Additional Parameters.


Drupal CSS is not loading after server move

This doesn't really sound like a Drupal-specific question. That link doesn't even point to a Drupal contrib module.. Have you tried running through the install instructions again?

If you haven't "SmartOptimizer needs write access to smartoptimzer/cache folder. Make sure it's writable." looks pretty telling.


Role that can set roles but not change its own

It really sounds like there should be a module that does this ... I'm not aware of 1 offhand.

You could use hook_form_alter on the user account form and simply check the role of the logged in user. If they are Staff allow them to set roles to all but the Admin role you've defined. You would simply unset() the admin value in the $options array for the Roles checkboxes.

For example:

function MYMODULE_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  if (array_search('Staff', $user->roles)) {
    // Any RIDs you want to remove.
    unset($form['account']['roles']['#options'][3]);
  }
}

You would also probably want to add a validator to this form to check that a Staff user does not try to get around this by setting this value for instance via Firefox's Firebug. I leave that exercise to you.


Why are we using utf8mb4_general_ci and not utf8mb4_unicode_ci?

It seems to me that the recommendation is outdated and that  utf8mb4_unicode_ci will work without problems. It has been used by a lot of people for a long time.

There is a difference between changing the character set from utf8 to utf8mb4 (to support more codepoints) and changing the collation from general_ci to unicode_ci (to get more accurate sorting). Both changes can cause their own problems, so doing both independently makes sense.

utf8mb4 is used by default since 8.0.0-beta12. The main issue seemed to be a change of key lengths limitations for InnoDB but as I understand it, utf8mb4 should have worked with the default MyISAM engine even before that change.

Switching to unicode_ci shouldn't cause problems, but may unexpectedly changes the order of sorting for some sites.

The default collation setting is just a default and modules can choose their own collations anyway if they need to. I also haven't found any documentation that says modules should expect a certain collation. The database install guide just lacks a clear statement about which collations are supported and is inconsistent:

In the section about phpMyAdmin it says that you have to

  Make sure you select COLLATION utf8_general_ci

Later in the section about installation from command line, general_ci doesn't seem to be required and any UTF-8 collation will do:

  Note: The database should be created with UTF-8 (Unicode) encoding, for example utf8_general_ci.

Furthermore, PostgreSQL is supported and it seems its default UTF-8 collation is equivalent to utf8mb4_unicode_ci, so using that with MySQL should be fine too.


Migrate nodes with special characters in title

It looks like you will have to define a custom process plugin to do this - I can't find any plugin for it on this or this page.

There is a PHP function called htmlspecialchars_decode, which decodes all HTML special character entities, which you can probably use. It takes in a string and returns the decoded string. We also need to pass it the ENT_QUOTES flag for it to convert both double and single quotes.

So you could probably do something like:

namespace Drupal\YOUR_MODULE\Plugin\migrate\process;

use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 * Decode HTML entities.
 *
 * @MigrateProcessPlugin(
 *   id = "decode_html_entities"
 * )
 */
class DecodeHtmlEntityString extends ProcessPluginBase {

  public function transform(string $value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    return htmlspecialchars_decode($value, ENT_QUOTES);
  }

}


How to make a Shortcuts menu that open with new window or tab?

Shortcuts are menu items, so you might be able to use Menu Attributes to set the target to _blank.


Changing URL alias for search module action

I've had a lot of misery trying to customise the URLs for the search module so I feel your pain!

It's a submit handler that redirects to the search/node page so you'll need to add your own handler to override the redirect:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_form') {
    $form['#action'] = 'search';
    $form['#submit'][] = 'MYMODULE_search_form_submit';
  }
  else if ($form_id == 'search_box_form' || $form_id == 'search_theme_form') {
    $form['#submit'][] = 'MYMODULE_search_form_submit';
  }
}

function MYMODULE_search_form_submit(&$form, &$form_state) {
  $default = search_get_default_module_info();
  $form_state['redirect'] = str_replace("$default[module]/", '', $form_state['redirect']);
}

That code comes from a module who's sole purpose is to allow users to search at search/string rather than search/node/string so you'll probably need to change a couple of things to match your alias settings, but it might help start you off.

Here's a bit of extra code that's used to override the search URL using a hook_menu_alter():

function MYMODULE_menu_alter(&$items) {
  drupal_static_reset('search_get_info');
  $default_info = search_get_default_module_info();
  if ($default_info) {
    foreach (search_get_info() as $module => $search_info) {
      $path = 'search/' . $search_info['path'];
      unset($items[$path]);
      unset($items["$path/%menu_tail"]);
    }

    $items['search/%menu_tail'] = array(
      'title' => 'Search',
      'load arguments' => array('%map', '%index'),
      'page callback' => 'search_view',
      'page arguments' => array($default_info['module'], 1),
      'access callback' => '_search_menu_access',
      'access arguments' => array($default_info['module']),
      'type' => MENU_CALLBACK,
      'file' => drupal_get_path('module', 'search') . '/search.pages.inc'
    );
  }
}

It basically removes the menu items for the search path and replaces them with a single one. It's only useful in very specific conditions (i.e. when you've only got one search type enabled) but it's something to go off at least.


Based on the comments, I think the issue is that your user needs the "Use the administration pages and help" permission, under the System category.


The directory tmp does not exist and could not be created

You didn't mention the actual (complete) value for the path of the "Temporary directory" you want to use. But something that should work, pretty sure, is like so:

Navigate (in your web browser) to relative path admin/config/media/file-system.
Copy the value you have entered for "Public file system path", assume it's some/path/files.
Paste the copied value (like some/path/files) in the field "Temporary directory", and append to that value something like /temp, so that it becomes something like  some/path/files/temp/
Hit the Save configuration button and you should be good to go (Drupal will, automagically, take care of the rest).


Exposed filters do create/update the page URL. You can construct a link with a combination of values for your Exposed filters and the Views results will react to it by displaying the "correct" results narrowed down to what is set in the URL.

The confusion you're having is the Ajax option. Ajax (asynchronous JavaScript and XML) option fetches only a particular part of the page data and replaces the old set of that part of the page.

Ajax doesn't reload the entire page.

URL requests are related to entire pages, the URL in your browser can't change without a Page Reload/Refresh.

The Ajax option in Views even tells you:

  Options such as paging, table sorting, and exposed filters will not initiate a page refresh.

With Ajax option turned on the Exposed filters are still working correctly, you get changes in your results based on the applied Exposed filters. But the changes happen without the page reloading so the URL doesn't change. It can be confusing if you at that moment compare the currently enabled Exposed filter options with the Exposed filter values in the URL, because they won't match. But that is just the circumstances of using Ajax.

With Ajax on you get better responsiveness/speed just because there is no page reloading, but the URL might be misleading, if that is what your users pay attention to at that moment.

But turning Ajax on doesn't prevent you from constructing specific Exposed filter combinations in URLs!

You can create different URLs for a Views page, add them to a menu, when the user clicks on it they will get the filtered out results and the Exposed form options will match the URL ones. Then users can interact with the Exposed form and with Ajax on the URL will not change but the results will.

Without the Ajax option turned on each change in the Exposed form will trigger a page reload, which makes things less interactive/fast, but the URL options will match what you see on the Exposed form.


You can display image using following URL:

/drupal/xxxx/sites/default/files/background.jpg

This is for your local setup. While migrating your drupal setup to production at root directory, your image url will break, because of directory change. To avoid this, you will need to change the path of image as below:

/sites/default/files/background.jpg

You can fix this broken your without changing the URL at production by using Pathologic. After Installing this module, you will need to enable Pathologic filter by checking Correct URLs with Pathologic in Text Formats e.g Full HTML. Then select Correct URLs with Pathologic tab from vertical tabs & Path relative to server root (/foo/bar) radio option. Add following values in the text area & save.

/drupal/xxxx/
/


Showing content of subterm under parent term

This may not be the most standard way of achieving it but it may help in your case.
Just try the following code by replacing 24 with a $termid that exists in your case. And see if this gets your work done.

    //to get the children of a taxonomy term
    //lets take 24 for example

      $terms = taxonomy_get_children('24');

      //to get the nodes associated with a termid

     foreach ($terms as $term) {
         $termnodes = taxonomy_select_nodes($term->tid);

         foreach ($termnodes as $termnode) {
              $node = node_load($termnode);
              $node_output = node_view($node);
              print render($node_output, $view_mode = 'teaser'));
        }
  }


Go to admin/structure/views/settings, check Show information and statistics about the view during live preview and then Show the SQL query checkbox that will appear below.


How can I translate the checkout system?

In importing translation page /admin/config/regional/translate/import I have chosen "Drupal commerce"in Text group section. The process went fine, but the words to translate were indeed in Bult-in interface. So I imported the same file again but now choosing "Bult-in interface" in Text group section. Now I have checkout system translated at some degree.

I think perhaps because I installed Commerce Kickstart 2 and Drupal Commerce comes all in Built-in interface.


Entitybrower access denied for non-admin user

There's a separate permission for entity browsers - on the permissions page (/admin/people/permissions), they're grouped under Entity Browser. You'll need to give any roles that will use the browser the Access [My Browser] pages permission.


Printer: Is it possible to show print PDF and ePub url link for each node on Views?

Yes, add a global text field and under Rewrite Results select output this field as link and give the path eg. for PDF it should be printpdf/[nid].

similarly you can create one more  field for EPUB using printepub/[nid].

Note [nid] is a replacement pattern, you should add nid before these fields and exclude it from display.


Search snippet does not appear in Search API search page

It appears that Create Excerpt was the option that was not allowing the search snippet to appear. After I disabled it, everything worked as expected. Should have done my homework better :-/


If you have access to your ssh console, you can use cron

crontab -e

Then you put inside, at the bottom:

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0 14 * * * cd /var/www/drupal && drush cc all

the above will clear the cache with drush everyday at 2pm.

A few notes:

replace cd /var/www/drupal with the actual path to your drupal.
I believe the default runs at UTC time.
You need to install drush if you haven't already.

An alternative to using Drush, you could create a PHP or Python or NodeJS etc.. file that uses mysql to delete the row that holds the page cache in your DB, and run the file with cron at 2pm.


Validation constraints on form fields ignored

Turns out I was trying too hard. Typical beginner mistake. :)  I threw out the code above, and started from scratch. I replaced everything with the code examples in this tutorial: https://www.drupal.org/docs/8/api/entity-validation-api/providing-a-custom-validation-constraint

Within the validator, I replaced if (!is_int($item->value)) with  if ($item->value == "Value one" || "value two"), to get what I needed to validate on. Then I modified the variable names, field names and error messages to suit my needs. It only handles one field, but gets me closer to what I need.


Easy way to add EU cookie notification to multiple Drupal websites?

Check out EU Cookie Compliance for your notifications.

  This module intends to deal with the EU Directive on Privacy and
  Electronic Communications that comes into effect in the UK on 26th May
  2012. From this date on, you run the risk of enforcement action if you are not compliant or visibly working towards compliance.

Automating the process however is quite localised depending on your server setup, and would probably be considered off topic.


Importing pre-built content into the site

Creating a feature could be what you need. Have a look at its project page. https://www.drupal.org/project/features


Province/State list does not update when Country changes when set to "Dropdown" (Location Module)

A friend of mine worked on that issue a while ago, this was the link to the issue. He is now using the Address Field module.
I'm personally using address field as well, the country - province/state selections work well in that module.


Placing block inside a node (positioning block between specific elements in node's content)

Give the Block reference module a try.

  Defines a field type Block reference which creates a relationship to a
  block and allows the block to be displayed as the content of the
  field.


Filter node link in the menu by term tid

It's a bit unclear what you want to do exactly. Hope this is an answer to your question.

You will have to work with views. Attach the car terms to your articles or vice versa.Then add the term id as a contextual filter. You will be able to output a list with articles specific to your cars or cars that have a specific article.


Where does the style guide get generated?

Once you run gulp, the style guide will be generated in

  /path/to/your/theme/styleguide/

Just open the index.html file in your browser to view the contents.


How to move a form field inside a container

The fieldset is added by the theme_date_combo() function, which is on the element itself, not the wrapper (i.e. $form['field_birthday']).

To get this to work you'll need to temporarily move the Show Birthday field into the date_combo field, like so:

function MYMODULE_form_article_node_form_alter(&$form, &$form_state, $form_id) {
  $form['field_birthday'][LANGUAGE_NONE][0]['field_show_birthday'] = $form['field_show_birthday'];
  unset($form['field_show_birthday']);

  $form['#validate'][] = 'MYMODULE_article_node_form_validate';
}

Importantly, you'll also need to move that field back to where it originally was when the node form is validated. You won't get any errors if you don't, but the field_birthday value simply won't be saved.

function MYMODULE_article_node_form_validate(&$form, &$form_state) {
  $form_state['values']['field_show_birthday'] = $form_state['values']['field_birthday'][LANGUAGE_NONE][0]['field_show_birthday'];
  unset($form_state['values']['field_birthday'][LANGUAGE_NONE][0]['field_show_birthday']);
}

The above assumes you're making changes to the Article node form, just replace article with the name of your content type in the code. If your fields are inside another fieldset you might need to dig a bit further into the form array to find out how to access the precise field, but the logic will remain the same.

This is the result I get with that code (using admin theme):

I've tested both add and edit node forms and they seem to work perfectly using this method.


By page ID I guess you mean the page path? There isn't a hook like the one you've suggested but you can do basically the same thing in a standard hook_page_alter() like so:

function MYMODULE_page_alter(&$page) {
  if ($_GET['q'] == 'node/1') {
    // Do something for node 1
  }
  else if ($_GET['q'] == 'admin') {
    // Do something for the root admin page
  }
}


jQuery stops working in a ahah wrapper div returned as json data

Not really a Drupal question, but the slider is created in Javascript on the document.ready -event which can't as such be triggered manually.

When you fetch a piece of content via ajax to the page, it just replaces the html, but does not attach any event handlers or run any document.ready -code. You need to handle that explicitly.

What I'd do is I'd check out what function EasySlider calls on document.ready and just repeat that call after the ajax content is fetched.


Use the html.tpl.php of your theme to add the noscript tag using the $scripts array.

$scripts = str_replace("\n", "\n<noscript>Your browser does not support Javascript</noscript>\n", $scripts);

Note : html.tpl.php will apply this for all pages of your theme.if you want to do it for specific content type pages or specific pages then use the specific template.See Drupal 7 template suggestions for more information.


How to restrict direct access to the nodes?

A simple solution would be to not publish the nodes you don't want to be accessible. Views can still pull the data from those nodes.


Below is a blueprint of how I'd implement what you're looking for. It can work for both D7 and D8 ...

Sub-level 1

You could, for sure, use the Group module for this. Group allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections. It is available as of D7, and has a D8 version also. It is designed to be an alternative to Organic Groups. The Group module creates groups as entities, making them fully fieldable, extensible and exportable.

For more details about the various roles and permissions, refer to my answer to "What are the various roles supported by the Group module?".

Resources:

Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".

Sub-level 2

Option 1

You could use one or more taxonomies to implement "Subject". E.g. 1 taxonomy for each area, each of them with 3 terms. As a variation, a single taxonomy (used by all areas) with up to 9 (different) terms could also work.

Option 2

As an alternative to using taxonomies/terms, you could also use the Entity Reference module (included in D8 core). Here is a possible solution to do so:

create a content type (say) "Subject", and add any "field" to it you might need (now or in the future).
create 9 nodes of type "Subject".
for the content type you use for your "nodes" (in your picture), add a field that implements an entity reference to your "Subject" nodes.

Nodes

That's pretty forward, just pick an appropriate content type for those nodes you want to create. One could argue if you yes or no want to use the same content type for the nodes of the various areas. But unless you have a need for different fields of those nodes for the various areas, I don't see any reason to have like a different content type for each area. Also because if you want to impose access rules for those nodes in the various areas, you'd do so using the Group module.

Bonus

Everything above is based on using entities. With that you also have all sorts of bonus options to further refine your implementation using out-of-the-box facilities with modules such as:

Views.
Rules.
Flag.
Message.


Can't get narrow stylesheet to load in Omega commerce sub-sub-theme

So it turns out freshstop-omega-alpha-default-narrow.css actually IS being added, just not at the breakpoint that I expected.

The problem is that I'm thinking from a more "mobile second" perspective. Here's the stylesheet cascade:

global.css
example-alpha-default.css
example-alpha-default-narrow.css
example-alpha-default-normal.css
example-alpha-default-wide.css

"Narrow" is included at 720px and wider, while global.css is included at all sizes. If one wants to target just mobile or smaller, one would have to create a new media query.

More information here: https://groups.drupal.org/node/156719


I think you should this in this way, so you should register you theme hook


Making all REST Server calls to Drupal site as an authenticated user through Services

You can use jdrupal.min.js. and set variables as follows in your js:

 Drupal.settings.site_path = "http://example.com"; // SET Drupal site Path
 Drupal.settings.endpoint = "services_endpoint_name";  // Set the Service Resource REST endpoint path FROM services module in Drupal site.

and you can use directly functions for for doing operation such as:

user_login(username, password, {
                        success: function (result) {
                          cosole.log(result);
                        },
                        error: function (xhr, status, message) {
                            console.log(status +" Error Message"+ message)
                        }
                    });

If login successful then you are logged in with the authenticated user in your Drupal site. And also you can do number of operations node save, update, delete etc.


Is there a downside of having too many features?

I'll jump in with an answer, though I agree with others that there is probably no single correct way.

My experience with features is that large features become very difficult to manage. Even one-feature-to-rule-all isn't a great answer, though it obviously reduces the conflicts possible, though that helps, because of the management of all those individual elements becomes hard.

In the past I have attempted to keep one "feature-module" for each aspect-feature of the site - so for example one feature describing a content type, and the views using it, and the rules, etc. Sometimes this is essentially one page, sometimes more. I have also tried larger groupings - bad idea - but not so far smaller ones (one for the actual CT, another for the view, etc.

The aspect of 'too many modules' is real, though I have dealt with perfectly functional sites with >200 (non-features) modules active. A mitigation you could use is for the live system to run with the features modules disabled, because their effect should be in the database and so the code is not needed. I haven't tried this, though.

From this experience I think that the choice should be to keep the scope of each feature small and very, very well defined. Most of the time I have got into trouble it has resulted from some aspect of a feature that is on the border between several elements -- it should probably have been its own thing not lumped into other things.

So: smaller features with very well defined scope for each.


Although and older issue, it's worth noting that system/files is normal for Drupal private file mode paths.

That is because system/files is the logical application path that handles and routes to the file on the actual file system.

It is this logical path that allows the additional authentication checks that private file mode allows.

You can put your private files under sites/default/files/private and Drupal will automatically create an .htaccess file to deny direct web access to them.

However, for safety, it's recommended to put your private files directory outside the html web root. For example, one level up from your website document root, or some other designated folder.

If curious private files are served via system_menu which defines the system/files url callback to file_download.

Following that hook_file_download is used to provide access control to the requested private file.


Install profile installation fails with "Base table or [error] view not found: 1146 Table 'xxx.system' doesn't exist'" on aegir

The reason for this obscure error message was that I had defined a dependency in the installation profile, but the module was missing. After removing the not-existing module from the profile.info-file the installation went smooth.


Sticky Navigation 8.x-1.1. Funny padding-top

So far my solution was to apply CSS + jQuery to me theme:

CSS

body.js--padding-fix {
   padding-top:0 !important;
}

and JQUERY

jQuery(document).ready(function () {
    if (jQuery('div.primary-menu-container-global').hasClass('stickynav-active'))
    {
        jQuery('body').addClass('js--padding-fix');
    }
});

Note: if you apply the CSS directly to the body tag, it creates a problem with the Admin Menu, that covers the top of the site (minimized this way)

Is there a better solution?


First, PHP is case sensitive - don't start your function names with capital letters, it's bad practice, capitals are generally reserved for Classes.

Secondly, if you haven't already, install the devel module, it's really useful.

Then you can look at the structure of the $comment object that is passed to the hook by putting dpm($comment); inside your hook.  Make sure you give yourself the permission to view devel information.

Once you can see the structure of the variable it should make sense what drupal is doing with it.  You can add a new element to the form simply by editing the $comment variable:

$comment[#myNewElement] = array(
  'property1' => 'value1',
  'property2' => 'value2',
  'property3' => 'value3',
);

You can learn about the various form elements and their properties at the Drupal form API.

You will probably need to query the database to get your display value before you set the element.

Happy coding!


How do you use forms to populate content type fields?

You seem to be going in a slightly wrong direction with this (until I'm missing or not understanding something). If your goal is to create a node based on the data users send via a custom form then it can be done in the form submit handler. Fields added via the GUI don't need separate handling. For example if you are using node_save() then adding a custom field value could look similar to this:

$node->language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled.
$node->field_name[$node->language][0]['value'] = $form_state['values']['name'];

and with drupal_form_submit():

$new_form_state['values']['field_name'][$node->language][0]['value'] = $form_state['values']['name'];

There's a solid amount of information available about this on the web that you might want to check out for further assistance (like this, this and this).


How to fix Bootstrap theme overlapping on views administration pages

It is possible to set the admin theme just for views in the views settings page: admin/structure/views/settings. "Custom admin theme for the Views UI".

This does not fix the bootstrap theme problem, but it does solve my problem where I want to use the bootstrap theme for content administration actions.

Secondly, to solve my problem where I want a consistent user interface when viewing and editing content under admin/appearance there is a setting

Use the administration theme when editing or creating content.

This enables me to provide people submitting content with the same experience as viewing.


How to list comments of certain node in a PHP

You can use the Views module to create custom lists of nodes, comments, users etc. In your case, you will need to:

create a view of comments
add a 'Feed' display
add a 'Contextual filter' for 'Comment: Nid' (this will allow you to specify the node ID in the url)
set the feed url to something like comments/%/rss, where the % is a placeholder for the Node ID
save the view

Now you can find an rss feed of comments for node 32 at http://example.com/comments/32/rss

Here is an export of such a view:

$view = new view;
$view->name = 'comments_rss';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'comments rss';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'comments rss';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'comment';
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = 1;
/* Field: Comment: Title */
$handler->display->display_options['fields']['subject']['id'] = 'subject';
$handler->display->display_options['fields']['subject']['table'] = 'comment';
$handler->display->display_options['fields']['subject']['field'] = 'subject';
$handler->display->display_options['fields']['subject']['label'] = '';
$handler->display->display_options['fields']['subject']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['subject']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['subject']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['subject']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['subject']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['subject']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['subject']['alter']['trim'] = 0;
$handler->display->display_options['fields']['subject']['alter']['html'] = 0;
$handler->display->display_options['fields']['subject']['hide_empty'] = 0;
$handler->display->display_options['fields']['subject']['empty_zero'] = 0;
$handler->display->display_options['fields']['subject']['link_to_comment'] = 1;
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Comment: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'comment';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'not found';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['nid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['nid']['not'] = 0;
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 0;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'comments/%';

/* Display: Feed */
$handler = $view->new_display('feed', 'Feed', 'feed');
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['style_plugin'] = 'rss';
$handler->display->display_options['row_plugin'] = 'comment_rss';
$handler->display->display_options['path'] = 'comments/%/rss';
$handler->display->display_options['displays'] = array(
  'default' => 'default',
  'page' => 'page',
);


what to fill in after $items in hook_field_is_empty

rgb is one of the column names defined by the field_example module's implementation of hook_field_schema():

function field_example_field_schema($field) {
  $columns = array(
    'rgb' => array('type' => 'varchar', 'length' => 7, 'not null' => FALSE),
  );
  $indexes = array(
    'rgb' => array('rgb'),
  );
  return array(
    'columns' => $columns,
    'indexes' => $indexes,
  );
}

These columns are the actual storage for your field's various values, and represent the columns you'll find in the field_data_* and field_revision_* tables in a normal Drupal installation.

In the case of the rgb field there's only one column, but for many fields there are multiple columns (for example the image field which besides a 'fid' (file id) column has 'alt' and others).

The $item passed to hook_field_is_empty() is the representation of an instance of your field attached to an entity...essentially it contains the values filled in (or not as the case may be) by the user.

All of the columns you define in hook_field_schema() will be available in $item in hook_field_is_empty()...you then use whatever custom logic you need to decide whether the field has been sufficiently completed for storage, and return a TRUE or FALSE to represent that.


Drilling down into an Entity Reference Field in Rules Actions

In my scattered experience with rules, a limitation on what data you can access is usually a safeguard because the data has not been confirmed to exist yet.  In the Rules conditions, create "entity has field" condition twice.

1) Rule Conditions > Entity has field
Data selector: node
Field: field-associated-brief

This is your entity reference field, and gives Rules the comfort of knowing the reference field is usable. Once you have the above conditions, rules will load up the referenced fields from your node

2) Rule Conditions > Entity has field
Data selector: node:field-associated-brief
Field: field-breif-recipients

3) Now the action is able to use the field confirmed in the conditions

Even if you do not think the conditions should be required, it is good practice to confirm you have the data before you try to use it.  Here is another person who had a very similar issue


No you don't uninstall the module first. You want to have the module enabled when updating to let possible database updates kick in. Which may be performed to update existing data/entities. If you already have the latest 1.x version installed you could simply do

$ composer require drupal/admin_toolbar to upgrade the module.
$ drush cr && drush -y updb to perform database updates.
And finally $ drush -y cex to export any eventually updated config.

If you don't have the latest 1.x version installed yet, it's better to upgrade incrementally. And to play really safe to also do two consecutive releases for that.

$ composer update drupal/admin_toolbar --with-dependencies && drush cr && drush -y updb && drush -y cex to first update to the latest 1.x version, followed by a release.
And then $ composer require drupal/admin_toolbar && drush cr && drush -y updb && drush -y cex to get the latest major upgrade, followed by another release.


How to add theme from github with composer

If you still want download theme from github, you can edit file composer.json by add more repository:

Add this code

 {
    "type": "package",
    "package": {
        "name": "forumone/gesso",
        "version": "2.0",
        "type":"drupal-theme",
        "source": {
            "url": "https://github.com/forumone/gesso.git",
            "type": "git",
            "reference": "8.x-2.x"
        }
    }
}

after

{
    "type": "composer",
    "url": "https://packages.drupal.org/8"
},

and run composer require "forumone/gesso"
 to download theme and update composer.lock.


How to style and add more fields to the bubble in a gmap field?

Quote from the Comparison of mapping modules:

GMap is considered a legacy module.

So maybe you want to have a look at the IP Geolocation Views & Maps module. Partial quote from its project page:

Despite what the name may suggest, IP Geolocation Views & Maps (IPGV&M) is first and foremost a mapping engine.
The module makes it very easy to create Views-based mapping solutions using the map renderer of your choice (Google, OpenLayers or Leaflet) with any location storage module of your choice, e.g.:

Get Locations,
Geofield,
Geolocation Field
Location.

This allows you to bring together modules and feature sets that without IPGV&M you would not be able to combine.
Like beautiful animated marker clustering on Google or Bing or Mapbox ... any of various map providers.
But more importantly IPGV&M adds some features you won't find as conveniently packaged elsewhere.
These include marker differentiation based on field values or ranges (2nd screenshot) with or without font icons, various centering options, super-imposing the current visitor's location, allowing multiple content types to be displayed on the same map, full screen button and mini-map inset (bottom screenshot), polygon support (Geofield), marker tags and tool tips and cross-highlighting of associated content on the page when markers are hovered (and vice versa).

Head over to its (impressive) project page for even more information about it. That project page also includes various screenshots.


This is best accomplished with Render Arrays. Please read Theming Node Form into Regions for a tutorial.


I also had the same problem, and it was related to mod_rewrite. I have enabled the mod_rewrite with the following command and the problem was fixed.

sudo a2enmod rewrite


Alter existing route to a different route for a specific content type node using RouteSubscriber

You need to change the _controller for the route, check this code:

<?php

namespace Drupal\drush_help\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    // Change the controller for the help page.
    if ($route = $collection->get('help.page')) {
      $route->setDefault('_controller', '\Drupal\drush_help\Controller\HelpController::helpPage');
    }
  }

}

In this case the route is altered to replace the Drupal help page for a custom controller.

If you want to see this in action go to check the code of the Drush Help module.

Disclosure: I'm the maintainer of the module Drush Help.


Are HTML strings translatable through admin/config/regional/translate?

After looking into this for a bit, here's what I've found so far.  t() runs everything through format_string(), which sanitizes/wipes out HTML such as the IMG tag.  Hopefully someone who understands this better is able to provide greater insight into how it all works.


Can we use panels for header and footer?

Panels takes over the "Content" region.

Panels everywhere takes over the entire page, and is the module that does what you want.

Some themes are listed on the PE page as "compatible", but all that means is that they ship with appropriate templates, which makes it easier to get started.

You can use any theme you want with PE, but you will likely want to provide your own site-template as alternative to the regular page.tpl.php which PE will disregard. Look at one or two of the themes that are listed on the PE page and their use of template to get started.


You can theme the webform.
Create a new file: webform-form-81.tpl.php (Replace the number 81 with the node ID of your webform)

Place this file in your sites theme directory (sites/all/themes/yourtheme/webform-form-81.tpl.php)

Inside this new webform-form-81.tpl.php file, insert the following code:

<col style="width: 50%" /> <col style="width: 50%" /> </colgroup>

    <?php print drupal_render($form['submitted']['name']); ?>

    <?php print drupal_render($form['submitted']['email']); ?>

    <?php print drupal_render($form['submitted']['phone']); ?>

    <?php print drupal_render($form['submitted']['notes']); ?>

<?php
// Always print out the entire $form. This renders the remaining pieces of the
// form that haven't yet been rendered above (buttons, hidden elements, etc).
print drupal_render_children($form);

Save the file, then clear your Drupal cache.
Refresh the page with the form on it.


How can I programmatically set the default export path?

It looks like configuration for the features module is managed in the features.settings configuration object. This settings can be viewed and change via drush.

Viewing the features configuration directory:

drush cget features.settings

Setting the features configuration directory:

drush cset features.settings export.folder "custom/features"


Private File System and Externally Modified Files

The files won't be served if the entry in the file_managed table for that file does not have the correct filesize.


The taxonomy_select_nodes() function has as default limit of unlimited, so if it's only returning 10 nodes, I would suspect that's all the nodes it was able to match against the provided taxonomy terms.

Note that this function will not return any unpublished nodes, nor return any nodes you do not have access to because of any node-access controlling modules.

Also note that taxonomy_select_nodes() only returns nodes that match $tid only - and not any of that term's children which might be what you are expecting.


domain-name.com/user and other URLS not loading

You should enable apache's rewrite mod. and then restart your apache server.
Then, goto configuration and check clean URL. After that your site will be using clean URL.


how to make a content type that ties to the user and user can only add one?

Instead of creating content types, I think you're better off using the profile module.

For Drupal 8 use the Profile Module

  The Profile module provides configurable user profiles.

  Multiple profile types may be created via the UI (e.g. a general
  profile + a customer profile), whereas the module provides separated
  permissions for those. Optionally, profile forms are shown during user
  account registration. Fields may be configured to be private - thus
  visible only to the profile owner and administrators. Profile types
  are displayed on the user view page, and can be configured through
  “Manage Display” on account settings.

Formerly known as Profile2 in drupal 7. Here is a video tutorial. Perhaps it's similar in Drupal 8?


Drupal 7 - access to page content in template.php

In page.tpl.php the content of the page is available in $page['content']. It seems that your are mixing two different concepts here: pages, any page on the site (including administration page, taxonomy terms page, and other not directly editable pages) and nodes, editable content. This can be rather confusing as a default Drupal installation provides a page content type. So you end up with page nodes, which are nodes of a the page content type.

The layout of the content of a page displaying a node, is handled in the node.tpl.php template. In this template, the body of the displayed node is available in $content['body'].

If you really need to access a field (handled using the Field API) of the node object ($node) from the page preprocess function in your template.php, you can use:

function THEME_preprocess_page(&$variables) {
    $node =& $variables['node'];
    $value = field_get_items('node', $node, 'FIELDNAME);
}


You can use the Flag module to allow users to select nodes. Flag integrates nicely with Views, so you can create a view of nodes flagged by the current user.


preprocess function call - $vars[node_title] does not work as a parameter, while $vars['node-title'] does

Always use quotes around a string literal array index. For example, $foo['bar'] is correct, while $foo[bar] is not. But why? It is common to encounter this kind of syntax in old scripts:

This is wrong, but it works. The reason is that this code has an undefined constant (bar) rather than a string ('bar' - notice the quotes). PHP may in the future define constants which, unfortunately for such code, have the same name. It works because PHP automatically converts a bare string (an unquoted string which does not correspond to any known symbol) into a string which contains the bare string. For instance, if there is no defined constant named bar, then PHP will substitute in the string 'bar' and use that.

See PHP:Arrays - Manual Chapter "Array do's and don'ts"


How to output content type title on page.tpl.php?

In D7 there is node_type_get_name

node_type_get_name($node)

Parameters

  $node: A node object or string that indicates the node type to return

Return value

  The node type name or FALSE if the node type is not found.


Views contextual filter - Contains search with taxonomy field

As per my understanding exposed filter works for this requirement. So maybe you can try combining contextual filter with exposed filter.

You can use the Views Filter Harmonizer module for that. Here is a quote about it (from its project page):

  Views Filter Harmonizer solves an operational foible with the Views
  module regarding filtering.

  Normally, when a Views field has been assigned both an exposed filter
  and a contextual filter, then both filters get applied to the View's
  results set -- always. This is not configurable behaviour. It's
  hard-coded.

  As a consequence, contradictory search clauses easily occur, causing a
  counter-intuitive user experience with some White Screens of
  Disillusionment. Since the contextual filter sets the "bounds" for the
  page, any filtering by the visitor through the exposed filter on that
  page can only narrow down the results set, not broaden it. In other
  words the exposed filter appears not to be working properly.

  This small module allows you to have a contextual filter argument
  apply only when there is no corresponding regular (exposed) filter
  value present.

  This is most common on initial page load. After that the contextual
  filters will silently retreat and let the exposed filter values as
  selected by the visitor do their thing without interfering.

  This means that you can take advantage of friendly URLs using
  contextual arguments instead of ugly and verbose query parameters. Put
  the URLs anywhere on your site, in emails and in newsletters to take
  visitors to tailored Views pages. Having arrived there, visitors may
  then further filter these pages to their heart's content using the
  View's regular filters you exposed. And they won't experience any odd
  behaviour.


How do I remove the active class in the main menu?

I had the same problem: the l() function automatically assigns an active class when a link is pointing to the current page.

I got around this using an (ugly) hack:

As noted in the documentation, $options['language'] is additionally compared with $language_url->language before assigning the active class.

So, the hack is to supply a deliberately incorrect language when calling l().

You can find out what the current language of your site is using dpm():

global $language_url;
dpm($language_url->language);

In my case, I know that the language of the site is definitely not und, so I appended array('language' => 'und') to my call to l():

l('link text', 'path/to/page', array('language' => 'und'))

After this, the a element no longer had the active class.


You should always enclose the table names with curly brackets. That way table prefix (if any) will be added automatically. It's better to use that way all the time.

This is how your query should look like:

SELECT nid FROM {node} WHERE type = 'page' ORDER BY created DESC.


When might a module's weight in the system table not affect its hook order?

If revisioning does not appear in the system table, it is considered not installed and hook implementations it provides are not executed.

Upon installation, the revisioning module updates its weight to 1, making its hook implementations run later than those of most other modules (which default to a weight of 0).

If you want to change the order in which implementations of a particular hook are executed, have a look at hook_module_implements_alter().


Template name convention for view mini pager

After having Inspected the code more carefully and having read the whole resources I found again I finally found out the I bumped in one nasty corner case.

First of all, reading the code for the views module I found out that the tut I posted in my question was wrong and that the right naming convention for the template file is: views-mini-pager--evento-view.tpl.php (where evento-view is the name of the view).

Then I wanted to try and write a function template (instead of using the .tpl.php file) and I struggled again in finding the right naming convention. Since the views_mini_pager return with theme('item-list', ...) I tried to hook that for my specific view without any luck (mytheme_item_list would work, but changes the html output for every object using the 'item_list'). I finally read more carefully Using the theme layer (Drupal 7.x) especially this:

  Drupal provides a few helpers to build complex HTML constructs easily. These are very useful features, and by using them it is easy to create a consistent look on tables and lists. The downside is that they are not readily accessible to a themer. Instead, they place code that should be at the presentation layer into the logic layer, and only advanced themers are able to do anything with it.
  These functions are more acceptable for administration pages.
  When creating output that is likely to be changed, it is best to avoid the use of these constructs and create the tables and lists with real HTML code. The forum themes are perfect examples of how to accomplish this and still create HTML code that is consistent.
  Function name suggestions with double underscores
  An even bigger problem with using common provided theme functions such as theme('item_list') is that a theme probably does not want to override every theme_item_list() for every list output by Drupal anywhere, but only the one in our module. Therefore, instead of simply theme('item_list'), we can use theme('item_list_mymodule_main', $items) which would make it possible for a theme to implement themename_item_list_mymodule_main() or themename_item_list__mymodule() to override item_list() only for that specific instance.

So I made the mytheme_views_mini_pager function in my template.php returning a theme('item_list__views_mini_pager') hook this with mytheme_item_list__views_mini_pager and all worked like a charm


The source for the header of (Catalog views)  is from a second view
(catalog terms view)      you can make changes there

make term id hidden and term name visible


Migrating compound data structures from XML

Migrate can help you with this.

You can extend XMLMigration and use MigrateSourceXML.

I have a partial stack exchange data import which uses this with code on github.


Try changing your footer to the following:

<?php
$link = l(t('To blog archive'), 'blog-archive');

print $link;
?>

References:

l();

t();


How to have two view panes in one Panel, so that selecting a node title in View A displays the content for that node in View B? Do I HAVE to use AJAX?

There is sort of a hackish way to implement such behavior, described on this answer: https://stackoverflow.com/a/1596756/1421920

In short, the answer suggests two displays of the same view, one with the titles on the left with exposed filters (hidden by CSS) and the other one with the acutal content of the nodes. Add JS to the titles to fill the other view's exposed filter (also hidden by CSS) and submit. The relevant node loads on the second view with AJAX.


Just some ideas:

I use the Fieldable Panels Panes a lot on smaller web page to add direct content to the Panel pane instead of having to create content for it first. FPP are entities. Maybe you can use for a user to add images (and text, files, etc.) to their profile page? Honestly, I've only used it on site building level.

I know about this module Classy Panel styles, but never used it. Maybe you can also set the permissions that users can use the pre-defined styles.

There is also a widget type module (as used in Atrium) where a user can move blocks (Panel panes) around. I don't have a link for that.


Cloned site pointing to original site's database - can this cause problems?

The only way this could cause problems would be if the filesystem became out of sync. Since you didn't create, edit, or delete any content, this shouldn't be the case. If you have anything running on a cron hook which creates files you may see 404s in your logs. An example of this would be something like boost or advagg which create cached html/css in the files dir. Even if this is the case however you will be fine once cron has run again from the live codebase.


How to add a assign a value to File Field Desciption through tokens

You can use: $form['#attached']['js']  in your form preprocess to add some javascript that will set the field values.


If you add node data in a preprocess hook, then you need to add the cache tag of the node:

$variables['node_title'] = [
  '#markup' => $node->getTitle(),
  '#cache' => [
    'tags' => $node->getCacheTags(),
  ],
];

If this node is from a route match, then you need to add a cache context for the route as well:

$node = \Drupal::routeMatch()->getParameter('node');
$variables['node_title'] = [
  '#markup' => $node->getTitle(),
  '#cache' => [
    'tags' => $node->getCacheTags(),
    'contexts' => ['route'],
  ],
];


Using a debugger to understand which function called another one is not necessary all the time. If you look at the documentation on api.drupal.org, for example for user_load_by_name(), you will notice the documentation shows the number of
functions calling it, which is also a link to a page listing them.

In the case of hooks, such as hook_field_info(), the documentation page shows how many functions are implementations of that hook, and the number of functions invoking that hook.

The page listing the hook implementations can sometimes include functions that are not hook implementations; the short function description shown in that list makes evident when a function is not really a hook implementation.

In some cases, the documentation page lists the functions that reference a function, such as in the case of system_batch_page().

The documentation on api.drupal.org includes some sections that describe a group of functions correlated to each other, for example in Batch operations. The list of all the groups is on Topics.

Other topics are linked in the API reference page.