Google shows node links instead of Custom URL

Not sure how google got to index the node/123 URLs. Do you use a sitemap?
I would install the Global Redirect module to make sure those URLs get redirected to the SEO optimized URLs.
Select the "canonical" tag option in the config for that module.

I wouldn't worry to much about the SEO impact, especially if it's a new site.


Drupal 7 - Show Child Taxonomies and content in current taxonomy

There are a lot of disabled views that come bundled with Views module (check the list of views). One of those disabled views is a replacement for taxonomy/term/%. So, enable it and do all the modifications you need.

You can attach to the header a view with the list of subcategories, and that would fit your needs.


What does Contextual Filters (in Views) serve for?

Contextual filters in Views 3 replaces the 'Arguments' of Views 2.

It's best used with paths as outlined in this video: http://nodeone.se/blogg/learn-views-with-nodeone-part-19-contextual-filters-with-paths.

By the sounds of it, the filtering of your view could do the same job.


How to redirect old url alias to new url alias?

You can use redirect module to redirect url from "old url" to "new url".

  This module allows you to specify a redirect from one path to another
  path or an external URL

There is also global redirect module which provide the same functionality.

  Checks the current URL for an alias and does a 301 redirect to it if    it is not being used.
  Checks the current URL for a trailing slash, removes it if present    and repeats check 1 with the new request.
  Checks if the current URL is the same as the site_frontpage and    redirects to the frontpage if there is a match.
  Checks if the Clean URLs feature is enabled and then checks the    current URL is being accessed using the clean method rather than the
  'unclean' method.
  Checks access to the URL. If the user does not have access to the    path, then no redirects are done. This helps avoid exposing private
  aliased node's.
  Make sure the case of the URL being accessed is the same as the one    set by the author/administrator. For example, if you set the alias
  "articles/cake-making" to node/123, then the user can access the
  alias with any combination of case.
  Most of the above options are configurable in the settings page. In    Drupal 5 you can access this after enabling the globalredirect_admin
  module. In Drupal 6, the settings page is bundled into the module


i18n translate vocabulary field description

You can localize the taxonomy description field out-of-the-box with the Entity Translation module.  While Entity Translation can be used in combination with the i18n suite of modules, note that you cannot use Entity Translation for taxonomy in conjunction with the i18n Taxonomy translation module; you must select one or the other.

If you use Entity Translation, to translate the taxonomy term names you will also need the Title module.


how to change login destination to front page

I think the Login Destination-module is what you're looking for! Easy to configure and works perfect!


It can be done with Path metatags module

  Path metatags module helps you to create metatags for any page with any selection rules and load any entity from the URL!


Hook to import entity data in custom module installation in Drupal 7

For one time import of data, when installing a module, use hook_install.  This can be used to populate the database just after tables are created, provided your module also implements hook_schema.

You do not want to use
hook_enable.  If you used this, the database would be re-populated every time the module was re-enabled after being temporary disabled.


How to hide Input Format Options and help text under a textarea?

You can use hook_form_alter in a custom module to do this.

For instance, in drupal 7:

// hook_form_alter function
function CUSTOM_MODULE_form_alter(&$form, &$form_state, $form_id) {
    // We want this on a specific node type
    if ($form_id == 'NODE_TYPE_node_form') {
        $form['#after_build'][] = 'CUSTOM_MODULE_NODE_TYPE_node_form_after_build';
    }
}

// afterbuild function
function CUSTOM_MODULE_NODE_TYPE_node_form_after_build($form) {
    // We want this on a specific field
    $form['YOUR_FIELD']['und']['0']['format']['#access'] = FALSE;
    return $form;
}


Adjusting Height of Panel Columns using CSS

to achieve this you need make use of CSS pseudo selectors and apply them in the correct element, a good approach can be this:

.panel-2col-bricks > .panel-panel:nth-child(2) .center-wrapper .panel-col-first,
.panel-2col-bricks > .panel-panel:nth-child(2) .center-wrapper .panel-col-last

You can see this in action in the link below:
https://codepen.io/anon/pen/xBZGGb


How to configure chosen on Form API with an entity_automcomplete widget?

I guess you can't becuase you are using and autocompelte widget, but module states:

  Chosen uses the Chosen jQuery plugin to make your  elements
  more user-friendly.

So you have to refactor your form to use a select element, not autocomplete.


How to patch core via drush-make when using a stub make file?

Include the core patch in the core stub makefile. Here is mine straight out of buildkit.

api = 2
core = 7.x

projects[drupal][type] = core
projects[drupal][version] = "7.39"

; Use vocabulary machine name for permissions
; http://drupal.org/node/995156
projects[drupal][patch][995156] = http://drupal.org/files/issues/995156-5_portable_taxonomy_permissions.patch

projects[example][type] = profile
projects[example][download][type] = git
projects[example][download][url] = git@github.com:Laudanum/example.git


Access field data from entity in block plugin

Try this:

public function build() {
  $query = \Drupal::entityQuery('node')
    ->condition('type', 'blog_post');
  $nids = $query->execute();

  $build = [];
  foreach ($nids as $nid) {
    $node = Node::load($nid);
    $build[] = $node->blog_summary->view();
  }
  return $build;
}


How do I change the rate modules output to "# of users like this"?

I haven't used the module. But looking at the code, you essentially need to override the preprocess function in the module which is used to generate the string.

Open rate.module in an editor and search for the text string that you are looking to change. In this case, this string would be something like "have voted", which should lead you to the function named rate_preprocess_rate_template_thumbs_up(). This is the function that you should look to override. You can see that the strings are added as part of two format_plural calls and should be straightforward to amend in the override function.

You can perform the override either from a custom module or from your theme's template.php file. Since the module is using a preprocess function to make its changes, I recommend using a process function (note the difference in name) when you override it. There should be plenty of documentation and examples available on drupal.org and drupalSE to aid you if you are unfamiliar with overriding.


How to add block to only user/uid and not user/uid/edit

Hope this will help you,

In Drupal 7,

You can achive it by enabling PHP filter module, which allows embedded PHP code/snippets to be evaluated. GO to admin > modules and enable PHP filter.

<?php
    global $user;
    if (arg(0) == 'user' && $user->uid == arg(1) && is_numeric(arg(1)) && (arg(2) == NULL) ){
      return TRUE;
    }
    else {
      return FALSE;
    }
?>

You can also refer Extended block visibility module. This will allows PHP block visibility to be defined in code.


What you are looking for is html.tpl.php which by default is part of the system module. Copy the file to the location of your theme and add your code. The copy should take precedence over the default .tpl file.

Warning: Do not hack the core! I.e. if you add this change directly to the system module file it will be overwritten with the next update. In fact even adding the file to the third party theme is not a very clean solution (for the same reasons).

Consider using drupal_add_js() instead (requires custom code).


Go to Checkout Complete without checkout payment

Seems like you're trying to create a Rules condition like so:

  if field field_cel_ck_scholar=TRUE

whereas you have such field added in your 'customer profile type'.

Looking at the rule you create so far, your Rules condition seems incomplete:

you already do have the entity_has_field, that's OK, and actually one (out of 2) ways to be able to create such condition like "if field field_cel_ck_scholar=TRUE".
your Rules condition seems to be missing the actual Data comparison condition, in which you actually specify that "if field field_cel_ck_scholar=TRUE".

So try adding such Data Comparison condition, and check if that solves your issue. Not sure if it will be the only reason why "It doesn't work", but for sure a reason why it cannot work.

PS: refer to my answer to the question about How to specify a Rules condition related to select list values? for a similar (though not duplicate) question, which includes some more details (and background info) about such entity_has_field.


How can I associate an advanced forum with an organic group?

I have struggled with this problem myself for some time and finally decided to just create a separate content type for my group forum topics and "create" a forum in each group with those topics.

I created a new content type called "Group Forum Topic." In Advanced Forum settings, I added this content type to the "node types to style" so that it would make it look like the forum.

On the og_content view, I added an additional block and named it "Group Forum topics" and I changed it to use the forum topic list format. Using the view from Advanced Forum (Topic list) as a template, I set up the view to display the "group forum topic" content like a forum.

This allowed me better control over the permissions -- I am using entityreference-prepopulate to prepopulate the group when they add the content and I have the group content set to private, so I know that the content will be kept private to the group.

I tried using other modules, but ran into issues with auto-selecting both the forum name and the group and didn't want to chance the user accidentally not selecting one of those things on their own. After a lot of testing and trying, this seemed to be the easiest solution to having a private group forum on the group page.

Keep in mind this does NOT create a listing for the forum on the forum index page. What I have done instead is add my group listings to my forum index page view, so that beneath my "regular" forums, I have a listing of "groups," which contain their private forums inside.

This is my first answer here and I know this question is old... but I ran across it when I was researching this issue myself and thought perhaps the next person looking for a resolution might find it and it might help them!


Updating taxonomy terms with vbo and workbench

The basic principle behind using Views to display the latest revision, instead of the published revision, is to base the view on the node_revision table instead of the node table. Unfortunately you cannot change the base table of an existing view, so you'll have to rebuild the entire view showing "Content revisions" instead of "Content".

To display only the current revision, use the filter criteria "Workbench Moderation: Current" on the node_revision table (otherwise all revisions will be displayed). To gain access to fields on the node itself, add a Relationship of "Workbench Moderation: Node" (and then be really careful you don't use this relationship unless you intend to reference the published node).

To avoid a potential security bypass in your view, you should also include the filter criteria "Content access: Access" on the Node relationship.

With all that plumbing out of the way, you should now be able to edit the taxonomy term field on the most recent revision of your nodes using "Content (historical data): [taxonomy field name]".


In Drupal, you already have that module. You just need to activate Statistic module and set the rights permissions to anonymous users. And maybe you might modify your node.tpl.php to show count information.

Also, this module provides you blocks that show the most viewed nodes in the day, all the time or right now.


node type not getting in search template

I took a look into the code and it seems to be that is not implemented. So maybe it's a bug or just mistake in the documentation.

At least, you can reach your goal with the hook_node_search_result or even with template_preprocess_search_result if you don't want create a module.

For information, the $info_split for node is filled by node_search_execute that call the hook said above.


You need to make the form ID dynamic, so that it is different for each instance on the page. As you're extending EntityForm, you'll have to extend it, then register your form on the node class, and finally call your form class.

Extend the entity form:
class MyEntityForm extends EntityForm {
  public function getFormId() {
    // The dynamic form ID allows for the form to be
    // reused on a page.
    return parent::getFormId() . '-' . $this->getEntity()->id();
  }
}

Register your form class on the node entity type:
/**
 * Implements hook_entity_type_alter().
 */
function HOOK_entity_type_alter(array &$entity_types) {
  $node = &$entity_types['node'];
  $node->setFormClass('my_form_type', 'Drupal\[MODULE]\Form\MyEntityForm');
}

Call your form from your controller:
  $form = \Drupal::service('entity.form_builder')->getForm($node, 'my_form_type');


Add items to batch queue operations on the fly

I was really quite close! As always, asking the question on here caused the answer to reveal itself.

function example_drush_sync_entries() {
  $batch = array(
    'operations' => array(
      array('_example_fetch_data', array())
    ),
    'finished' => '_example_batch_finished',
    'title' => t('Processing'),
    'progress_message' => '',
    'error_message' => t('The update has encountered an error.'),
  );

  batch_set($batch);
  $batch = &batch_get();
  $batch['progressive'] = FALSE;

  drush_backend_batch_process();
}

function _example_fetch_data(&$context) {
  $response = drupal_http_request('http://blah.com/data');
  $data = $response->data;
  $data = drupal_json_decode($data);

  $batch = &batch_get();
  $batch_next_set = $batch['current_set'] + 1;
  $batch_set = &$batch['sets'][$batch_next_set];
  foreach ($data as $entry) {
    $batch_set['operations'][] = array('_example_process_entry', array($entry));
  }
  $batch_set['total'] = count($batch_set['operations']);
  $batch_set['count'] = $batch_set['total'];

  _batch_populate_queue($batch, $batch_next_set);
}

function _example_process_entry($entry, &$context) {
  var_dump($entry['id']);
}

Notable differences:
* The operations need to be added to the next set, not the current one.
* You need to define a total and count, otherwise the percentage progress is considered 100% and, therefore, complete before it even starts.

I hope this helps other people :)


How to change placeholder title of search box?

By using hook_form_alter and/or any of its descendants, you are altering the placeholder everywhere and anywhere that the form occurs.

To isolate specific instances of the form, based on which region they are in, you can use hook_preprocess_page.

For example, in your template.php:

function yourthemename_preprocess_page(&$variables) {
  if (arg(1) == '92') {
     // Set the default value for the form in the header region.
    $variables['page']['header']['search_form']['search_block_form']['#attributes']['placeholder'] = t('abc');

     // Set the default value for the form in the content region.
    $variables['page']['content']['search_form']['search_block_form']['#attributes']['placeholder'] = t('def');
  }
}


If they only differ in color, you should provide a theme setting for choosing it and setup the theme in /themes/custom/mymulticolortheme, so it will become available for all sites. Otherwise you have to maintain multiple nearly identical themes, which is a time killer when you have to fix a bug or add a feature.

If you have different themes for each site you should place each theme in the particular site theme folder like /sites/site1/themes/custom/myspecialthemeforsite1, /sites/site2/themes/custom/mytotalydifferentthemeforsite2 etc., so that they are only available for sites they belong to.


Drupal module to generate compressed xml sitemap

You can separate you sitemap.xml into several sitemaps. Each of this maps will be a smaller than one big sitemap.

Go to admin/config/search/xmlsitemap/settings, in Advanced settings in Number of links in each sitemap page choose, for example, 1000 and regenerate you sitemap.


You could also hook on hook_node_presave() and check here the value of the field... No ?

mymodule_node_presave($node) {
if($node->yourfield[.....]['value'] == 'London') {
$node->state = '0';
}
}


How can I change the 'active' class in main menu to something else?

Assuming you are using Drupal 7.

You can overide theme_links in your own theme.

find the line:

$class[] = 'active';

make it

$class[] = 'current';

check API:

http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_links/7

by the way, I would suggest you not to change 'active', instead you can just add additional class for it.  As many contributed modules use the default 'active' class. Such as SuperFish, Menu Block


How to utilise isDefaultRevision() for forward revisioning?

It sounds like you want to use content_moderation experimental module that just went into Drupal Core 8.2.x-dev and will be available in Drupal 8.2.0.

That module should also be a great inspiration how to implement the functionality.

In general you will need to create your own route where you first load the revision of the entity, then save it when you get it back from the form with:

$node->setNewRevision();
   $node->isDefaultRevision(FALSE);

The function name is very misnamed (https://www.drupal.org/node/2706337 has the details).

However I strongly suggest to check content_moderation first and maybe you can just utilize it for your needs directly.


Displaying a Value while linking a Key with the Linked Field Module

You need to configure the "token" view mode for the content type in question.

First, ensure you're set up to configure the "tokens" view mode separately from your other view modes.

Click to go to the "default" view mode:

Near the bottom, click "Custom display settings" and check "tokens", then save.

Now you will see "Tokens" in your list of view modes to configure:

Go to that page, find the field that contains the key you want and, in the drop-down in the format column, change it to "key".


Why is there a hash value at the end of this element ID?

Here is my guess:

In HTML ID's are suppose to be unique. Since you're adding another item, the ID cannot be the same. Thus, the --nOP2UjZ0zuI is probably some random generated string so the ID is unique.


how to apply .active class to only one menu item that uses optional filters

A page with optional filters set in the url is not treated as a new different page, hence the .active class is applied on all pages with the same pattern. Use of a contextual filter such that the path changes to something like:

  http://example.com/user/1

will fix this problem, since each new url will be pointing to a new page.


Multiple Custom Modules Using Same External JS Lib (e.g. Angular)

The simplest way to solve this is to add a /libraries folder at the root of the Drupal project. Then create a sub-directory for each external library you are using, and reference that from your module.libraires.yml file.

For example, I created /libraries/angular/js, placed the files in there, and then referenced them by starting with a / in the code below.

my-module:
  version: 1.x
  js:
    /libraries/angular/js/angular.min.js: {}
    /libraries/angular/js/angular-sanitize.min.js: {}
    js/my-module.js: {}
  dependencies:
    - core/jquery

Now any module within the project can reference the same files.


What happened to the arguments part of views 3?

They have been renamed "Contextual filters," and they have been moved in the third column that is collapsed by default.

In Drupal 6 (Views 6.x-3.x-dev) the URL arguments are still called "Arguments."


IP Restricting admin pages with whitelist in custom module

This does not.need to be done in code. I.would use https://www.drupal.org/project/restrict_by_ip  and set a role for specific IP that would have the specific  permissions that you need.


Sorting Content easily - wish to avoid a "weight" integer

Here is a "Comparison of Node Ordering Modules".

I have tested most of these modules and decided to go with the Weight module because it was easier to implement and slightly faster then all the other module because it does not add any table joins to your queries since it is re-using the node's sticky field. It includes a very easy to setup Views plugin for drag-n-drop sorting. The Weight module is designed to 'sort nodes', while DraggableViews is designed to 'sort anything'.


In the last screenshot it looks like you're using the teaser view mode in the cart view. However, in your first screenshot, it looks like you haven't enabled and configured the teaser view mode on the variations. Scroll down on that page, open the Custom display settings, select Teaser, and click Save.

Afterwards, hide the image from the teaser view mode by clicking on the Teaser link below the Manage Display tab.

Finally make sure to do this for all variation types you got, if you do it only on one bundle and add a product (variation) of another type to the cart, the change won't be reflected in the cart view.

It seems the above solution doesn't work as expected, although it used to work for me at some point.
Another solution you can try is removing the rendered order item completely from the view, then adding a new relationship from the order item to the product variation and eventually add only the specific fields of the product variation you want to display to the view's fields.


Is EntityFieldQuery really this inefficient?

The EntityFieldQuery class is as efficient as its requirements allow it to be. It needs to be compatible with any field storage classes, even with those that use a NoSQL engine to store the field data, such as the one that uses MongoDB. For that reason, EntityFieldQuery cannot directly query the database, because the current field storage backend might not use an SQL database at all.

Even in the case the field storage uses a SQL engine to store its data, the equivalent of $query->leftJoin('field_data_field_user_role', 'role', 'n.nid = role.entity_id'); $query->condition('role.field_user_role_value', $some_value); for the EntityFieldQuery class requires:

Code to build the database table name from the field name
Code to build the condition to use to join the table containing the field data with the table containing the entity data
Code to build the name of the database row containing the field data

The difference is immediately visible: In one case you are using three litteral strings, while in the other case there is code that (in the simplest of the cases) is concatenating strings.

As per your comment about code that checks if the user has the permission to access the fields, you can bypass that using the following line to the code using the EntityFieldQuery class.

$query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');

This works if you are using Drupal 7.15, or higher; for earlier versions, you should use the following code.

$account = user_load(1);
$query->addMetaData('account', $account);

As usual, you should not bypass the access permission if the code could show to the user information to which the user should not have access. This is similar to what is done from Drupal when an unpublished node is only shown to the users who have the permission to see unpublished nodes. If the code's purpose is, for example, selecting some entities that are successively deleted (e.g. during cron tasks), then by-passing the access control doesn't make any harm, and it is the only way to proceed.


How to perform a comparison in a rule to check all values of a multi-select list?

There is a switch to direct input mode button in the Value - Data selector section, after clicking it you'll see a select box with all the values of that field which now you can select.


If the question is how to debug drush, you could use your IDE in the commands file you've got the command in pm.inc most probably, and use xdebug with the idkey, i.e.

xdebug.idekey="PHPSTORM";

See debuging drush with xdebug for more information

Also related: Can Xdebug be triggered by Drush commands?


Combine two or more filter criteria in views

I Found this problem interesting and spend little time over this. Here is the solution i come with.

Create a view with title and Body field.
Add two filters Content:Title and Content:Body with Contains operator, expose these two filters.
Create a custom module with the following hooks.

//custom.module
function custom_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {

if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'VIEW_NAME') {

    // Unset the title and body filter info so that it doesn't print any label.
    unset($form['#info']['filter-title']);
    unset($form['#info']['filter-body_value']);
    // Unset the title and body filter
    unset($form['title']);
    unset($form['body_value']);

    $form_element = array();
    $options = array(
    // '' => '-Select-',
      'title' => 'Title',
      'body' => 'Body',
    );
    $form_element['search_within'] = array(
      '#type' => 'select',
      '#title' => t('Search within'),
      '#options' => $options,
      '#default_value' => !empty($form_state['search_within']) ? $form_state['search_within'] : '',
      '#description' => t('Set the Title or Body within which you want to search.'),
      '#prefix' => '
',
      '#suffix' => '
',
    );
    $form_element['search_box'] = array(
      '#type' => 'textfield',
      '#title' => t('Search term'),
      '#default_value' => !empty($form_state['search_box']) ? $form_state['search_box'] : '',
      '#description' => t('Enter the term which you want to search.'),
      '#prefix' => '
',
      '#suffix' => '
',
    );
    $form = $form_element + $form;
}
}

function custom_views_query_alter(&$view, &$query) {
if ($view->name == 'VIEWS_NAME') {
    if (!empty($view->exposed_input['search_box']) && $view->exposed_input['search_within'] == 'title') {
    // Add title filter condition if title is selected
        $query->where[1]['conditions'][] = array(
          'field' => 'node.title',
          'value' => '%' . $view->exposed_input['search_box'] . '%',
          'operator' => 'LIKE',
          );
    }
    if (!empty($view->exposed_input['search_box']) && $view->exposed_input['search_within'] == 'body') {
    // Create join with fiedl_data_body table.
    // source:
    // https://api.drupal.org/api/views/includes!handlers.inc/function/views_join%3a%3aconstruct/
    // https://www.drupal.org/node/2049051#comment-7784967
        $join = new views_join;
        $extra = array();
        $extra[] = array(
          'table' => 'field_data_body',
          'field' => 'entity_type',
          'value' => 'node',
          'operator' => '=',
          );
        $extra[] = array(
          'table' => 'field_data_body',
          'field' => 'deleted',
          'value' => '0',
          'operator' => '=',
          );
        $join->construct('field_data_body', 'node', 'nid', 'entity_id', $extra);
    // Add join to query; 'node' is the left table name
        $view->query->add_relationship('field_data_body',$join,'node');
    // Add fields from table (or where clause, or whatever)
        $view->query->add_field('field_data_body','entity_id');
    // Add body filter condition if body is selected
        $query->where[1]['conditions'][] = array(
          'field' => 'field_data_body.body_value',
          'value' => '%' . $view->exposed_input['search_box'] . '%',
          'operator' => 'LIKE',
          );
    }
}
}

Note: This solution will only work with Contains operator and very case specific. It would be great if somebody will create a generic views filter handler to combine exposed filter as select list and allow search within selected filter.


Changing numbers of render-blocking JavaScript and CSS

The bundler works per region, so set it to 2 for JS as you have footer JS and header JS; 2 header + 2 footer + 2 external scripts will give you 6 for desktop and 3 for mobile, as Page Speed Insights seems to only count header JS for mobile. Moving all the JS to the footer might help eliminate all render blocking JS with mobile according to Page Speed Insights Mobile; it will also give you a better score for the Page Speed Insights desktop as more JavaScript files can be combined.

You can disable the bundler as that will give you a better score, but you will have to download a new full sized CSS/JS aggregate if any of the CSS/JS changes per page on your site; so you won't be able to fully take advantage of the browser cache and real world performance will not be as optimal as it could be if you do disable the bundler. It's about tradeoffs.

http://www.webpagetest.org/result/140619_5M_134C/ Shows a decent report as well.


I haven't tested this, but I would make two views-- View A includes the events with a start date and View B includes the events with no dates.  Then, add View B as the footer to View A.  The events will now be shown on the bottom.


I guess I found a solution for this problem:

function mymodule_node_insert($node) {
  $node->field_custom_field['und'][0]['nid'] = $node->nid;
  node_save($node)
}

I saved the changes to database with node_save()


Hope you are using views to display the nodes. If so, then click on the tags field in the Fields and in the "MULTIPLE FIELD SETTINGS" give space in the separator.


Allow editing of user content by account creator

Your question looks like a perfect fit for the Group module, which can be used to create collections of content (nodes) that can be accessed by sets of users and with variations of access levels, such as none, read only, edit, etc.

Have a look at the answer to "What are the alternatives for the Organic groups module?" for a brief introduction to the Group module.

For this specific question, here is a blueprint of how it could be used/configured:

Group Type: Teams
Group Roles (refer to "What are the various roles supported by the Group module?" for more details):

Coordinator.
Team Member (or whatever fits), used for those who have access to a Team's content.

Groups: 1 such group for each team (simple as that ...).
Optional (not sure if you want this): If a user creates a new group, then automatically assign the "Group Owner"-role to the user who created the group.
Group permissions: grant permission to the user with role "Group Owner" to perform actions like "Add members" or "Invite members to join".

Special case: "If the coordinator were to change" (as in your question), then simply tune the permissions to grant the "Coordinator" role to another appropriate user (how easy can it be ...).

To use the Group module from within a custom module, start from its Development guide and/or have a look at its API for D7 or API for D8.

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".
Other questions tagged with the group tag.

PS: Even though this question is related to D8, this answer applies for either D7 ...


Add a view with a contextual filter not on a node/taxonomy page

You already have Views that list all the content tagged with a Taxonomy term. The Views is called Taxonomy term, but it is a Content type Views listing nodes that have been tagged with a particular term.

You can Clone the Taxonomy term view and edit the clone to adjust it to your specific needs for Accomodation. Keep the original Taxonomy term View disabled if you don't need it. But you can keep it enabled along with the cloned instance too.

You want to change the Path to accommodation/%, the first part shouldn't be variable.

Also add a new Filter Content: Type and choose Accommodation only.

You can also change to use Fields instead of Content for more control over what is shown in each Accommodation result.

With this setting you will get pages that take term ID as the argument. If your San Diego term has ID 12, then if you visit the page /accommodation/12 you will see Accommodation nodes tagged with San Diego.

You don't have to create those pages in any other place than Views, they're already working when you type the correct path with term ID into your browser location bar.

If you want to list all the available terms you can use the Summary in the When the filter value is NOT in the URL option of the Contextual filter. This way when users visit the /accommodation path they see a list of locations. When they click on a location they see accommodation nodes associated with it.

You can use the Menu option to add the page to a menu of your choice.

Use term names instead of IDs

To get the term name to appear in the path instead of the TID you have to add the Relationship to the term, and use a Contextual filter Term name that uses that Relationship. (Remove old Contextual Has term ID.)

I've covered details in another Question: How to setup view to filter based on second URL parameter?

Be careful about the Case settings, use dashes ;)

With this configuration your path will be /accommodation/san-diego.


I was going to check the theme for you but it looks like that's a private theme so I'll try to outline some other places you can check.

The most common places you would find it are html.tpl.php and template.php but it sounds like you've covered those.  If it's not in html.tpl.php then it is likely being added with drupal_add_html_head().

Other places to look outside of the ones you've already checked could be in your /modules folder - looking for any custom modules that came with the theme.  If the tag is being added with drupal_add_html_head() then it could be in a custom module.

If not in template.php, check if the theme uses individual files for preprocess functions.  ie look for html.preprocess.inc or something similar.

The theme might have some *.inc files for random features - you can check those as well.

A quick grep of your theme folder for drupal_add_html_head or X-UA-Compatible would likely get you your answer quickly.


function theme_field__content_type() isn't working

The problem lies in having other functions that alter OTHER fields of the SAME content type.

Earlier in my development, I created two functions, one each, for two specific fields. Even though my adjustments for those fields were minor (added classes to one and added an img tag to another) it still caused the generic function to fail.

Because I had those other functions...

theme_field__field_name__content_type

It made the generic function for all fields...

theme_field__content_type

...not work.

Once I removed those other functions? Suddenly theme_field__content_type started working instantly.


This should be possible by invoking Drupal.CTools.Modal.show directly. The function takes one argument (the modal-style), which either can be a string pointing to an object on Drupal.settings or the style-object itself.

After showing the dialog, it is possible to populate title and content using jQuery:

Drupal.CTools.Modal.show('my-modal-style');
$('#modal-title').html('my-title');
$('#modal-content').html('some markup here').scrollTop(0);
Drupal.attachBehaviors();

In your PHP code, you need to ensure that ctools modal.js and also misc/ajax.js gets loaded:

drupal_add_js('misc/ajax.js');

ctools_add_js('modal');
ctools_add_css('modal');

// Add your modal style to the settings. You find the defaults in modal.js near the top:
drupal_add_js(array(
  'my-modal-style' => array(
    'modalSize' => array(
      'type' => 'fixed',
      'width' => 250,
      'height' => 250,
    ),
    'closeText' => 'Dismiss',
    'closeImage' => ...
  ),
), 'setting');


How can I exclude content older than... with Views

The Show nodes relative to a date with Views page explains how to do it. Did you try post date on Filter criteria with the following configuration?

?


Creating a node type module in Drupal 7.x

Download and look at those wonderful examples


Using SQL functions in conditionals in Drupal 7 db_select()

change

$query->addExpression("LOWER(ttd.name) = $category");

to

$query->where('LOWER(ttd.name) = :category', array(':category' => $category));


How to keep checkbox checked after form submit

First you need to specify #default_value to your element, Then if you are going to save your data in some place, then load it and use it as your element default_value, if you are not going to save it then you can use form_state on that but remember to set $form_state['form_rebuild'] as TRUE in submit handler, a sample code will be like this :

function my_module_form($form, &$form_state) {

  $form['terms'] = array(
    '#type' => 'checkbox',
    '#title' => t('Your checkbox'),
    '#default_value' => isset($form_state['values']['terms']) ? $form_state['values']['terms'] : array(),
  );
  $form['submit_button'] = array(
   '#type' => 'submit',
   '#value' => t('Click Here!'),
  );

  return $form;
}
function my_module_form_submit($form, &$form_state) {
  $form['terms']['#default_value'] = 1;
  $form_state['rebuild'] = TRUE;
}


How to make work Restfull /user/register?_format=hal_json

please add at header:
 Content-Type : application/hal+json


Disable delete functionality on Webform submissions

Webform provides the following permissions, which can be controlled via the standard page at /admin/people/permissions:

Delete all webform submissions

  Allows deleting of any webform submission by any user. Generally an administrative permission.

Delete own webform submissions

Once you have those set for the required roles, the delete tab will no longer appear for those users.


Crumbs module won't display correct current page. Displays 'Anchor'

I found the answer to my issue after using the crumbs debug tool. I had stupidly named a link 'Anchor' when I was creating a menu and forgotten about this. This menu item was overriding the output I was looking for.

Here is my debug results if it helps anyone. Thanks to donquixote for pointing me in the right direction to use the debug tool.


hook_preprocess_page: "node_load() + node_page_view()" versus "%node + node_page_view()"

When mymodule_preprocess_page() is invoked for the "first/%node" path, it gets the node object because the path is associated with a node from the module.
Drupal cannot associate a node object with a path like "/admin/content/node" (Drupal 6 path) because the path doesn't contain any reference to a node ID which is marked as node ID. Which node object should Drupal return for such paths, considering a Drupal website can contains hundreds of nodes?

Your question is "how can Drupal associate a node object in one case, but not in the other one?"

The answer is in the template_preprocess_page() code, which the function executed before the template page.tpl.php is rendered.
In that function, you will find the following code:

if ($node = menu_get_object()) {
  $variables['node'] = $node;
}

The default parameters for menu_get_object() are $type = 'node', $position = 1, $path = NULL, which means template_preprocess_page() is asking for the node object that is associated with the placeholder in position #1, which is the value returned, for example, from arg(1).

Looking at the source of menu_get_object(), you will notice that the code being executed is the following:

function menu_get_object($type = 'node', $position = 1, $path = NULL) {
  $router_item = menu_get_item($path);
  if (isset($router_item['load_functions'][$position]) && !empty($router_item['map'][$position]) && $router_item['load_functions'][$position] == $type . '_load') {
    return $router_item['map'][$position];
  }
}

Using the default arguments, the function will verify the loading function associated with the route item #1 is node_load(). If the loading function is that, then it will return the value returned by the loading function to the calling function (in our case, template_preprocess_node()).

To automatically get a node object, your menu callback should use a path like "second/%node" (which would be compatible with the default menu_get_object() arguments). The only problem is that for such paths the node ID needs to be passed; if the URL is http://example.com/second, Drupal will show a 404 error page, as the placeholder require parameter that must be passed.
To resolve this problem, the module should define two menu callbacks: one associated with "second", and one associated with "second/%node". The first menu callback would not get a node object, while the second would get the node object (and mymodule_preprocess_page() would get it too).

As alternative, you should change the code of mymodule_preprocess_page() to something similar to:

/**
 * Implementation of hook_preprocess_page().
 */
function mymodule_preprocess_page(&$vars){
  // Check if the page being served is one of the pages handled by the module.
  if (arg(0) == 'first' || arg(0) == 'second') {
    if (isset($vars['node'])) {
      // The page is a node page.
    }
    else {
      $vars['node'] = mymodule_load_the_default_node();
    }
    // …
  }
}


I found it. Silly me, it was the module Menu link (field), it actually says in the project page The "Menu settings" tab is however removed from the node form and replaced by an field widget. Argh, so much time looking for the reason, I didn't see that one when I uninstalled the ones that were interfering.


how to change hierarchical taxonomy path using Pathauto

this work for me:

[term:vocabulary]/[term:parents:join-path]/[term:name]

this pattern generates the path: Category-Name/Category-1/sub-category-1/Term-Name


Using SQL how do I select the value of a translated field in a specific language?

The field language is stored in the language column of each row in the field table.

So you just need to add a simple condition to your SQL, e.g.

language = 'es'


How do I convert a pre-existing site to a Composer-managed application?

Follow
https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies#managing-existing-site
Copy-paste method:

Install Composerize Drupal with composer global require grasmash/composerize-drupal command;
Run cd path/to/drupal/project/repo && composer composerize-drupal
--composer-root=[repo-root]    --drupal-root=[drupal-root] where [composer-root] is the root directory of your project where .git is located and    [drupal-root] is the Drupal root where index.php is located.

Manually restructure pre-existing Drupal projects per discussion between Norman and Moshe on https://github.com/drush-ops/drush-launcher/issues/33
Rebuild the code base from scratch, see https://www.jeffgeerling.com/blog/2018/converting-non-composer-drupal-codebase-use-composer


Ubercart how to provide expiry option for a product if its not in auction?

There is one for Drupal 6, but there does not appear to be a solution for Drupal 7.

The easiest way may be to use rules with an additional field in the products content type and set the product to be unpublished after the date (see https://groups.drupal.org/node/240678 for an example).

Another more complex way would be to make a module that runs on cron (hook_cron) loops through all the products (MySQL select * from uc_products for an example), add a new field to the products content type called expired, set it to a date (using the date module), upon looping through products get the entire node (including this field) and see if it is expired.

But scheduler can do what you want, you just need to add a new field to the content type for the expiration date and set it to expire on that.


Title encoding to display correctly foreign characters

Instead of trying this.

<?php print $head_title; ?>

try this and check.

<?php print html_entity_decode($head_title); ?>


Where does Drupal set the uploaded file name syntax?

You can use transliteration module.

and in code use code like

function hook_transliteration_clean_filename_prepare_alter(&$filename, $source_langcode) {
  $filename = drupal_strtolower($filename);
  $filename = str_replace('__','_', $filename);
}

Above code is not tested, Hope it will help you.


How can I obtain the "latest" vid when on Revisioning's "View latest" tab?

I dug into the Revisioning module to see how they are doing the check and adapted it for use in a helper function in my module. I first load the node using menu_get_object() and then call the following:

function _get_correct_revision($node) {
  if (module_exists('revisioning')) {
    if (_revisioning_load_op($node, 'view') == REVISIONING_LOAD_LATEST) {
      $vid_to_load = revisioning_get_latest_revision_id($node->nid);
      $node = node_load($node->nid, $vid_to_load);
    }
  }
  return $node->vid;
}


How do I get a data value after all AJAX calls are complete?

Seems that you are building the elements of the form some parts using ajax and some parts using what you show on JsFiddle.

To run commands after success of an Ajax callback you could use he Ajax framework and Ajax framework commands API documentation. Here is a brief example. You will the hook_form_alter to alter the linkit_dashboard_form and add the commands. This alternative is more accurate to execute the commands after a specific ajax call but would require many changes adding hooks and custom functions.

Another alternative is to use .ajaxComplete() and check if the ajax call retrieves the linkit form elements. Example:

$(document).ajaxComplete(function(event,request, setting) {
 // Add same check you use on your setTimeout to make sure that "form-item-linkit-rel" input exists.
 // You could also use some of the values of the "setting" param of ajaxComplete() function to use additional checks.
});

Note: In case that the problem is caused by something declared inside of  Drupal.behaviors.mymoduleLinkit, try to debug your Js code with Chrome/Firefox DevTools. Add some breakpoints to find out what is causing the issue.


How to use views contextual filter default argument "Taxonomy term id in url"

Have you figured this out? If so could you share your answer?

I do not think the problem is that the path follows any pattern.  As long as you create a path that identifies the location of a term and you configure the contextual filter correctly.  eg. example.com/whatever-you-want/any-term will work as long as the view path is example.com/whatever-you-want/%.  The 'any-term' must be a term in a vocabulary defined for the contextual filter and validation must be set to identify it.


Ckeditor can not create new profile with input format

It seems to be a problem when creating or cloning a ckeditor profile, the module doesn't insert registers into the table ckeditor_input_format, so we can do that by the following SQL queries

INSERT INTO `ckeditor_input_format` (name, format) VALUES ('<profile_name>','filtered_html')
INSERT INTO `ckeditor_input_format` (name, format) VALUES ('<profile_name>','full_html')
INSERT INTO `ckeditor_input_format` (name, format) VALUES ('<profile_name>','plain_text')

The name  must be replaced with the name of the profile you created with ckeditor.


Entity Reference Field: How to filter a View entity reference

Yes, the options you can select from there are plugins.

As you found out, you can't use views with config entities, but you can implement one yourself.

There are two ways to do that, one is to define your own plugin that you can select there, like ViewsSelection does it. Or, it is possible to provide a version of the default plugin (DefaultSelection) that is automatically used for a specific entity type, see for example TermSelection.

I would however only use the second pattern if it is your own entity type, and otherwise define a separate plugin (you can still extend from DefaultSelection and re-use the code there).


How do I put a taxonomy term on a panel page?

Create a Page
Give it a %term argument and map it to a taxonomy term
Create a view pane that takes a taxonomy term as argument.
Create a mini panel that requires a taxonomy term argument.
Add the View to the mini panel. Configure it to use the taxonomy term.
Add the mini panel to the Page.


How can I avoid the feed link is printed in my theme?

If this is a view, you can hide the feed icon using this method.

  Go to Structure > Views > Frontpage > Edit. Then click on "Feed" at the top. In the second drop-down box, select "Disable Feed." Then "Save" the change.


You need to implement two Views hooks: hook_views_api() and hook_views_plugins(). Have a look at views_views_plugins() in Views' /includes/plugins.inc file for an example implementation of the plugin hook; specifically, look at the plugins in the 'access' key.

Beyond that, look at the views_plugin_access* files in /plugins/ for examples of actual implementations.


jQuery wrapper function when using Drupal behaviours

Drupal attaches behaviours on DOM ready - by waiting until the DOM is ready yourself to actually inform Drupal of your custom behaviour, it's too late (unless you call Drupal.attachBehaviors manually afterwards, which would be less than efficient).

Your 2nd example is both logically correct, and the recommended way to use behaviours with jquery in Drupal 7.

Unless you have a very good reason not to, always using that approach would be a good idea.


Add configuration options for Views block under Structure > Blocks > configure

To "add fields to the block configure pages for these two blocks" (as in your question), you should look at the Bean module as a possible alternative to answer this question. Here is a quote about its project page:

  Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of this module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved). It also shows how the Bean module transforms Drupal blocks into fieldable entities.

PS: this is a D7 module, integrated in core in D8 ...


Available approaches for moving userpoints from one user to another

There are at least 2 approaches you can choose from, as further detailed below ...

User points donations

Use the Userpoints Donation module, which is one of the modules included in the (D7 version of the) Userpoints Contrib module.

To use it, make sure to also grant the required permission related to it (and to avoid asking yourself "How is the module Userpoints Donation intended to work?" ...).

Rules

Use the integration between the User Points module and the Rules module to "roll your own cookies", by writing some custom rules to transfer user points from one account to another.

As a sample, have a look at this rule, which is used in combination with voting of a node, whereas the author looses "-2" points, and the voter looses "-1" points:

{ "rules_votedown_question" : {
    "LABEL" : "votedown_question",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "answers" ],
    "REQUIRES" : [ "rules", "voting_rules", "userpoints_rules" ],
    "ON" : { "voting_rules_insert_node" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "answers_question" : "answers_question" } }
        }
      },
      { "voting_rules_condition_check_vote_value" : { "vote" : [ "vote" ], "value" : "-1" } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "node:author" ],
          "points" : "-2",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Receive downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "QuestionDownvoteReceived",
          "reference" : "By uid=[vote:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      },
      { "userpoints_action_grant_points" : {
          "user" : [ "vote:user" ],
          "points" : "-1",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Issue downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "QuestionDownvoteIssued",
          "reference" : "From uid=[node:author:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      }
    ]
  }
}

If you simply adapt the amount of points (-2 and -1) to something like (eg) +25 and -25, you've a prototype to transfer (25) user points from one user to another.

If you replace the Rules event by an event like "something is flagged" (created with the Flag module), a simple click could be used to indicate "I want to transfer 25 user points of mine to this user). You could take this even a step further: since flags are fieldable, you could add a field to indicate the amount of points to be "moved".

However, the above Rules example may need further refinements, e.g. if you want to ensure that after moving points van User A to User B, the remaining points for User A is not negative. Refer to "How to check whether one's current User Points are negative with the Rules module?" for details about how you can implement such refinement also.


Go to admin > content types, find your content type used as a profile (default is called 'profile') and click edit.  Scroll down to the "Comment Settings" fieldset and expand that and choose "Read/Write" and any other comment options you choose and save the content type.


Is there a plain-text equivalent to the 'html' suffix for [webform_submission:values]?

Thanks @leymanx for the suggestion to make my own custom token. That's what I did. I created a hook_tokens function that borrowed code from webform.tokens.inc hook_tokens implementation. I deleted anything that didn't relate to the one token I was after, then created a _module_name_token_get_submission_values function that also borrowed heavily from the corresponding function in the webform module. Finally, I wrote a function that performed a series of preg_replace substitutions on the html code that was giving the destination server problems.
Along the way, I learned a lot about custom tokens and was able to refactor my plugin to eliminate the need for a completely separate plugin through the use of a custom token. :-)


How to create commerce product content using date repeat entity module?

I'm not too familiar with Date repeat entity module, but why don't you try implementing hook_node_insert() in a custom module, to handle creating a new product every time a a new node is created:

/**
 * Implements hook_node_insert().
 */
function my_module_node_insert($node) {

  //check type and that no product set previously
  if($node->type == 'my_type') {

    //create product
    $cp = commerce_product_new('product');
    $cp->is_new = TRUE;
    $cp->revision_id = NULL;
    $cp->uid = 1;
    $cp->status = 1;
    $cp->created = $cp->changed = time();
    $cp->sku = 'My SKU';
    $cp->title = 'My Product';
    $cp->language = LANGUAGE_NONE;
    $cp->commerce_price = array(LANGUAGE_NONE => array( 0 => array(
      'amount' => 1000, //$10.00
      'currency_code' => 'USD',
    )));

    //save new product
    commerce_product_save($cp);

    //set reference field
    $node->field_product['und'][0]['product_id'] = $cp->product_id;

    //update node
    node_save($node);
  }
}

I haven't tested this code, but this would be the general approach I would try.

This would only work if the Date repeat module invoked this hook though.


No submit button available when using Display Suite Forms to render a node add form

Just in time. Went through the ds form source code and found a variable drupal_render_children which holds the so far "unrendered" part of form.

So instead of using regular drupal_render_children as function and passing form etc for it you use it just as an variable.


use Css if nothing is working to show the label in small letters.

text-transform: lowercase;


7 - Attachments are not showing in search results for non admins when using apache solr attachments

One dirty hack for this problem is: Disable Apache Solr Access module and than the file search should work fine for other users as well.

But first check if there are permission available for Solr Access, if not than you may try this hack and see if this works.


How to scrape content from a Drupal Site?

The way I would go about it is:

At .htaccess / nginx.conf level, I'd disable access to site for anyone but my own IP. You know, to be sure.
Directly in database, change email address of user 1 to my own OR restore user table from a backup
Use password restore feature to get admin access
Use whatever module I want to export content (stripping it from any html, js, php if it's there)
Delete site thoroughly from the server
Rebuild it, or restore it from pre-Drupageddon backup
Re-import content.


"user" is a path already used by the User module; if your module is not executed after the User module (i.e. you are not altering the order hooks are executed), the menu item of the User module takes the precedence. (That is also the wrong way to alter the menu item defined from another module, but your purpose is not that.)

  // Registration and login pages.
  $items['user'] = array(
    'title' => 'User account',
    'title callback' => 'user_menu_title',
    'page callback' => 'user_page',
    'access callback' => TRUE,
    'file' => 'user.pages.inc',
    'weight' => -10,
    'menu_name' => 'user-menu',
  );

If you want to define a menu tab for each user account, as I think, the definition of your menu item should be similar to this, used from the User module.

  $items['user/%user/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_profile_form', 1),
    'access callback' => 'user_edit_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'file' => 'user.pages.inc',
  );

For example, something similar to the following would work.

  $items['user/%user/edit'] = array(
    'title' => 'Blogs',
    'description' => 'Listing of blogs.',
    'page callback' => 'cleanetica_advanced_blog_page',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_LOCAL_TASK,
  );

The page callback receives an argument: the user object for the user account. It will be called from Drupal as cleanetica_advanced_blog_page($account).
Every function implemented by a module needs to be prefixed by its short name.
The menu type is MENU_LOCAL_TASK since there is already a MENU_DEFAULT_LOCAL_TASK menu item, and there cannot be two MENU_DEFAULT_LOCAL_TASK; the other tab is also the tab showing the details for the user account, and it is better to keep that as default tab.

If you want to show a list of blog posts global for all the users, then you need to change the path from user, or user/%user/edit, to (for example) blogs. Adding it as tab of the user tab doesn't make any sense, since the page would list content, not a list of users; it would be also shown together user/login, user/register, and it doesn't make sense to show a list of blog posts to who is registering/logging in.


Modify a custom block field value with hook_form_alter and validate

Got this working by adding a submit handler.

Below is the code -

function coolmodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  //create or edit form
  if('block_content_coolblock_form' === $form_id || 'block_content_coolblock_edit_form' === $form_id) {
    //extra submit handler that will execute after default submit
    $form['actions']['submit']['#submit'][] = 'coolmodule_coolblocksubmit';
  }
}

function coolmodule_coolblocksubmit(array &$form, FormStateInterface &$form_state) {

  $entity = $form_state->getFormObject()->getEntity();
  // unset field.
  $entity->set('myfield', '');
  // Saving the entity.
  $entity->save();
}


Passing an array of object from custom module to template in drupal 8

In your controller why you are using like this

'#myvariable' => array('key' => $myArrayofObjects),

Change it as

'#myvariable' => $myArrayofObjects,

and in my-page.html.twig

Test twig template!

{{text}}

{% for key, value in myvariable %}
  Key : {{ key }}
  Name : {{ value.name }}
  User ID : {{ value.user_id }}
  Email : {{ value.email }}
{% endfor %}


Yes views is what you want to do. So long as you are using fairly standard modules (like profile) for your fields. You can create filters for any of them.

Create a view with the base type of 'user' and you should be good to go. You will need views and views_ui module enabled.

Just be a little careful that if your view is open to the public you could potentially expose things like email address to the web.


You shouldn't include the ready function, the latest Zen wraps your script in a custom behavior.  Try putting your code directly inside the custom behavior that is already included in the script.js file.

(function ($, Drupal, window, document, undefined) {

Drupal.behaviors.my_custom_behavior = {
  attach: function(context, settings) {

    $(".colorbox-color").colorbox({
      onComplete: function(){
        var bg = $.colorbox.element().data('bg');
        $('#cboxWrapper').css('backgroundColor', bg);
        $('#cboxLoadedContent').css('backgroundColor', bg);
      }
    });

  }
};

})(jQuery, Drupal, this, this.document);


How to programmatically duplicate a node?

Just unset the node ID with unset($node->nid), and node_save() will create a new node.

The code executed from node_save() is the following one:

// Insert a new node.
$node->is_new = empty($node->nid);
// ...
if ($node->is_new) {
  _node_save_revision($node, $user->uid);
  drupal_write_record('node', $node);
  db_query('UPDATE {node_revisions} SET nid = %d WHERE vid = %d', $node->nid, $node->vid);
  $op = 'insert';
}

The last argument of drupal_write_record() is not passed; this means the function will not update an existing database row.

Once the node object has been saved with node_save(), $node->nid contains the node ID for the newly created database row.


There's more interaction and integration between core and CKEditor's plugins than we see in D7. In fact, in researching your question, I've learned that Drupal and the CKEditor team are actively collaborating, which is cool to know. But let's first note that the ckeditor js libraries and plugins (version 4.5.5 as of Drupal 8.0.1) live at core/assets/vendor/ckeditor, not core/modules/ckeditor. Also note that enabling ckeditor plugins requires explicit supporting code, such as noted here and here.

So, rather than "the kitchen sink" approach — it might be better to identify which CKEditor plugins you need enabled, that are not in core, and use the code examples in the URLS above to implement them. FWIW, it's much easier to manage such projects after delivery anyhow, even with D7.

Finally, as a nag, I presume kittens still get it bad when you overwrite drupal-managed code with your own code. In other words, I'd figure how to extend Drupal without changing code in core/ so that when I perform a later core update, I won't loose those changes.


Make Apache Solr return results based on taxonomy term

Apachesolr's "More like this" block, that you can display on your nodes, is similar, but not particularly configurable.  It uses both terms and text to determine related nodes, so you can't just base it on a particular term reference field.  Also, it appears on the actual nodes (in your example, it would appear only once a user has clicked on and is viewing node1), not on the search results page.

OPTION 1 ----------

If you're looking to include this type of block on nodes, it'd be possible to do precisely what you want with just a view.

Create a content view that filters out only the node types you want.
Make sure it accepts a term id as a contextual filter to use (i.e. based on the currently viewed node and its terms, it will filter the list of nodes it displays to ones with precisely those terms). To accomplish this, add a contextual filter to your view that is "Content: term_reference_field"!
Then, set the default value of this contextual filter to come from the current node if it's not in the URL: select 'Taxonomy term id from URL' as the default value and then select 'Load default filter from node page'.  Under that, select the vocabulary that your term reference is based on.  Also make sure you select how to handle multiple values (if the current node being viewed has multiple terms selected, do all terms have to match for a related node to be shown, or should just a single value match be enough?).
That should be all you need!  Test your view out by providing some sample inputs in the 'Preview' area and making sure that the resulting nodes match via their terms!

OPTION 2 ----------

Now, if you're looking to do this on the search results page, that is a little trickier, because you have to look at multiple nodes (all the ones in the results) rather than just a single one.

Here's how I would do that:

In your view, from above, make sure you expand the 'More' section at the bottom of the contextual filter, and check that it should be able to accept multiple parameters (if you want to base the 'Related nodes' view on all the nodes from the search result rather than just the top one
Implement a hook_preprocess_search_results() function in your custom theme - this should be placed in your template.php file.

  function YOURTHEME_preprocess_search_results(&$variables) {

  // Get nodeids from search results
  $node_ids = array();
  foreach ($variables['results'] as $result) {
    if (!is_object($result['node'])) {
      continue;
    }

    $node_ids[] = $result['node']->entity_id;
  }

  // Ensure node ids exist
  if (!count($node_ids)) {
    return;
  }

// Now that you have the nids of all the search results on the current page, call the above view with those nodes as parameters
// The second argument should be the display on your view you want to call, could be 'page', 'block' or whatever custom one you have
$view_output = views_embed_view('YOUR_VIEW_MACHINE_NAME', 'block', implode('+', $node_ids));
if ($view_output) {
  $variables['my_view_results'] = $view_output;
}
 }

Finally, now that you've set the variable $my_view_results above (with nodes from the search results at view contextual filters!!!), you can call place that variable anywhere in your search_results.tpl.php template file and place it anywhere: above, below or anywhere on your content

  <?php print $my_view_results; ?>

Sorry that Option #2 is kind of complicated.  Someone may come up with a more straight-forward answer, but I can only think of using a view and providing it with the right parameters by hooking into hook_preprocess_search_results() to grab the right node ids that are appearing on the search page.  Good luck.  Let us know if this works out!


Can theme() call a theme function from another module?

Yes, a module can call, with theme(), a theme function that is defined from another module. If it were not so, no module could use theme_link(), since that is defined as one of the System module theme functions. This is contrary to Drupal philosophy; limiting a module to use the theme functions it defines would not make sense.

See system_theme() which calls drupal_common_theme() to add link to the theme function it implements.

function drupal_common_theme() {
  return array(

    // From theme.inc.
    'html' => array(
      'render element' => 'page',
      'template' => 'html',
    ),
    'page' => array(
      'render element' => 'page',
      'template' => 'page',
    ),
    'region' => array(
      'render element' => 'elements',
      'template' => 'region',
    ),
    'status_messages' => array(
      'variables' => array('display' => NULL),
    ),
    'link' => array(
      'variables' => array(
        'text' => NULL,
        'path' => NULL,
        'options' => array(),
      ),
    ),
    // …
  );
}

Notice that the correct theme function definition that works for Drupal 7 is the following one; the one you are using is only for Drupal 6 or previous versions.

function def_theme() {
  return array(
    'example_def' => array(
      'variables' => array('nid' => NULL)
    )
  );
}

Since your example of calling the function is theme('example_def', $var), I take you are using Drupal 7, for which your definition would not work.


Why does my 'UUID, Webform, Node' Feature remain overridden?

FWIW, features should only be used to export configuration, and not content. I have audited a site which used UUID features and was not able to find a solution for reverting it. Exporting content (nodes, taxonomy terms, etc.) also makes the feature heavy.

Some things which you could do to :

Have multiple instances: (approach 1)

Dev : continuous deployment happens here. E.g. After every commit or pull/merge request.
Stage : Intermediate deployment; maybe after some feature is done completely. Think of this as a release. Or at every sprint end. When the code deployment happens. Database from the production instance is copied to this instance. So, that the testing can happen on live data.
Live : Sometimes called production instance. Data is only created here. Deployment to this instance happens very infrequently.

These are all servers located on internet. Then, each of the developers have their own "local" site setup. Database from the live site should be used to test new features being developed (or bug fixes). This will ensure more accurate results, as testing happens on latest content.
Note: You can use features in this case only to export configuration.
If you do not want direct addition of content to live environment, try modules like Workflow, Workbench, or Workbench Moderation; which enables you to empower checking of content before the actual publish happens.

Important note: If you are using live database make sure you sanitize it. drush sql-san commands can come in handy.

Use Deploy module: (approach 2)

  The Deploy module is designed to allow users to easily stage and preview content for a Drupal site. Deploy automatically manages dependencies between entities (like node references). It is designed to have a rich API which can be easily extended to be used in a variety of content staging situations.

Using this module, you can create content on one environment and push it to others. It is pretty easy to setup, with extensive documentation available.

In a nutshell -> KEEP "CONFIGURATION" AND "CONTENT" SEPARATE TO MAKE YOUR LIFE EASY!


What is placeholder_token in html.html.twig for?

The reason why placeholder_token is used in html.html.twig instead of using just a normal variable is that in Drupal 8 we have different render strategies than just the simple rendering where everything gets rendered in the template and we are able to collect the assets.

In the Drupal cores default Renderer we have placeholders (placeholders might attach some additional assets). If we would print the assets in a normal variable it would happen before all the assets have been collected. So what Drupal 8 does is it first renders everything with the normal rendering in the template, then it replaces the placeholders and collects assets from then, and after all that has been done we finally replace the asset placeholders to add the assets to the page.


In a form, I want subsequent fields depending upon previous field?

If looking for a module, you can use the D7 -dev version of conditional_fields

  Define dependencies between fields based on their states and values.

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

Alternatively, you can tweak the forms directly in code using hook_form_alter and the States API

In this example, I show the UPC field when the specified operation value is chosen in a select box:

  // Define available batch operation callbacks
  $operations = array(
    'infinity_batch_sync_products' => 'Import and sync product details',
    'infinity_fetch_products' => 'Fetch list of available products',
    'infinity_fetch_product' => 'Fetch detail on single product'
  );

  $form['operation'] = array(
    '#type' => 'select',
    '#title' => t('Select operation'),
    '#options' => $operations,
    '#required' => TRUE,
  );
  $form['upc'] = array(
    '#type' => 'textfield',
    '#title' => t('UPC'),
    '#description' => t('Enter the product UPC code (commerce product SKU)'),
    '#default_value' => 0,
    '#size' => 20,
    '#maxlength' => 20,
    '#states' => array(
      'visible' => array(
       ':input[name="operation"]' => array('value' => 'infinity_fetch_product'),
      ),
    ),
  );

The "UPC" field only shows when the operation is "infinity_fetch_product"


Can you change the list builder class used by an entity?

You want something like this:

<?php

/**
 * Implements hook_entity_type_alter().
 */
function MY_MODULE_entity_type_alter(array &$entity_types) {
  /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $entity_types['node']->setListBuilderClass('Drupal\MY_MODULE\NewListBuilder');
}


How can add Thumbnail image in Drupal 7 site?

You can edit the content type and configure in the manage display fields. Go to admin/structure/types/manage/article/display considering article is a content type.Replace 'article' with what every node type you have and change the image fields display options as shown in the screen shot.


I guess the Field Permission module is what you need. It allows you to set finegrained permissions to fields. Once installed you can set the permissions to edit, view etc to the field on the manage fields tab of your content type...


Using Simple jQuery click() events in Drupal 7

(function ($) {
// To understand behaviors, see https://drupal.org/node/756722#behaviors
Drupal.behaviors.ss2 = {
  attach: function(context, settings) {

  $("h1").click(function() {
    alert('clicked!');
  });
}}

})(jQuery);

be careful with braces at the end, and rename ss2 as you want, it's just for example...


Views - currently logged in user problem

I figured it out.

The key was to create a "user" view from the beginning, and not a "content" view. Then, the view provided me with all the necessary relationships/filters that I could use. I got this idea from Views - Filtering nodes by current user profile field.


Custom field: users organized into departments

Add a "grouping" to the table settings if you want to group by department etc.

(You would probably want to hide the department field in this case.)

Using taxonomy for user->department relationship sounds fine, and use Views to make all your lists of users/departments (group by):

Make a Vocabulary "Departments" and add some terms to it

Make a Person content type
Add a field to Person which is a taxonomy reference to the Department vocabulary

Download and enable the entityreference module
Modify the fields of the Vocabulary to add a field, which is an entity-reference to a Person node
Call it Person Responsible

Create some content to test with: Create some People, attach them to Departments, then edit the Departments (terms) to assign people responsible
Download and enable the Views module
Create a View of content, of type person. Add title+department fields
Add a relationship to the view "Content: Department"
Add the Person Responsible field to the view, using the relationship you just added

From discussion in IRC, I misunderstood the requirement around Document. It's simpler than described above. Just do:

Create Department vocabulary; add some terms
Create Person content type; add a taxonomy field referencing the Department vocabulary
Create the Document content type; add an entity reference field referencing nodes of type Person
Use Views to display, including "looking through" the entity reference


How do I keep unique form id for ajaxified form?

So the issue was that I was calling the getFormId() in the form itself to build the html id for the ajax wrapper. For rebuilt form the entity object that I provided as argument to constructor was not available anymore so calling this method caused it to look for that entity object to extract data to build the id from and since it no longer exists it caused this issue.


Cron is 403: forbidden with cron_key and through 'run cron' link

If token is valid (and it should be when you use Drupal-generated link), there is one other mechanism that can generate 403: .htaccess - check it for rewrites that might block it. If this will not help, try running cron from Drush. Drush bypasses Apache altogether, so you can know if the problem was Apache related (conf files, .htaccess), or purely Drupal related.


Drupal 7: adding html (image) to view's exposed filters fields

Solved: I am using BEF module (Better Exposed Filters) that, in row 532 of better_exposed_filters.theme used to check_plain even the label.

Commenting that line do the trick, knowing that youre raping someone'else module (but this is the only way i found since there is no an option to dont check_plain the label)


Make a view or panel that displays image *or* video field if present

It can be done with Views rewriting options.

Add both fields (Image before Video) to Views and exclude Image field from output.

For Video field set “NO RESULTS BEHAVIOR” to Image field token:

It means that if Video field is empty Views will get value from this textarea, which contains special placeholders (in this case [field_image]).

Available tokens for your fields can be found under “REWRITE RESULTS” fieldset:

Don't forget to uncheck “Rewrite the output of this field” flag.


You need to use it's namespace, like

use Drupal\user\ProfileForm;

 ..

$form = \Drupal::formBuilder()->getForm(ProfileForm::class);

Or prefix the class, like

$form = \Drupal::formBuilder()->getForm(Drupal\user\ProfileForm::class);

Or get it by 'name', like

 $form = \Drupal::formBuilder()->getForm('Drupal\user\ProfileForm');

  To fix your error, you need to pass a user object there, like this
  (for the current user)

Drupal::formBuilder()->getForm(ProfileForm::class, Drupal::currentUser());


How do I set allowed extensions for a managed_file form field?

$form['picture']['file'] = array(
  '#type' => 'managed_file',
  '#title' => t('picture'),
  '#description' => t('Allowed extensions: gif png jpg jpeg'),
  '#default_value' => (isset($foo->picture->fid) ? $foo->picture->fid : ''),
  '#upload_location' => variable_get('picture_upload_location'),
  '#upload_validators' => array(
    'file_validate_extensions' => array('gif png jpg jpeg'),
    // Pass the maximum file size in bytes
    'file_validate_size' => array(MAX_FILE_SIZE*1024*1024),
  ),
);


This allows you to change the output of field tokens without disturbing the default display of the field.

For example, you might want the Body field displayed as formatted text by default, but plain text whenever it is output as a token.

Take a look at http://drupal.org/node/1299662 for an example of how to use.


Group context on pages generated by views

This has been an issue on the Organics Groups page. Please refer to comment #6 for the solution.

The other way to work around this is to Use page manager to create pages instead of using views. Page manager helps to maintain the context of the group across its pages.


You will need to use views and panels. You will create a new user home page using panels. Within that panel you will want to create a view that lists all the content types Project filtering on the user.

Otherwise, you will need to create your own module.


Are page caching and cache tags related?

Page cache is just the cached values.
Cache tags are tags that are attached to a cached value (simplifying a little bit). This tells Drupal what cached values are related to what cache tags. When a cache tag is invalidated, all cached values that have the invalidated cache tag are invalidated as well. You can find more info on the Drupal documentation page about Cache Tags. The headline is:

Cache tags provide a declarative way to track which cache items depend
on some data managed by Drupal.

So, answering your question, yes, they are totally related and you can (and you should) invalidate page cache entries using cache tags. Because, as stated above, cache tags track content and cache dependencies and thus you can invalidate cached item when content (or the source data of a cached item) changes.
However, this can be tricky. For example, page cache entry of a node view page is always associated with the cache tag node:[nid]. When the node is updated, that cache tag is invalidated, thus making the page cache of that node's view page invalidated as well. Views that shows a list of nodes are not associated with each node's cache tag. Blocks are other display elements may not be related to that kind of tags. So you need to know which cache tag you want to invalidate.
The good news is Drupal takes care of the most common cases, so you don't have to care. Usually, you only need to deal with the cache tags when you are developing custom code.
In your case, you may be hitting another cache (browser cache? reverse proxy cache?).


How to safely delete relation entity endpoint revisions (field_revision_endpoints)

The answer is no. I eventually had to circle back to this question and come up with a solution myself. The relation_revision table contains the relation + revision ids that match up to the field_revision_endpoints rows. Simply deleting rows from relation_revision would orphan the revision field data in field_revision_endpoint.

After poking around the relations issue queue, I found this patch which adds support for the Entity API's revision deletion mechanism.

Instead of patching the relations module, I used hook_entity_info_alter to register my own 'revision deletion callback' on the relation entity, which I based on the above patch and node_revision_delete(). I can now use the Entity API's entity_revision_delete() to cleanly remove the excess revisions in batches.


How to sort in accordance to best match on the results returned by a views filter?

You can do this if you have the core search module installed.  For your filter use "Search terms" (exposed), and for sort use "Search score" (descending).

You'll be able to influence what factors are dominant in the ordering of results by adjusting the settings at admin/config/search/settings.

If you want more control over the ordering then it could be worth looking into the Search API module but setting this up is a lot more involved.


Commerce: Hide "Save and Add Another" button when saving new product

implement hook_form_alter

function hook_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_product_ui_product_form') {
    unset($form['actions']['save_continue']);
  }
}


Enable Group Content Visibility field on Content Type. Using that field you can mark content under a group as public or private.

You need to enable OG ACCESS module to see those fields in admin/config/group/fields

Select the bundle as your content type in node section and select field Group Content Visibility from Fields Dropdown, click on Add field to add Group Content Visibility field for Content Type.


Entity metadata wrapper, get field collection in field collection

Yes it is possible. Let's say you have a content type with a field collection named field_collection_parent, which has a field collection in it named field_collection_child, which has a field in it named field_child.

// First you need to wrap the node with entity_metadata_wrapper
$node_wrapper = entity_metadata_wrapper('node', $node);

// To get the value of field_child:
$value = $node_wrapper
           ->field_collection_parent
           ->field_collection_child
           ->field_child
           ->value();

// UPDATE: If a field accepts multiple values, treat it like an array
// The following line would get the first value of field_collection_child in the
// first field_collection_parent.
$value = $node_wrapper
           ->field_collection_parent[0]
           ->field_collection_child[0]
           ->value();

// To set/modify the value of field_child
$node_wrapper
  ->field_collection_parent
  ->field_collection_child
  ->field_child
  ->set('Some new value');

// To save the node after modifying
$node_wrapper->save();


How do I redirect a form after has been submitted?

There isn't anything different between Drupal 6, and Drupal 7, for the code you are showing, which means:

$form_state['values'] still contains the values submitted from the users
$form_state['redirect'] is still used to redirect the users to a different page

What changes is that the submission buttons for the node edit form are inside $form['actions'].

  // Add the buttons.
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])),
    '#value' => t('Save'),
    '#weight' => 5,
    '#submit' => array('node_form_submit'),
  );
  $form['actions']['preview'] = array(
    '#access' => variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL) != DRUPAL_DISABLED,
    '#type' => 'submit',
    '#value' => t('Preview'),
    '#weight' => 10,
    '#submit' => array('node_form_build_preview'),
  );
  if (!empty($node->nid) && node_access('delete', $node)) {
    $form['actions']['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#weight' => 15,
      '#submit' => array('node_form_delete_submit'),
    );
  }


How can write reffering page node or url in a field of entity form

Using an entityreference to the page the entity form is displayed on solved this for me. Here's some code providing a entity form block with the values prefilled and locked:

<?php
/**
 * Implements hook_block_info().
 */
function mymodule_contact_block_info() {
  $blocks['mymodule_contact'] = array(
    'info' => t('mymodule contact form'),
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function mymodule_contact_block_view($delta) {
  $block = array();
  switch ($delta) {
    case 'mymodule_contact' :
      module_load_include('inc', 'entityform', 'entityform.admin');
      $entity_form_name = 'contact'; // machine name of entity form
      $render_contact_form = entityform_form_wrapper(entityform_empty_load($entity_form_name), 'submit', 'embedded');
      $render_contact_form['field_contact_page']['#access'] = FALSE; // machine name of entity reference field
      $block['content'] = drupal_render($render_contact_form);
      break;
  }
  return $block;
}

/**
 * Implements hook_entity_presave().
 *
 * set the page reference to the current active menu object
 */
function mymodule_contact_entity_presave($entity, $type) {
  if ($type == 'entityform' && empty($entity->draft) && $entity->type == 'contact' && $entity->is_new == TRUE) {
    $node = menu_get_object();
    if (isset($node->nid)) {
      $entity->field_contact_page[LANGUAGE_NONE][0]['target_id'] = $node->nid;
    }
  }
}


This functionality is available in Drush 8.x-6.x:

 role-add-perm (rap)   Grant a specified permission to a role.
 role-create (rcrt)    Create a new role.
 role-delete (rdel)    Delete a role.
 role-list (rls)       Display a list of all roles defined on the system.  If a
                       role name is provided as an argument, then all of the
                       permissions of that role will be listed.  If a
                       permission name is provided as an option, then all of
                       the roles that have been granted that permission will be
                       listed.
 role-remove-perm      Remove a specified permission from a role.
 (rmp)

Unfortunately, this has not been backported to the 7.x-5.x branch, so it probably won't be in the soon-to-be-released Drush-5.9, and isn't in Drush-5.8.  For now, you'll have to use the dev branch to get it.


You could check the Triggering element in the Form State for the button that triggers the Form Submission.

function MYMODULE_node_validate($node , $form_state , $form) {
  if ($form_state['triggering_element']['#value'] != 'Delete') {
    //Include the validations here
  }
}


Trying to find an alternative / replacement for VBO is similar to trying to do so for a module like Views, or other (popular) modules.

To my knowledge there is no other "contributed" module that can do the same as VBO to replace it. Your only alternatives to consider, I think, is either of these options:

Carefully review the D6 security issue and check if you can find a way to prevent that issue from happening in your site (do not allow it to be used in any way that might cause the security issue to arise).
Spend time to create a fix to actually resolve the D6 security issue in VBO, and optionally consider contributing that back to the VBO module (so that others may help to continue to "maintain" that fix).
Similar to "2.", but "hire somebody" to do it for you.

PS: Writing your own "custom" module to replace VBO entirely is another option, but of course "the toughest one" also ...


Unsubscribe links are automatically included when emails are sent via simplenews.

By the way, if you're using simplenews-2.x, you don't need the simplenews_register module; that functionality is included.


In a nutshell:

function mymodule_form_submit($form, &$form_state) {
  if ($form_state['values']['mycheckbox'] == 1) {
    // node code...
    node_save($node);
    drupal_set_message('Node saved.');
    $form_state['redirect'] = 'some/path';
  }
}

Or you could just require the checkbox in the form:

$form['mycheckbox'] = [
  // props
  '#required' => TRUE,
];

If the checkbox is required, the form can't be submitted, and thus the node won't be created.

I would probably require the field(s) instead of silently do nothing on submit if they did not check it. That way the form submit won't get hit and the user won't have to re-enter all of the information.


How can I flush a json response in a controller?

Maybe obvious for people familiar with Symfony, but was new for me; spent way too long trying to find something so simple:

$json_response = new JsonResponse($my_key_value_array);
$json_response->send();
$this->function_that_takes_a_long_time();


want to load the multiple select box field data as per selected category using ajax form alter?

Use reference &$form_state instead of $form_state in functions
hook_form_alter(&$form, &$form_state, $form_id)

Edit:
Ohh yes, I got, there is one should be field_loadtest_player you used "field_loadtest_category" on both ajax
$form['field_loadtest_player'][LANGUAGE_NONE]['#ajax'] = array(
   ...
   ...
);
$form['field_loadtest_category'][LANGUAGE_NONE]['#ajax'] = array(
   ...
   ...
);


How to get the out of the box slideshow to display on a page other than /node? - Corporate Clean/Omega theme

If it was displaying the slideshow correctly out of the box (i.e. without any modifications made), then you should be able set the default front page back to its original state (empty... i.e. delete whatever's currently in the box), then add a file in the theme directory called page--front.tpl.php. Inside that file, copy/paste the original code found inside the file page.tpl.php.

Assuming you're using the Corporate Clean theme, scroll down your new page--front.tpl.php file about 220 lines and change this line:

<?php print render($page['content']); ?>

... so that it's commented out:

<?php // print render($page['content']); ?>

... Or, if all you want to do is simply remove the No front page content has been created yet message, you can hide the default message and then print the rest of the content like normal (i.e. instead of changing the line, just add another one right above it):

<?php hide($page['content']['system_main']['default_message']); ?>
<?php print render($page['content']); ?>

Or, you could just delete that line but I assume you'll eventually want some content there (in which case you can go back and undo the commenting out).

After you've completed all the changes, saved all the files, etc, go to admin/config/development/performance and clear all the caches -- the new front page should now appear with the slideshow and without any "No front page content has been created yet" content.

Hope that helps...

:)


Can't get fid of the saved file after file_save_data

In Drupal 7, $file_object->fid should work.

Looking at the code you have tried ($file_object->fid->value, file_object->id()), I guess you have been mixing up Drupal 8 and Drupal 7 documentation.


Workbench: Allow users to publish revisions without moderation

This is sort of bizarre and I'd love to hear other answers, but after much trial and error with Rules, it turns out this seems to work with the following setup:

Event: After updating existing content [so it's not a new node]

Condition: Content is published [so admin has approved it at least once]

Reaction:
1. Publish Content
2. Set moderation state during save: Published

I would have thought that either #1 or #2 would have been sufficient, but strangely if they are not combined, it always reverts to draft. Also strange, the order doesn't seem to matter. I've had it working #1 then #2 and #2 then #1.


I would ask joachim about the status of this module. He's very good and was interested in finishing it up a little over a month ago. I'm not certain where he is but it's worth a try.


Clear views cache after node inserted in Drupal 7

The next snippet should work for you

cache_clear_all('MY_VIEW_NAME:', 'cache_views_data', TRUE);


How do I invoke a service after submitting a form?

You're trying to do four things at once (form, service, integration with API, caching), so you can't see where the problem is. Instead, break this down into distinct steps.
First, code and debug your form. In the submit function, just use the messenger service in your form ($this->messenger()->addMessage('this is a test message');) to display a static value for your greeting. You should reach a point where visiting /hello and submitting the form will display the message. You can customize that message later. Get this working first.
Second, code and debug your service class. I find it useful to use drush php-script here to execute a standalone PHP script that accesses your service. That way you can ensure your service is doing exactly what you want, and figure out how to communicate with the external API, before you try to use your service in a form. You don't need the "_controller" in your routing file. The way to access your service is using \Drupal::service('hello_world.salutation')->salutation(). Instead of passing variables through a tempstore, pass them as parameters to your salutation() method. So your standalone PHP script for drush would look something like this:
<?php

  $greetings = \Drupal::service('hello_world.salutation')->salutation('some string entered on your form');
  echo $greetings;

Save this as test.php then execute this with drush php-script test.php.
Third, once your service is working as you want, integrate your service with your form. You should be able to take the PHP script you wrote in step two and insert it almost unchanged into your form submit function. (As a future enhancement, learn how to inject your service into the Form rather than use the static \Drupal::service() call, but that can wait until after you have this working).
Fourth (do this only after you have the above working), examine your need to cache data, and then implement some sort of caching in your service if needed. You haven't shown all your code or completely explained what you're doing, but I don't see anything that justifies using cache.nameofbin or a tempstore.


What is the maximum number of elements allowed in a form?

I think, the issue is related to Server configuration, not with Drupal.

There is max_input_vars variable in php.ini which define the maximum number of variable form elements that can be submitted to a single page.

  The “max_input_vars” setting in the php.ini file is a relatively new
  option starting last year from PHP 5.3.9. It allows you to control the
  maximum number of form elements on a page. Some webpages have a large
  amount of forms/fields for administrative or page configuration
  purposes. In those cases, we need to increase the number of this value
  in order to properly view those pages.

There is also post_max_size variable in php.ini.

  post_max_size sets max size of post data allowed. This setting also affects file
  upload. To upload large files, this value must be larger than
  upload_max_filesize. If memory limit is enabled by your configure
  script, memory_limit also affects file uploading. Generally speaking,
  memory_limit should be larger than post_max_size. If the size of post data
  is greater than post_max_size, the $_POST and $_FILES superglobals are empty.

You can check the this for more details.


Where can I check my module information in database?

The information is stored in the config table.

Search for the record with name 'core.extension', the related data is an array of all enabled modules with their related weight.


Term Reference field as checkboxes, not auto-complete?

To change the tag selection to check boxes configure the widget in the tab Manage form display:


XHProf not displaying runs but empty table

I found the problem, the developper module (used to activate XHProf) use the site name to generate the run. The site name contains the & character which messes up the URL corresponding to run.