Here is a better approach by using the following function which uses modifies display in node it-self:

/**
 * Attach node into panelized node.
 *
 */
function example_attach_node_to_panelized_node($pnid, $nid, $region = 'middle') {
  $result = FALSE;
  $node = node_load($pnid);

  // Set default region based on layout.
  if (!$region) {
    switch ($node->panelizer['page_manager']->display->layout) {
      case 'landing_page':
        $region = 'primary';
        break;
      case 'sub_landing_page':
        $region = 'main';
        break;
      case 'bootstrap_threecol_stacked':
      case 'onecol':
        $region = 'middle';
        break;
    }
  }

  if (!$region) return; // Check if matching type.

  $panes = array();
  $my_block_pane_exists = FALSE;

  // Load the display.
  $display = $node->panelizer['page_manager']->display;
  $did = is_numeric($display->did) ? $display->did : example_resave_display($node);
  if ($display = panels_load_display($did)) {

    // Check if our pane is already there, if so, ignore the further processing.
    $panes = $display->content; // Get this display's panes.
    foreach ($panes as $pid => $pane) { // Loop through and add in our new pane.
      if ($pane->type == 'node' && $pane->subtype == 'node' && $pane->configuration['nid'] == $nid) {
        // If our node already exists we can skip this.
        $my_block_pane_exists = TRUE;
        return FALSE;
      }
    }

    // Attach our new panel.
    $uuid = ctools_uuid_generate();
    $new_pane = panels_new_pane('node', 'my_node', TRUE);
    $new_pane->uuid = $uuid;
    $new_pane->pid = "new-" . $uuid;
    $new_pane->panel = $region;
    $new_pane->shown = 1;
    $new_pane->configuration['nid'] = $nid;
    $new_pane->configuration['build_mode'] = 'teaser';
    $new_pane->configuration['link_node_title'] = FALSE;
    $new_pane->configuration['links'] = FALSE;
    $display->panels[$region][] = $new_pane->pid;
    $display->content[$new_pane->pid] = $new_pane;
    // Or: $display->add_pane($new_pane, $sourcePane->panel);

    if (!$my_block_pane_exists) {
      // Finished reordering pane's and save the panelized node.
      $node->panelizer['page_manager']->display = $display;
      $node->panelizer['page_manager']->display_is_modified = TRUE;
      $result = node_save($node);
      // Clear ctools caches.
      ctools_include('object-cache');
      ctools_object_cache_clear('panels_node_display_cache', $pnid);
    }
  }
  return $result;
}

In case the display is not initialized yet (it's in new state), you've to re-save the display in order to perform above operations.

/**
 * Re-save panelizer display.
 * See: https://www.drupal.org/node/2537006
 *
 * @param
 *   $nid (integer)
 *     panelized node id
 *
 */
function example_resave_display($node) {
  $node = is_numeric($node) ? node_load($node) : $node;
  $display = !empty($node->panelizer) ? $node->panelizer['page_manager']->display : FALSE;
  if ($display && !is_numeric($display->did)) {
    $new_display = panels_save_display($display);
    $node->panelizer['page_manager']->display = $new_display;
    $node->panelizer['page_manager']->display_is_modified = TRUE;
    node_save($node);
    ctools_include('object-cache');
    ctools_object_cache_clear('panels_node_display_cache', $node->nid);
  }
  return is_numeric($new_display->did) ? $new_display->did : FALSE;
}

Sample usage:

example_resave_display(800); // Use only in case the node is new.
example_attach_node_to_panelized_node(800, 123);
example_attach_node_to_panelized_node(800, 124);

See also: Updating Panelizer content programmatically which the above functions were based on it.


It's impossible to say without knowing what exact template you are overriding, but you can't really convert your old PHP print statements to twig just like that.

What you can do however is put {{ dump() }} into your twig file, which is the twig equivalent to var_dump() in PHP. This will output all your available variables.

More info on {{ dump() }} here.


How to add unique identifier to each submission?

You want to use hook_webform_submission_presave to record your special key. I would create a hidden textfield in the Webform that is optional so the value can be set by your PHP code upon submission.

For a basically full working example see Webform Issue #1964080.

To create your special value such as AB-001-12345 you just make a php function that creates a random string, or a string to your specifications:

function generate_special_submission_key() {
  $length = 10;
  $str = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
  return $str;
}


You can create multiple page layouts using delta modules and use the same for required page.


Search api autocomplete - how to show search form?

There should be a block named Search box in admin/structure/block, i think it is the search box by default of drupal.

Remember that this block uses a view that returns a JSON, you can specify which view to use entering admin/config/search/search_autocomplete


Drupal Rules: How do I check if node is updated via edit form or via VBO?

This answer is slightly experimental as I have done something similar but not precisely the same. You may need to do further work, but here's the outline which will require a custom module that uses Entity API. What it does is create a custom node property which says where it was updated from:

Implement hook_node_submit() to check which form the node update has been submitted from and if it's a node_edit, add a custom member item to the node object, eg $node->is_node_edit = TRUE;
Implement hook_entity_property_info_alter() to add a custom property to the node entity type corresponding to the custom member as above.
Implement the getter callback you declared in that hook to be something like:

function mymodule_node_update_from_edit($data, array $options, $name, $type, $info) {
 $node = $data;
 return (boolean)@$node->is_node_edit;
}

You can then check the value of the property in a Rules condition.


I had a similar problem.

As described in the issue, we had the same problem in Drupal 7 with the "No front page content has been created yet" message. In Drupal 8, if you have no content on the page the default is to display the user page. If the user is not logged in, it defaults to the login page.

The best solution to this is to have content on the front page. However, assuming you want a blank front page except for some custom blocks, you can remove the Login Form by either creating or editing the existing
page--front.html.twig file in your theme.

Since you don't have any content on the front page, you can remove the "Content" region and then remove the "Header" region to remove the tabs.

EDIT: I just found that if you do remove the "Content" region from the page--front.html.twig file, this will also remove it from the login page, which is a problem. Not sure why this is. Still working on a solution.

Finally, make sure that you leave the "Front Page" setting blank = 'Manage > Configuration > System > Front Page'

These are the two blocks I removed from my theme

   {# Content #}
    {% block content %}

      {{ page.content }}
    {% endblock %}

  {# Header #}
  {% if page.header %}
    {% block header %}

        {{ page.header }}

    {% endblock %}
  {% endif %}


Getting parent enitity of enitityreference field

Something like this should work:

// Load wrapper
$wrapper = entity_metadata_wrapper($entity_type, $entity);
// Load parent entity
$parent = $wrapper->field_entityreference->value();
// Get nid
$nid = $parent->field_computed_field->value();
// Debug output
drupal_set_message(t('Parent NID: @nid', array('@nid' => $nid)));


Not able to reference Javascript functions inside jQuery wrapper

First off, onClick misses an = sign. Secondly, Chrome is right. From the point of view of the <a id="button"> element, the function is not visible even though it seems to be in scope of WelcomeScreen function. That's because it's not the function that invokes it, but the element on a page. Try onClick="Drupal.behaviors.interface.foofunction()". But better off - make it unobtrusive by removing the onClick attribute and saying at the document.ready level:

(function ($) {
    Drupal.behaviors.interface = {
    // code
    }

    $(function(){
      $('#button').live('click', Drupal.behaviors.interface.foofunction);
    });
})(jQuery)

Of course this is just a rudimentary suggestion, you might want to optimize the code further. If you're using jQuery 1.7+, you'd rather use .on() than .live().


Found this 5 year old comment in the issue thread that gives some more context. Not sure why the enhanced help text didn't make it into the 7.x module, but it helped me make the decision. https://www.drupal.org/project/date/issues/1358790#comment-6327490

  In order to display a date, a date object is created. Creating and caching date objects at the time date field data is entered may improve performance. For single-value, non-repeating, date fields caching will be neutral or have a performance benefit. For multiple-value or repeating dates with a large number of values, caching may negatively impact performance as some date objects that are cached may never actually be required.


You try code

$term_id = 1;
  $query = $this->connection->select('node', 'node');
  $query->join('node__field_country', "nfc", "node.nid=nfc.entity_id and (nfc.field_country_target_id=1 or nfc.field_country_target_id=2 or nfc.field_country_target_id=3)");
  $query->join('taxonomy_index', "tid", "tid.nid = node.nid AND tid.tid =".$term_id." AND tid.status = 1 ");
  $query->execute()->fetchField();


How to display Webform label Above the field instead of Inline in Drupal 8?

Ben, Let me know you webform version I can guide where you can get that option.

As of now I am using webform version 8.x-5.0-beta15 & it seems your requirement is available in this module. Below are steps for same

Choose Any webform. Click on edit of that webform you will see list of fields available in that webform.
Select any of the field and click on edit option provided. You will see one popup is opened.
On that popup if you scroll down little you will find your required option. Please refer attached screenshot.

Hope this helps.. :)


Create native Excel XLS and XLSX files from scratch and export directly to a PDF file

PHPExcel. It uses PHPExcel library and supports native Excel export, import. We are using it in our project and it does it well.

  The PHPExcel module allows developers to export/import data to/from real Excel files.

Print. It allows you to generate the printer-friendly, PDF, EPUB and Email versions of any node. It supports following libraries:

dompdf
mPDF (only in the 7.x-2.x branch)
TCPDF
wkhtmltopdf

I'd recommend using the dompdf library, since I'm using it an it does the job well.


How to change an address field that says "There is data for this field in the database. The field settings can no longer be changed."?

The message you see is for the settings of an existing field name "Adresse".  It tells you that you can no longer change its field settings.

There is nothing that prevents you from adding a new field named "Company" to the content type. Just go to the "Manage fields" tab for the content type, fill in the "Label" (i.e. Company) and other settings for the new field, click "Add new field" and then "Save".


How to change the default variant globally?

Typically speaking, the default product variation is the first value in the reference field. You can see this in action on a vanilla install by creating a product display that references multiple products and switching the order of the SKUs in the product reference field (easiest if you're using the autocomplete widget). I doubt there's a way to change the order of your field values en masse, and I'm not sure there's a safe SQL query we can pass on to you.

However, if you're similarly open to writing custom module code to solve this, you can do so using hook_commerce_product_reference_default_delta_alter(&$delta, $products). The products variable will be an array of the fully loaded products on the display and the delta value will be initialized to the first one and available for alteration. You can inspect the field values of the products in the array to find the one whose attributes match what you want the default variation to be and update the delta accordingly.

(If you just wanted to write a script to actually update the storage instead of doing this on run-time, you'd want to process your product displays one at a time and do a similar product load / field value inspection to move the items around in the reference field's values so delta 0 was your desired default variation.)


Feeds - How to set a blank source value programmatically

In the code where you run the importer you can only alter the field mapping.

To modify the field mapping configuration at that point to add custom data (you can also do things like remove fields from the mapping here):

// Load the importer.
$importer_id = 'my_importer';
$feeds_source = feeds_source($importer_id);
// Get the current field mappings.
$field_mappings = $feeds_source->importer->processor->getMappings();

foreach ($field_mappings as &$mapping) {
  // Add an arbitrary value to the mapping of my_field for
  // use later in the processor target callback.
  if ($mapping['target'] == 'my_field') {
    // Your logic goes here to populate this.
    $mapping['my_custom_value'] = 'My custom value';
  }
}

// Set the new field mappings.
$feeds_source->importer->processor->addConfig(array('mappings' => $field_mappings));
// Save the new field mappings.
$feeds_source->save();
// The previous call to FeedsProcessor::getMappings() cached
// the mapping, so we need to clear that before we run the import.
drupal_static_reset('FeedsProcessor::getMappings');

// Run the import.
$feeds_source->startImport();
while (FEEDS_BATCH_COMPLETE != $feeds_source->import());

Then to change the actual value that goes into the field, you have to do that at import time, when feeds is getting the value from the source and saving it to the target.

To do that you can implement hook_feeds_processor_targets_alter(), like this:

/**
 * Implements hook_feeds_processor_targets_alter().
 */
function my_module_feeds_processor_targets_alter(array &$targets, $entity_type, $bundle) {
  // Set a custom value setter callback for the my field on my node type.
  if ($entity_type == 'node' && $bundle == 'my_node_type') {
    if (isset($targets['my_field'])) {
      $targets['my_field']['callback'] = 'my_module_set_custom_field_value';
    }
  }
}

/**
 * Custom feeds target setter callback.
 */
function my_module_set_custom_field_value(FeedsSource $source, $entity, $target, array $values, array $mapping) {
  // Set the field value to our custom value if it's there.
  if (!empty($mapping['my_custom_value'])) {
    $entity->{$target}[$entity->language][0]['value'] = $mapping['my_custom_value'];
  }
}


I am not really sure what the difference between them is

menu_get_object() returns the object associated with the page currently shown. If the code is executed when Drupal is showing the page example.com/node/1, then menu_get_object() will return the node object for the node whose ID is 1; if the page being shown is example.com/user/1, then menu_get_object('user') will return the user object for the user whose ID is 1.
menu_get_item() returns an array containing an index for each field contained in the "menu_router" table. This includes:

path: the current path of the menu callback
load_functions: an array of function names (like node_load) to be called to load an object corresponding to a part of the current path
access_callback: the callback that checks if the currently logged in user has access to the menu item
page_callback: the name of the function that renders the page
title: the title for the page associated to the menu item

drupal_lookup_path() is the function that returns you the internal path associated with the alias passed as argument. If "homepage" is the alias associated to example.com/node/1, then drupal_lookup_path("homepage") will return "node/1". Path aliases can be associated to any internal paths, not only to node paths.

  and which is more appropriated to get the node ID in a block preprocess function.

If all you want to get is the node ID of the node currently shown, then you just need to use the following code:

if (arg(0) == 'node') {
  $nid = arg(1);
}

If you need to get the node object, then you can use the following code:

if ($node = menu_get_object()) {
  // Use the node object.
}

Of those snippets, the second is better, as it returns the correct node object for internal paths such as node/1/revisions/3/view.

Keep in mind that some preprocess functions, such as the ones for the page, or the node, have already a $variables['node']. This means that in those cases, you just need to use the following snippet in your preprocess function, without worrying about which function to use.

if (isset($variables['node'])) {
  // Check the node ID or other properties.
}

For other preprocess functions, check the documentation to see if there is any variable containing the node object. For example, that is the case for template_preprocess_comment() which makes $variables['node'] available to the preprocess functions for comments.


How to change the value of the publishing status checkbox to false by default?

Simply edit your content type's default publishing options under example.com/admin/structure/types/manage/MYCONTENTTYPE (Structure > Content types > MYCONTENTTYPE > Edit).


Copying over all the elements to a new page

If your events are part of a content type, then try this module. It should let you clone a node

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


Webform Serial - Serial Numbers updating after editing submission

I was going to suggest placing an issue on the project page-it seems like it would be a common issue-but you've already done so. If the maintainer doesn't respond, you could look at the code yourself to figure out why and create a patch for it.


How do I alter the behavior of the form fields contained within the paragraph field?

Since paragraphs^1.3 you can use hook_field_widget_WIDGET_TYPE_form_alter() (I linked the 8.2 version because there is a good comment about using the hook).

You can see the following example in modules/contrib/paragraphs/tests/modules/paragraphs_test/paragraphs_test.module

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function paragraphs_test_field_widget_entity_reference_paragraphs_form_alter(&$element, &$form_state, $context) {
  if ($element['#paragraph_type'] == 'altered_paragraph') {
    $element['subform']['field_text']['widget'][0]['#title'] = 'Altered title';
  }
}


What are the photo gallery/album module choices for Drupal 7?

An album essentially is a grouping of like nodes.

In drupal this grouping can be done a number of ways. I would suggest using a fixed taxonomy (not free tagging) for the album. This way views can list list all photos (nodes) from a particular tag and you can create thumbnails for instance for display.

You could also group by author for another group of nodes (e.g. 'my photos')


Display different fields based on a URL parameter

Use a custom module. Implement hook_menu to declare a page handler for your path pattern that return the value of field_view_field().

function MODULE_menu() {
  $items = array();
  $items['section/%node/%'] = array(
    'title callback' => 'node_page_title',
    'title arguments' => array(1),
    'page callback' => 'MODULE_node_field_page_view',
    'page arguments' => array(1, 2),
    'access callback' => 'node_access',
    'access arguments' => array('view', 1),
  );
  return $items;
}

function MODULE_node_field_page_view($node, $field_name) {
  if ($node->type !== 'section' || !field_get_items('node', $node, $field_name)) {
    drupal_not_found();
  }
  else {
    return field_view_field('node', $node, $field_name)
  }
}

Then use alias and pathauto to use path like section/{node-title}/{field_name} instead of numeric node id in URL.


how should I add textfield ie jump pagination in views mini pagination of drupal

Try the Pretty Pagination module . I think This is what you are looking for.

This module extends the default pagination into a more flexible format. It allows the user to jump to any specific page in the content just by entering the desired page number in an input box and hitting the ENTER key. The result is easier navigation, especially with sites where the content is spread over numerous pages.

Another module is
Pagerer module. Using this module you can give direct input of the page to go to through a jQuery UI Slider.

Pagerer is a module providing a collection of pager themes to enhance Drupal and Views standard pagers.
Features:

multi-pane pager

Views pager plugin

control whether to display links to pages, to items, or to item
ranges

direct input of the page to go to through an input widget

selection of the page to go to through a jQuery UI slider

selection of the page to go to through a client-side scrolling pager

links to progressively more distant pages (like +10, + 20, +100,
+200)

adaptive logic links

specify text to be used to render page separators (like a vertical
bar) and page breakers (like an ellipsis)

supports Views' AJAX enabled pager


Might this help... http://www.xandermar.com/blog/may-20-2014/using-drush-proxy ?

(sorry, I know this is more of a comment, but I don't have the points!)

If not, have you run the drush commend in verbose mode to get more info?


I think you need to reset the collection first, as the ::loadLinksByRoute() annotation states that it returns an array of MenuLinkInterfaces[].
See /core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php:

  /**
   * Loads multiple plugin instances based on route.
   *
   * @param string $route_name
   *   The route name.
   * @param array $route_parameters
   *   (optional) The route parameters. Defaults to an empty array.
   * @param string $menu_name
   *   (optional) Restricts the found links to just those in the named menu.
   *
   * @return \Drupal\Core\Menu\MenuLinkInterface[]
   *   An array of instances keyed by plugin ID.
   */
  public function loadLinksByRoute($route_name, array $route_parameters = [], $menu_name = NULL);

So do something like:
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$menu_links = $menu_link_manager->loadLinksByRoute('entity.node.canonical', array('node' => $node_id));
// Reset collection by retrieving the first item.
$menu_link = reset($menu_links);
// Now call the parent method.
$parent = $menu_link->getParent();


Does "hook_ENTITY_TYPE_load" have performance advantages over "hook_entity_load"?

The only difference is that hook_entity_load() is invoked for every entity loaded, while hook_ENTITY_TPE_load() is invoked for every entity for which the entity type is ENTITY_TYPE.
If a module implemented hook_entity_load() only to handle a specific entity type, or a group of entity types, but not every entity type, its hook_entity_load() implementation would need to check which entity is being loaded, but since the second argument passed to the hook ($entity_type_id) is the entity type, checking that isn't time consuming nor a performance issue.

As for using hook_entity_load() or hook_entity_storage_load(), the second hook is invoked for content entities (not configuration entities) with a storage handler that saves the data in the database. In the other cases, including entities loaded from the entity cache, only hook_entity_load() is invoked.


How to filter paragraphs by the field name on parent using entityQuery?

Specifically with Paragraphs there are three extra fields directly on Paragraph level, which are accessible with EntityQuery: parent_id, parent_type (entity type like "node", not bundle name like "page"), parent_field_name
You can use those three with EQ like a normal field, e.g.
->condition('parent_field_name', ['field_a', 'field_c'], 'IN')

Notice that those three fields are only available for Paragraphs, it will not work with any other entity type.


Given the commentary above, all you should need to do is cascade your class/table, eg, something along the lines of...

.listView table {
  border: 0;
  border-spacing: 0;
  margin: 10px 0;
  width: 100%;
}


WYSIWYG only shows in administration theme

This is happening because you have an input format associated with the editor that is only available to your admin users. You need to either make the input format available to other roles on your site or expand the formats that the WYSIWYG editor displays on.


Executing JS calls during user login validation (Drupal 7)

You could add a validation hook to the user login form & block to add the javascript if the fields fail to validate.

So to alter the form:

function MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  // Add the validate function
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    // Add your javascript that contains Drupal.behaviors
    drupal_add_js(drupal_get_path('module', 'MODULE_NAME') . '/MODULE_NAME.js');
    $form['#validate'][] = '_MODULE_NAME_user_login_validate'; // this is the function name
  }
}

Then in your validation function:

function _MODULE_NAME_user_login_validate($form, $form_state) {
  // Do your field validation here, I'll only showcase one of them (username)
  if(!valid_email_address($form_state['values']['name'])) {
    // Add a setting to the Drupal.settings variable available in javascript
    drupal_add_js(array('MODULE_NAME' => array('name' => FALSE)), 'setting');
  }
}

Finally in your MODULE_NAME.js file you can check to see if the setting was set:

if(Drupal.settings.MODULE_NAME.name == FALSE) {
  wrong_email();
}


Required Modules by Translation Management Tool (tmgmt)

A explanation on what these modules do

Entity API: Provides API functions that makes working with entities easier (e.g. tokens for entity fields, CRUD functions, etc.). There's no visible functionality here.
Views: Provides a way to select into data tables (e.g. users, nodes, etc.), filter them, and display the data in different modes (e.g. as page, block, RSS feed, etc.)
CTools: A suite of API/utility functions to help with development tasks (e.g. creating modals, handle AJAX requests, etc.). The only visible functionality is Page Manager, a UI that allows you to override URLs paths with a different display).
Views Bulk Operations: Adds an option to Views to select multiple items and perform an operation on them (e.g. bulk unpublishing selected nodes).
Content Translation: A core Drupal module that enables the ability to translate node content into other languages.
Locale: A core Drupal module that enables the ability to translate the interface (e.g. button & label names).
Internationalization: A suite of UI tools that extends out Locale to provide more control with interface localization.
Entity translation: Provides a UI for the Content Translation module.
Rules: Provides UI and API for enforcing workflow. These enforcements are called Rules which has 3 parts: an event (something thing happened to your data), a condition (checks on the data to see it matches your scenario), & action (actions to take to enforce your workflow on your data).

There's much more to these modules than what a couple sentences can provide. Read the respective documentation pages for more information.


Drupal mobile theme doesn't display image

I have just found the solution: It was just a permission that wasn't given to the anonymous user.


How can I add an existing field to a new content type?

You can find an option to select existing field under the list of fields :


How to avoid invoking the same module every time when I have to call a function of that module in Drupal 7?

You're calling the same function over and over, that's true. But the parameters are different, so from a pure programming point of view, the processing could be completely different. I don't see another option to approach this.

Is it a good idea to use the module_invoke() every time when I have to call hook_block_view() with different arguments?
Yes
Is there any other function that can be used for calling the same function or any other function in the module after one- module_invoke()? Not that I'm aware of
Is there any other way of doing thing? I don't think so

More specifc, some functions allow passing an array of arguments instead of one. Eg node_load_multiple allows to pass 1 nid or whole list of nids. But hook_block_views doesn't allow this.


Prefix html before radiobutton (input field)

You can override the theme_radio function in your own theme :

function mytheme_radio($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'radio';
  element_set_attributes($element, array('id', 'name','#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-radio'));

  if ($its_my_field) {
     return '<input' . drupal_attributes($element['#attributes']) . ' />';
  }
  else {
     return '<input' . drupal_attributes($element['#attributes']) . ' />';
  }

Maybe try with the more generic function theme_form_element.

Make sure to add conditions to only affect the form or the element you need like in the example written above.


Have a look at this module: Pathologic

  Pathologic is an input filter which can correct paths in links and
  images in your Drupal content in situations which would otherwise
  cause them to “break;” for example, if the URL of the site changes, or
  the content was moved to a different server. Pathologic can also solve
  the problem of missing images and broken links in your site’s RSS
  feeds. See more example use cases on the documentation page.


"$ch1" contain tids.

The function "taxonomy_get_children($ch1);" retrieve all children term id and not related nid...

You can retrieve all nid linked with a term with this function taxonomy_select_nodes

I will suppose $ch1 contain your tids in an array

foreach($ch1 as $tid){
    $nids  = taxonomy_select_nodes($tid);
    $nodes = node_load_multiple($nids);
    foreach($nodes as $node){
        $link = l($node->title, 'node/' . $node->nid)."<br>";
        print $link;
    }
}

I can't test this code, if it's valid tell me and i will remove this line :)


How to add any plugin to ckeditor manually?

The manual process is described on that plugin page itself, as you can see on the instruction page in first image(red circle.)

If you click that link which you have provided in your question, you can see the Download option on that page. If you click it will download and it will open up a new pop-up window.

1. As you can see in the image. Copy that file and paste to that path.

So, I did copy and paste at at module/ckeditor/plugins/ckwebspeech

2. Now second step says, put this code config.extraPlugins = 'ckwebspeech'; So, I went to admin/modules/ckeditor/config. I did choose either Full or advanced, whichever my site is using. Clicked edit, went to Advanced options And paste the second step as shown in the step-2. Saved it ans clear the cache.

3. Now again went to same place at described in step-2. Instead of Advanced option went to Editor appearance and move the webSpeechSetting and webSpeechEnabled button to the custom toolbar as shown in following image.

4. Now if I scroll down further on the same page, I will have all option of the plugins then I enabled that plugin as shown in following image.(see second option which i checked). Saved cleared cache.

5. Now went to any page where I can see my editor, and, it showed up in editor.


Is the Search API module able to do range facets on numeric values?

commerce_search_api sounds like exactly like what you're looking for.  Be aware of the commerce >= 1.4 dependency as of this writing.

The module includes a product display index (configurable at admin/config/search/search_api/index/product_display):

  Auto-generated search index that includes all product display node    types* and related product data.
  Auto-generated facets for all node type categories and product attributes.

I've used the price facet filters, with and without the search_api_ranges widget, with great success.


CKEditor Inline Styles Getting Removed on save

You write:

  Nevermind, this is only happening on filtered.

Sure!  The Filtered HTML text format is supposed to do that.

For CKEditor, you need to configure the WYSIWYG filter module to retain inline styles (Unless you allow users to use the Full HTML text format. This is not recommended as it is insecure. The Full HTML text format lets unfiltered user input pass into rendered content.)

I am written up a short cookbook about configuring CKEditor for Drupal, including how you configure the CKEditor ACF and the the WYSIWYG filter text filter to give your users the power of the CKEditor without jeopardizing security.

Here's a link to my CKEditor cookbook.


User Reference field with full list of users, but with current user as default selected value

Using hook_form_alter():

function example_form_alter(&$form, &$form_state, $form_id) {
    global $user;
    if ($form_id === 'my_form') {
        $form['field_user']['#default_value'] = array($user->uid => $user->name);
    }
}

Not tested, but it's the idea.


OK, I have this figured out, I think I just got confused by instructions and getting ramped up again on the ways of Drupal. Anyway just to leave a clear answer. All subthemes will be called MYTHEME. In my template.php in my subtheme I altered the form and then added hook to my new form wrapper:

function MYTHEME_form_alter(&$form, &$form_state, $form_id) {
if($form_id) {
    switch ($form_id) {
        case 'search_form':
            dpm($form);
            $form['basic']['keys']['#theme_wrappers'] = array('MYTHEME_search_form_wrapper');
            break;
    }
  }
}

function MYTHEME_theme(&$existing, $type, $theme, $path) {
  $hooks = array(
      'MYTHEME_search_form_wrapper' => array(
      'render element' => 'element',
      'file' => 'MYTHEME-search-form-wrapper.func.php',
    ),
  );

  return $hooks;
}

In this I copied the original wrapper file and made my changes, you could just copy the method and add it to your template.php anyway here's that method, referenced earlier as 'MYTHEME-search-form-wrapper.func.php':

function MYTHEME_MYTHEME_search_form_wrapper($variables) {
  $output = '
';
  $output .= $variables['element']['#children'];
  $output .= '';
  $output .= '<button type="submit" class="btn btn-default">';
  // We can be sure that the font icons exist in CDN.
  if (theme_get_setting('bootstrap_cdn')) {
    $output .= _bootstrap_icon('search');
  }
  else {
    $output .= t('Search');
  }
  $output .= '</button>';
  $output .= '';
  $output .= '
';
  return $output;
}

Key here is having the subtheme name twice in the method call. The instructions I found on this didn't give an explanation on why that needs to be. I'll try to find relevant information.


reCaptcha has blocked me out of my website

If you can use SSH, or other shell, it's easy:

Install Drush. On Ubuntu, follow this document. Or simply unpack it and add it's directory to system's PATH variable (OS dependant).
Enter your Drupal's directory
Execute drush dis recaptcha

I strongly advise this approach, it may be a bit hard to set up initially, but drush is a powerful tool that can help you in future.

If you cannot, but you can use SQL client, it's not so bad too:

Login to your Drupal database with your SQL client
Back up your entire database
Execute UPDATE system SET status = 0 WHERE name = "recaptcha";

In both cases, you should be able to login, and uninstall reCaptcha module via UI to get rid of messed configuration data.


Separate panels variants for 'edit' & 'add' nodes of same type

Try using String: URL path in variant Selection Rule.

Edit path: "node/*/edit"

New path: use your content type path (node/add/your-content-type)


exception 'TwitterException' with message 'Bad Request'

I actually had a lot of trouble setting the Twitter module up on my localhost for testing, so I just created a blog post about how to set that up, that includes some tips on doing this with localhost: http://drupalwoo.wordpress.com/2013/04/22/how-to-show-tweets-from-your-twitter-account-on-your-drupal-website/

Here are the couple of things that I think my be relevant for you to check:

If you’re testing on localhost, use the following urls for your website and callback URLs (don’t worry, these are just placeholders, and your drupal site will send the correct callback URL when it connects):

Website URL: http://127.0.0.1:8000/twitter/oauth
Callback URL: http://127.0.0.1:8000/twitter/oauth

If you’re still getting errors when testing with localhost, make sure the version of the module you’re using has the patch #5 on this issue queue: http://drupal.org/node/1924478#comment-7260928 (if you have an older version of the module, prior to the incorporation of the patch, get the latest stable/dev release that includes it and uninstall and install the module)


Contrary to CSS/JS the itok is not for caching, but for DoS protection, see this question
Why are tokens added to image URLs?

The token is generated in
https://api.drupal.org/api/drupal/core%21modules%21image%21src%21Entity%21ImageStyle.php/function/ImageStyle%3A%3AgetPathToken/8.2.x


How to send e-mail to node author 1w before date field in node?

Requirements
Rules, Rules UI, Rules Scheduler, Date, and Date API modules
Add date field
Go to your content types Manage Fields and add a field of type Date.
I called mine Deadline, machine name: field_deadline
Create a Rule
Action: After saving new content
Type: Article

This is all you have to do for now, will get back to this rule later.
Create a component
Component Plugin: Rule

Component action

Add action of Fetch Entity by Property

Add action Send Mail

To: [author-email:0]

Edit your Rule now

Add action of Schedule component evaluation. In SCHEDULED EVALUATION DATE click on the grey switch to data selection button. (not visible in screenshot since I already click it)

Testing
Go to the components tab and click on schedule

You'll need to click those grey switch to ...  buttons to get it to look like mine.
Put a node ID in the last one.

Important
Your e-mail will get sent once the time has been reached, but also once cron runs. So if your cron runs once a day, it may not get sent until the day after, so you may need to adjust your cron to run more often.
You might want to use Ultimate Cron so you can schedule specific crons to run at different intervals, instead of running everything every x minutes, days, hours.


Hook_form_FORM_ID_alter problems with custom validating

I think you need to write

    if (in_array($form_state['values']['pass'], $badpasswords)) {
        form_set_error('pass', t('Please use a more secure password!'));
    }

$form_state['values']['pass'] instead of $form['values']['pass']


I followed below steps and it is working when I cancel account by "delete user and its content"

/**
 * Implements hook_user_delete().
 */
function MYMODULE_user_delete($account) {
  watchdog('MYMODULE', 'hello, user: !username, user id: !uid, has been deleted', array(
    '!username' => $account->name,
    '!uid' => $account->uid
  ));
}

Go to admin/reports/dblog
check if the message displayed there. Mine is showing.


The problem was a setting in the admin/content/node-type/[your node type]/display (Display Fields settings). The "Print" tab was set to show the images, but PDF uses the "Basic" settings. Changing the "Teaser" setting to "thumbnail" fixed the problem.


The entire page is being cached, so you'll want to disable caching on those pages that have dynamic elements. I think you'd want to:

a) turn OFF page caching for the needed paths (http://drupal.org/project/cacheexclude)
b) turn ON caching for any Views, blocks, or whatever else you can cache on those pages to save bandwidth

Then you'll have more granular caching control.


you connect the the fuzzy search via search api pages module (or views).

when using views you can place the views search block in your desired region.

Manual instructions: (from fuzzy search)

From the main Search API configuration page, create a server using the Fuzzy Search service class.
Create an Index using the server you just created.
Click the Workflow Tab.
Enable "Complete entity view".
Enable the following processors: Both Fuzzy search processors, Ignore case, HTML filter, and Tokenizer.
Move the Fuzzy Search excerpt processor to the bottom of the list, and the Fuzzy Search search settings processor just above it.
The default settings should be fine.
You will need the Search API Pages module or Views to provide a place to search your site.
Go to the main Search API page,
Click Search Pages, add a search page, and configure with the index you created above, multiple terms for query type, and view mode as themed as search results.
For Views, make a new view using the default fuzzyseach index, add a page display and configure as desired.
Run cron to index your content. Visit the path for your search page.


I would instead use views_get_view_result() if all you are concerned with is if there is a result.  More information on it can be found here.


The page you are referring to, admin/config/people/rpx, is defined in the module named Janrain Engage UI, machine name rpx_ui. You need to have it enabled for the path to be registered.


How to attach a view attachment display to an Openlayer Data Overlay display?

The proposed scenario works just fine if you attach the attachment display to the OpenLayers Map display instead of to the OpenLayer Data Overlay.


Programatically change the base theme of the current theme

So as it turns out an info.yml file can be altered inside HOOK_system_info_alter

To change the base theme definition of an existing theme you can use the following

function HOOK_system_info_alter(&$info, $file, $type) {
  if ($type == 'theme') {
    if ($info['name'] == 'YOUR THEME NAME') {
      $info['base theme'] = 'NEW_BASE_THEME_NAME';
    }
  }
}

As this hook is only fired when caches are flushed there is no need for a separate cache flush after the change is made.


Digest of suggested content based on user activity

This wiki page on d.o has a review of some relevant contrib modules.
http://groups.drupal.org/node/12347


Rules parameter description to appear in different lines

This should work

 $descp = "line1 </br> line2";

 $items['my_custom_action'] = array(
    'label' => t('Some Label'),
    'triggers' => array('any'),
    'named parameter' => TRUE,
    'parameter' => array(
      'par1' => array(
        'type' => 'list<text>',
        'label' => t('Select an option'))),
        'options list' => array('1' => t('Option1'), '2' => t('Option2')),
        'description' => t($descp),
        'restriction' => 'input',
      ),
    ),
    'group' => t('My own group'),
  );


Workflow is the following:

Create category admin/config/services/simplenews
Add newsletter node/add/simplenews (Choose category beneath body)
go to node/%/simplenews and send it


How to theme the separate page for editing profiles provided by Profile2

Change where it says customtheme to the actual theme name you are using.

for example if you are using bartik:

function bartik_theme() {
'path' => drupal_get_path('theme', 'bartik') . '/templates',
'preprocess functions' => array(
         'bartik_preprocess_user_profile_form'
    ),

The files should be located in your theme folder.


How to prevent a node being saved when using the Rules module?

I would try to use the Conditional Rules module for this. Some more details about this module (from its project page):

  ... provides Rules plugins for conditionally altering execution flow directly inside a group of actions.

So create a rule in which you add these actions:

Conditional (which you add via the 'Add conditional' link at the bottom)
If Condition (which you add via the 'Add If' link to the right of the 'Conditional' action, and 'Condition' is what you mentioned in your first rule already).
Redirect & set message (which you add via the 'Add Action' link to the right of the 'If' action, and 'Redirect & set message' is what you mentioned in your first rule already).
Else (which you add via the 'Add Else' link to the right of the 'Conditional' action.
Calculate & set value (which you add via the 'Add Action' link to the right of the 'Else' action, and 'Calculate & set value' is what you mentioned in your second rule already).

Here is a screenprint of a rule with an action that uses Conditional Rules (though only with an "if"-part here, no "else"):


Abstract Base Class versus Service with Queue API

I would suggest an abstract base class, but instead of creating another function ::doSomethingCommon, partially implement ProcessQueueBase::processItem and call parent::processItem from the subclasses.


500 error on one page in entire site only showing error "You are here" instead of administration content

If you have shell access to your server, you could check the actual php error logs on the server- which should indicate the exact culprit.

If you recently updated Drupal core or some contrib modules, you may want to make sure the update process completed successfully.

Also, if you were editing/adding a custom feature module, content types, field collections, paragraph bundles, or other entities referenced by the specific "People" content type, you may have accidentally removed a required field that could cause the page to break- in which case, restoring a backup database could fix the issue.


Caching $_SESSION data for anonymous users

I think your best option is to use 2 cookies. Set one cookie that checks to see if the browser has JavaScript enabled. If JavaScript cookie is not there, the user gets an uncached page. If JavaScript does exist then drop a cookie containing the session data. Do the uncached page check in your settings.php file.

If you have something like Varnish or Nginx on your web stack, checkout ESI as it can work how you want it if the browser doesn't support JavaScript.

Also checkout http://drupal.org/project/authcache as it might be what you're looking for (minus the JS part...)


how to achieve a sliding effect to show the rest of elements in a grid, with views

Here is an example of jquery slide show.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <title>jQuery Animating an Element</title>

        Animating an Element

Animate Me

    <button id="right">Grow Right</button>
    <button id="text">Big Text</button>
    <button id="toggle">Move Div</button>


I fact all you need is

hook_facet_items_alter(&$build, &$settings);

There you can change the queries and hide/show other facets like

      $build['A']['#markup'] = 'NewA';
      $build['A']['#count']  = $build['A']['#count'] + $build['B']['#count'];
      $size = count($build);
      $build['A']['#query']['f'][$size] = 'field_filter:B';


I want to allow users to click "share this" on a page with an image, and then email that image as an attachment

If you are willing to write your own module, check out the mimemail module. Sending the mail is as easy as this:

mimemail($sender, $recipient, $subject, $body, $plaintext = NULL, $headers = array(), $text = NULL, $attachments = array(), $mailkey = '')

If you store the picture in a imagefield or filefield inside a node, you can put that field into the attachments array and send it.


How can I create a custom user profile page without overlapping the registration and login pages?

One approach is to create a custom template file for the user.

add a bit of code to your .theme file:

MYTHEME.theme:

function MYTHEME_theme_suggestions_user(&$suggestions, $variables, $hook) {

  // Define the view mode.
  $mode = $variables['elements']['#view_mode'];
  // Create a theme hook suggestion which has the view mode name in it.
  $suggestions[] = 'user__' . $mode;

}

The above tells Drupal to look for template files that fit the new naming conventions.

Then create a twig template file in MYTHEME/templates:

user--full.html.twig

    {% if content.user_picture | render %}
          {{ content.user_picture }}
    {% endif %}

    {% if content.field_name | render %}

{{ content.field_name }}

    {% endif %}

The above html is just an example.

Now you have unique markup for just the user profile page in Drupal. From there it's just a matter of choosing fields, and adding styling.

Make sure to clear cache so Drupal will register your new twig file!


How does CSS and JS aggregration work in Drupal?

CSS/JS files get added to Drupal various ways; 5 out of the 7 ways allows for the file to be aggregated. Once they have been added to the page, drupal renders the html markup for them and creates/uses the markup inside of template_process_html().

Functions to look for how an aggregate is built is drupal_build_js_cache() & drupal_build_css_cache(). Inside of these function it gets a list of filenames and then creates a hash of them. This is a lookup, to see if the file has already been created.

  $map = variable_get('drupal_js_cache_files', array());
  // Create a new array so that only the file names are used to create the hash.
  // This prevents new aggregates from being created unnecessarily.
  $js_data = array();
  foreach ($files as $file) {
    $js_data[] = $file['data'];
  }
  $key = hash('sha256', serialize($js_data));
  if (isset($map[$key])) {
    $uri = $map[$key];
  }

If it has not been created before, because of the order and/or contents of the $file['data'] info then it will create a new aggregate based off of all the files contents strung together.

  if (empty($uri) || !file_exists($uri)) {
    // Build aggregate JS file.
    foreach ($files as $path => $info) {
      if ($info['preprocess']) {
        // Append a ';' and a newline after each JS file.
        $contents .= file_get_contents($path) . ";\n";
      }
    }
    // Prefix filename to prevent blocking by firewalls which reject files
    // starting with "ad*".
    $filename = 'js_' . drupal_hash_base64($contents) . '.js';
    // Create the js/ within the files folder.
    $jspath = 'public://js';
    $uri = $jspath . '/' . $filename;
    ...
    $map[$key] = $uri;
    variable_set('drupal_js_cache_files', $map);
  }
  return $uri;

The files are kept track inside of 2 variables drupal_js_cache_files and drupal_css_cache_files; Drupal will also check to make sure the file exists before it is used. The aggregates have nothing to do with the URL. Your 4 webheads will utilize these aggregates due to the variables being stored within the database.

Note: AdvAgg is sorta similar to this but it uses a couple database tables instead of 2 variables; AdvAgg does this for a couple of reasons mainly to fix issues with concurrent variable_set's and allowing for advanced grouping logic.


Code to fetch Stores of a user -- Replace node_type with your node type...

global $user;
$result = db_query('SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = :uid and type = :type', array(':uid' => $user->uid, ':type' => 'node_type'));
// Result is returned as a iterable object that returns a stdClass object on each iteration
foreach ($result as $record) {
  // Perform operations on $record->title, etc. here.
  // in this example the available data would be mapped to object properties:
  // $record->nid, $record->title, $record->created
}

Create a Custom Form -- Form API Reference

Create two fields

Select Field - Options Source - Run a query against node table to get list of node id's given user id filtered by type and status of node
Offer Request - Text Area

On Submit handler
Read Select Field Values , Offer Request Text
Send Email to admin using hook_mail


How to force redirect user to www.domain or http://domain in a nginx environment?

I wouldn't think that Drupal would handle it any different that another setup, ie.. creating another entry for the non-www version with a redirect:

server {
  listen       80;
  server_name  example.com;
  return       301 http://www.example.com$request_uri;
}

server {
  listen       80;
  server_name  www.example.com;
}


You'll need to change the nid manually in the database.
As far as I know, only the D7 node_save() allows you to specify the nid during initial save (because it allows you to set $node->is_new as well instead of overriding it).

And no version will ever allow you to change the nid in an update.


Displaying Special Characters and Letters in Drupal 7 Site

Try installing the languages in which you display the data. To do so go first install the "Languages" module which is already part of the core and then go to admin/config/regional/language and install any language with it.

If it's not in a formal language, try changing encoding by using this article:

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

Though, they mention in that document that it's problematic to change Drupal's encoding.

If showing these letters is rare, consider displaying these as an image.


Add a filter of your color field and expose the filter.

Enable ajax for your view, it's listed under Advanced.

There is a catch though: I believe this only works for page views only and not for block views.


Creating Sign Up form for 2 types users in Drupal 7

Sounds like a way to go. Additionally you may use the Rules module to redirect the seller to the profile page and the LoginToboggan module to login users immediately after registration. Also some Spam bot prevention may be useful. Generally I consider registration without user approval (by email) as harmful: A user can easily register himself in the name of another person. Drupals double opt-in usually helps to prevent that. LoginToboggan can delete users which did not approve their registration after x days.

Anyway here is a potentially cooking list:

Add two roles: Buyer and Seller.
Use the Auto Assign Role module to let the user choose between Buyer and Seller at registration time.
Use the LoginToboggan module to login the user immediately after registration.
Create a profile for Sellers using the Profile 2 module. Use Drupal permissions to make it accessible by Sellers only.
Use the Rules module to redirect Sellers to their profile page if they have no profile yet.
Optionally use the CAPTCHA module to prevent spam bot registrations.


You could also define your own 4-column panel. There are instructions here: Panels 3: Creating a custom layout in your theme, and a more specific tutorial available here: Creating a four column layout for Panels 3 in Drupal 7.


element_children() is the easiest way to get a list of all child elements in a render array, e.g.

foreach (element_children($form['field_...'][LANGUAGE_NONE]) as $key) {
  $element = $form['field_...'][LANGUAGE_NONE][$key];
}


Try this out :

use Drupal\views\ViewExecutable;

/**
 * Implements hook_views_pre_build().
 */
function customModule_views_pre_build(ViewExecutable $view) {
  if ($view->id() == 'your_view_id') {
   //- Set the new limit here // 3
   $view->setItemsPerPage(3);
  }
}


How to minimize conflicts in hook_update_N implementations with multiple developers?

A low tech solution I can think of would be to set up a wiki page where developers can "reserve" hook_update_N numbers for that site, and set up a procedure that everyone has to go to that page first and check for the next available number before starting work on an update hook.


What you could try is:

use hook_mail_alter() to check when mails have been send and store the information you need in a special table of your own module. Maybe the information in the $message is enough for you. If not you could try:

hook_fom_alter() to add an extra submit-handler to the contact form like this:

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

Inside my_custom_submit_handler($form, &$form_state) you should have full access to the form fields and store everything you need like you want to.


Exposed Form Block results on another Panel page

In my theme's template.php I did the following which seemed to work

/**
 * Implements hook_form_alter()
 */
function cmfzen_form_alter(&$form, &$form_state, $form_id) {

  // change the main search form
  // see http://drupal.stackexchange.com/questions/28404/easiest-way-to-add-x-webkit-speech-to-the-search-blocks-input-element
  // see http://adaptivethemes.com/html5-placeholder-text-for-your-drupal-7-search-field
  if ($form_id == "views_exposed_form" && $form['#id'] == "views-exposed-form-site-search-page"){
    // dsm($form);
    // redirect to a panels page with an embedded search_api view with facets.
    $form['#action']='hello';
    $form['site-search']['#type'] = 'searchfield';
    $form['site-search']['#attributes'] = array(
      'class' => array('search-site'),
      'placeholder' => t("I'm looking for..."),
      'speech x-webkit-speech spellcheck' => 'false',
      );
    // change form submit button
    //$form['submit']['#type'] = 'button';
    //$form['submit']['#value'] = '';
    $form['submit']['#attributes'] = array('class' => array('search-button'));
  }
}

Notice the part $form['#action']='hello'; ?
Make sure your using the right formid and also change "hello" to whatever page you want the results to go to

Maybe that will lead you in the right direction?


You don't need the drush. download the latest version, remove the /sites folder from the downloaded files and then simply copy and replace the files with the existing ones.


I suggest hide default edit tab and create a tab set with Quick Tabs module.I mean bypass default drupal menu tab( or hide it completely ) and create your own . this module help you to create a quicktab set that click on each item don't need page getting refresh.

  The Quick Tabs module allows you to create blocks of tabbed content,
  specifically views, blocks, nodes* and other quicktabs*. You can
  create a block on your site containing multiple tabs with
  corresponding content. Clicking on the tabs makes the corresponding
  content display instantly, using jQuery. With the 6.x-2.x branch, this
  can be done in either ajax or non-ajax mode:

if you choose ajax mode for your Quick Tabs block (and this is chosen on an individual QT basis), only the content of the active tab

  will be loaded on page load and the content of the other tabs will be
  loaded via ajax on tab click (this is good for performance if you are
  loading, for example, several large views)
      in non-ajax mode the tab content is just hidden / shown on tab-click. This latter method is an ideal way to do something like the
  Most Popular / Most Emailed stories tabs you see on many news
  websites, where it is used more as a space-saving device in your
  sidebar. If however, you want a QT block as the main content of your
  entire page, then the chances are that ajax mode will be more
  appropriate.

  Once created, the Quick Tabs blocks show up in your block listing,
  ready to be configured and enabled like other blocks. Multiple Quick
  Tabs blocks can be placed on a single page.

  For theming of the tabs, several styles have been provided for you to
  choose from (in the 7.x-3.x branch this functionality comes in a
  separate submodule, Quicktabs Tabstyles), along with the default
  option of no style, if you prefer to add your own theming instead.


Can I creat a View output using the root path?

Your view will need a path set, in this case 'home' and then within your site's Site Information settings just set 'home' as the Default front page (for Drupal 7 got to http://www.yoursite.com/admin/config/system/site-information).

When you access the URL of your site you will see your View, setting the homepage menu link to '' will also direct users to your homepage without adding '/home' to the URL.


How to display instances of a field (field collection) in tabs?

Someone up there likes you...
Field Collection Tab formatter

Field collection tabs provides a field formatter that allows you to output a multi value field collection field as a tabset, with one tab per field collection item.
Features
You can optionally choose a field from the field collection item to be used as the tab title.

It's uncannily close to what you're asking for. Your question might as well have been the user story that inspired that module :)


Preprocessing function for specific view by name

you have to implement hook_theme function to make views aware of your custom preprocess theme function. You can find a tutorial on this here: http://www.appnovation.com/blog/theming-view-within-your-module


How to batch upload images and generate multiple images

To upload more than one image to a field you can change the number of values the field will accept:

To get a photo album configuration you could also look at the node_gallery module, or roll your own arrangement.

The plupload module will allow you to select multiple images to be uploaded into a single field through one upload process.


You could try adding a "Global: Null" contextual filter to your Views display, configured to "Provide default value" with type "Content ID from URL".

The Null filter type doesn't change the output of your view. But it would make the Node ID available as a replacement pattern.


hook for disabling fields on add and edit node for a content type

If I understand you right you'd be better off using the Field Permissions module:

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.

If you do code it yourself you're going to end up implementing most of that modules functionality, so even if you don't use it it's a great place to look for the right hooks to call etc.


Can view HTML and PHP I wrote but install.php returns error

I installed Drupal8 from FreeBSD ports. I don't normally use PHP for anything so PHP version 5.6.30 is what is on my computer so either that is what Drupal used or that's what the port installed. I don't know why PHP7 was not installed instead.

In FreeBSD, the tokenizer extension is not automatically installed so I added php56-tokenizer and now Drupal8 works.


ImageField module is the perfect solution for your requirement. It is dependent on CCK and FileField modules. Some of the additional benefits provided by ImageField are it works fine with AJAX upload and removal, HTML5 and you can also restrict its behavior.


There's no single correct procedure to output HTML - as Ankit mentioned in his answer, one way is to add the raw HTML to the #markup property of an element in the form. Nothing wrong with that at all.

You could also use theme_item_list() which produces a simple HTML list with configurable attributes, and a bunch of default classes so you can target certain elements easily (see the docs for full details).

$items = array('First item', 'Second item', '...');
$form['some_element'] = array(
  '#theme' => 'item_list',
  '#items' => $items,
);

will output

First item

Second item

...

it will probably inherit some of Drupal's core or your custom styles because of "item-list" class on the wrapper. That may or may not be what you want, so for this case I guess what you use will likely depend on that styling.


Finally, I've done with hook_process_page() and removed the variable secondary_local_tasks upon logged-in user role before rendering to the template.

function mymodule_process_page(&$vars, $hooks){
    global $user;
    if(array_key_exists(6, $user->roles) && arg(0) == 'user' && arg(2) == 'edit'){
        $vars['tabs']['#secondary'] = array();
        if(isset($vars['secondary_local_tasks'])){
            $vars['secondary_local_tasks'] = array();
        }
    }
}

I have also tried this from hook_preprocess_page(), but it did not work on the sky theme.
Related question is here : Profile2 and profile fields by user role


Views throw an Ajax error in the admin page

I've had this problem many times before. For me, it was because I had the theme developer module enabled. I think the firebug module has the same effect. Basically, they are both adding extra markup to the response text and it isn't able to parse it then.


You shouldn't be adding JQuery like that.  It's automatically included in core, so you don't need to include it yourself.  To stay up with the latest JQuery version, install the jQuery Update module.

For your JS file, this should work:

(function ($) {
    Drupal.behaviors.myid.registrar_button = {
        attach: function (context, settings) {
            $('#myid_registrar_button').on('click', function(e) {
                e.preventDefault();
                alert("Eww");
            });
        }
    };
})(jQuery);


Change title head of the pages in Drupal 7 by path

It sounds for your limited set of pages maybe implement THEME_preprocess_html() and examine the url path and override $vars['head_title']. See this blog post as an example: How to set custom page title in Drupal 7

If you have some patterns for the head title try Page Title


This sounds like an unfortunate build decision coming back to hurt maintenance; that in itself is a common occurrence.  One phrase I must repeat here is "if things dont go as you planned, you have had an experience."  The issue that you have, at least in the school I went to, is called a Magic Number Unique values with unexplained meaning or multiple occurrences which could (preferably) be replaced with named constants

Now, solutions.  If you just want to plaster on more code to resolve this, then look at the External Links module.  This module adds javascript that checks every link on your site to see if they use the site's base url, and if not it adds an image to indicate the link goes elsewhere.  You could modify this code (the joys of open source) to change the IP from the old to the new.  This is what I would consider a weak solution.  It gets the desired result but it adds more code and processing to the site, and doesn't truly fix the root issue.

A better method would be to define a site variable ( code example ) to hold the ip address and then go and edit all of the references to it throughout the entire site to use that variable instead.  This works if all of the links are generated in php somewhere, and not just hard-coded in the body field of various nodes.  The advantage here is, if that ip address changes again you only have to update the variable value.  That can even be done with a drush vset.

Now, assuming these links are in node bodies and do not have the ability to use a php variable, you can get a similar result with a hook.  I would still recommend setting the new ip in a variable.  Then using a hook_node_view you can preg_replace the old ip address with the contents of the variable in the whole body field for any node.  Or in other fields too, or only on nodes of if( in_array( $node->type, $target_types_array)) etc.  This has the advantage of similar flexibility to the variable solution, but it does add extra processing like the javascript solution.  However, it is a hook that does not need loops so it will not be much of an increase.


Is there a way to assign an html ID automatically to a field in a content type?

Since I was only displaying the content with a view, in the view settings
- I edited the specific field
- clicked REWRITE RESULTS
- checked "Rewrite the the output of this field"
- and wrote:

<p id="file-types"> [field_file_type_text] </p>

This solved the problem


Way to have a theme-settings form input to accept numbers only?

You should be able to add your own validation handler. After the code you've shown, add this:

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

Then in your handler, you can add your own validation:

function my_validation_handler($form, &$form_state)
{
  if(!is_numeric($form_state['values']['mysite_contact_phone']))
  {
    form_set_error('mysite_contact_phone', t('Contact number must be numeric'));
  }
}


DB Query replaces %s inside LIKE operator

You just need to escape % signs with another % sign in a Drupal db query:

db_query("SELECT * FROM {foo} WHERE bar LIKE '%%supply%%' LIMIT %d,%d", 0, 10);

If you wanted to use a placeholder it would be like so:

db_query("SELECT * FROM {foo} WHERE bar LIKE '%%%s%%' LIMIT %d,%d", 'supply', 0, 10);


Recover from a Lost Drupal Administration Menu

Open below URL and change settings

admin/people/permissions

Or else you can edit here roles & permissions

admin/people/permissions/roles


Theming the output of multiple image upload widget in node create/edit form

One option is to use MYTHEME_image_widget. This theme function allows you to adjust the output of the image widget.

In combination with  MYMODULE_field_widget_form_alter and MYMODULE_image_field_widget_process you should be good to go.


How to get a dynamic Google map with filtered views and show a marker related to the selected item?

Have a look at the IP Geolocation Views & Maps module. Partial quote from its project page:

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

Get Locations,
Geofield,
Geolocation Field
Location.

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

Head over to its (impressive) project page for even more information about it (it would be way too long to include a quote of it all here). That project page also includes various screenshots.


Providing a view by using hook_views_default_views() is no longer possible. In D8 views are configuration entities. This means when a module wants to provide a view, it puts a yml file in /config/install.

If you want to change a view in code, load the view, change it and save it.

$view = View::load('test_filter_taxonomy_index_tid');
$display =& $view->getDisplay('default');
$display['display_options']['filters']['tid']['type'] = 'textfield';
$view->save();

A third alternative is to change the view directly in configuration, for example replace it with the content of a yml file:

$config_path = drupal_get_path('module', 'mymodule') . '/config/optional/views.view.myview.yml';
$data = \Symfony\Component\Yaml::parse(file_get_contents($config_path));
\Drupal::configFactory()->getEditable('views.view.myview')->setData($data)->save(TRUE);

The last option might be the easiest for your use case. You can configure the view in ui, export it to a yml file and use this file to overwrite the configuration of an existing view in hook_install().


Any easy way of implementing a mega menu?

(not a complete answer, but too much for a comment)

The main characteristic of a "mega menu" is that the contents of the menu are not limited to a simple list or tree of menu links. In your own example you have links with descriptions / subtitles, you have a picture, you have multiple columns that probably have nothing to do with a menu tree structure.

This is why you should use tools other than menu links system, for the contents of each megamenu box.

The first step is to forget you are creating a menu, and instead imagine you would be creating custom pages or blocks. How you create these, is a question for itself.

I have heard of someone who used nodes (possibly with pragraphs module), where every megamenu page is a node.

Another option would be to do something with panels.

The next question is how to anchor the megamenu contents to the actual menu items.

The person who used nodes for the megamenu pages (if I remember correctly) used a field where people specify the menu link path. Then when displaying the menu, the contents from the matching node are inserted as submenu.

You could also completely give up on the links being menu links, and instead just display node titles as toplevel items (sorted by whichever criterion), and then the rendered node as "submenus". This could be done with views, if you use a ul/li list as the style plugin (with custom classes) and a special view mode + layout for each item with its megamenu page. The special html you need would be in the custom layout.

Special attention should be given to multiple language versions, and possibly access checks for links. Maybe you use different paths in different languages?

This still requires some creativity in putting everything together.

But the main idea should be to look for solutions outside the menu links system.

EDIT:
I should add: You may want to think about doing something with ajax, to let the contents of the pages load after the main page contents. If I remember correctly, the person I talked to did this somehow, I just don't remember how exactly.

Credits to https://twitter.com/rachel_norfolk


The reason it's not working is because the
 with an ID of replace_model_div doesn't exist when the form is first built. So when the AJAX replace happens, there's no target container to append it to.

All you need to do is re-structure you form slightly (and remove the second #options array added to the second select):

$form['model_wrapper_container'] = array(
  '#type' => 'container',
  '#prefix' => '
',
  '#suffix' => '
',
);

if (isset($form_state['values']['platform'])) {
  $platform_value = $form_state['values']['platform'];
  $sqlmodel = "SELECT tid, name FROM {taxonomy_term_data} WHERE vid = $platform_value";
  $result = db_query($sqlmodel);
  $model_options = array();
  foreach ($result as $row) {
    $model_options[$row->vid] = t($row->name);
  }

  $form['model_wrapper_container']['model_wrapper'] = array(
    '#type' => 'select',
    '#title' => t('Select a Model'),
    '#options' => $model_options,
  );
}

And a small change to the callback:

function ajax_select_callback($form, $form_state) {
  return $form['model_wrapper_container'];
}


Is it possible to use a list of values from a views display as exposed filter of another view?

To do this,

Install the entity reference module.
Create an entity reference view (like creating a block or content pane). The results in this view will be your exposed filter.
Create an entity reference field in your content type.
In that field's settings, select the above view.
Use this field as an exposed filter.

Without more detail, I can't really describe how to set it up accurately but this is generally the accepted method.


You should not print individual children elements of the form array, but render it completely (with render($form)).

If you want to fine tune the markup inside the <form> tag, you need to alter the form (using hook_form_FORM_ID_alter()) or provide a custom theme used for the form (i.e. in hook_theme() returns an items with the form ID as key).


How to monitor several sites for updates from one central site?

You can use Drupal Remote Dashboard module for this

  This module is for system administrators. It's a tool to monitor and manage any number of Drupal installations at once and it's built to be extensible by other modules. Since version 2.X this module also comes with the highest level of security where as all communication between the dashboard and each of the cores is AES encrypted, hence the dependency (see below). Optionally the monitoring data will be made visible in nice graphs if the Google Chart API is available.


Is it possible to have term permission vocabulary id's match taxonomy vocabulary id's when creating a feature

That's not possible in Drupal 7 (and earlier) — permissions are hardcoded to use vocabulary autoincrement IDs, and there's no hook to override them.

This issue proposes switching to using the vocabulary's machine name for permissions in Drupal 8 — please consider reviewing the latest patch on that issue and providing feedback.


Why are my translated Select List values not shown after switching language?

After you translated the select list options of your field(s), make sure that you ALSO change the Format of that selection list from Default to Default Tanslated

You can do so via "Manage Display", located at /admin/structure/types/manage/yourtype/display (whereas yourtype corresponds to your Job Openings content type). Similar to what is explained in this comment also ...


What's the best infrastructure to set permissions to user roles that controls who can see which Nodes and which Views?

I was able to accomplish this using Permissions By Term (https://www.drupal.org/project/permissions_by_term). After I installed, I completed the following steps:

define member/student/guest roles in People > Roles
define Taxonomy structure (I named the vocabulary 'Page View Permissions')
In order to apply these permissions to Basic Pages, edit the Content Type of Basic Page to add section to set the permissions when creating a Basic Page. (Create new Entity Reference field.) Set default to Public.


You need to use drupal_goto the same way you use url.

So what you need to do is this:

$query = array('destination' => 'node/id');
drupal_goto('user', array('query' => $query));


Why is the AJAX replaced drop-down list value not being submitted?

You should make all form manipulations that are supposed to be actually submitted in dashboard_node_filter_form() and use dashboard_node_filter_target() only to tell ajax what part of a form should be updated, and to make aesthetic-only changes that does not affect data.


How do I display an image using the Dynamic Background module?

Make sure you also completed the required configuration steps as described in the Readme.txt of this module. I.e.:

Enable the modules/extensions that you want to use and go to the administration interface at /admin/config/user-interface/backgrounds/settings. Start by filling out the form and remember to fill out the CSS behaviour section. Then go into the configuration tab for each module/extension that you have enabled and as a minimum filling out the CSS behaviour fields.
Go to /admin/config/user-interface/backgrounds and select some images to upload after pressing "Save configuration" the form will change and allow you to select a default image. If you have enabled some of the extensions go to their location and select one of the uploaded images. See the extension descriptions above for information on where to select images for each extension.


displaying fields of selected taxonomy term

you need this functions:

taxonomy_term_load
taxonomy_term_view
drupal_render

load term by taxonomy_term_load, pass it to taxonomy_term_view then render it by drupal_render


Creating a responsive menu system for a site with a lot of content

for creating responsive menu you have lots of projects

below are some

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

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

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

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

try any one will help you out.


How does apache solr search recognize my changes by mysql query in my database

Solr maintains in own search index separated from the database. A process is required to index content from your database into Solr's index. Usually, this is done transparently by the Drupal Solr integration modules. These integrtions rely on usage of Drupal API for content changes. These API allow integration code to be executed on changes. This code will either index the change directly, or mark the content for re-indexation during the next cron run.

By accessing the database directly, you bypass Durpal's APIs and prevent the integration module to see your changes.

If this is a one off operation, you should be able to mark all content for re-indexation from the administration page of your Solr integration module.


Have a look at the Exclude Node Title module.

  This module handles a very simple functionality, decide whatever to exclude a node title from full node page or node teasers.
  It provides a checkbox on node-edit pages for easier exclusion, or you can use the admin page to manually enter a list of node id's to exclude title.
  Also provides the option to hide all titles of a certain Content type.


Migrate Module and AddressField Locality/City Lookup in PrepareRow Fails

Found the issue.  When using the addressfield module, you should have field mappings that allow for preparerow to work.  I thought that the address_arguments array was enough to create the field maps.  Also I was using the csv column title 'Zip' instead of the the mapped field title 'postalcode'

Under my address field mapping I added the following code.

    $this->addFieldMapping(NULL, 'fname');
    $this->addFieldMapping(NULL, 'lname');
    $this->addFieldMapping(NULL, 'address');
    $this->addFieldMapping(NULL, 'city');
    $this->addFieldMapping(NULL, 'state');
    $this->addFieldMapping(NULL, 'postalcode');

I also moved the function zipcity to my helper function file to allow other migrations to use it if needed.

This post https://drupal.org/node/1326044 was key into figuring out the missing link.


Embed block into a custom views template

Using the answer given to me in the comments by @subhojit777 I was able to call it up using this code:

<?php
  $block = block_load('MODULE_NAME', 'DELTA');
  $output =      drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
  print $output;
?>

I don't know if this is the best way, but it's working for now. :)


How to apply a Field Formatter to a node field programmatically?

The entity view builder provides a method to build a render array for a single field using a field formatter:

Drupal\Core\Entity\EntityViewBuilderInterface::viewField()

  /**
   * Builds a renderable array for the value of a single field in an entity.
   *
   * The resulting output is a fully themed field with label and multiple
   * values.
   *
   * This function can be used by third-party modules that need to output an
   * isolated field.
   * - Do not use inside node (or any other entity) templates; use
   *   render($content[FIELD_NAME]) instead.
   * - The FieldItemInterface::view() method can be used to output a single
   *   formatted field value, without label or wrapping field markup.
   *
   * The function takes care of invoking the prepare_view steps. It also
   * respects field access permissions.
   *
   * @param \Drupal\Core\Field\FieldItemListInterface $items
   *   FieldItemList containing the values to be displayed.
   * @param string|array $display_options
   *   Can be either:
   *   - The name of a view mode. The field will be displayed according to the
   *     display settings specified for this view mode in the $field
   *     definition for the field in the entity's bundle. If no display settings
   *     are found for the view mode, the settings for the 'default' view mode
   *     will be used.
   *   - An array of display options. The following key/value pairs are allowed:
   *     - label: (string) Position of the label. The default 'field' theme
   *       implementation supports the values 'inline', 'above' and 'hidden'.
   *       Defaults to 'above'.
   *     - type: (string) The formatter to use. Defaults to the
   *       'default_formatter' for the field type. The default formatter will
   *       also be used if the requested formatter is not available.
   *     - settings: (array) Settings specific to the formatter. Defaults to the
   *       formatter's default settings.
   *     - weight: (float) The weight to assign to the renderable element.
   *       Defaults to 0.
   *
   * @return array
   *   A renderable array for the field values.
   *
   * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewFieldItem()
   */
  public function viewField(FieldItemListInterface $items, $display_options = []);

To apply this method on a field object you can use $field->view() or if you only want a single value from a multivalue field without the wrapper and label you can also use it on a field item (delta).

EDIT: With this code you can find the values that you need.

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $i => $delta) {
  dpm($delta->value);
  dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
}


List child terms according to parent term page

In Drupal 7, I accomplished this by creating a view (for a block) that uses the contextual filter, "Taxonomy term: Parent term" - Under "When the Filter is Not Available" choose "Provide default value", then select "Taxonomy term ID from URL", and check "Load default filter from term page". I then displayed the block on the taxonomy pages where I want the child term lists to appear.

I'm just starting to work with Drupal and I suspect that there's a more robust solution - this works with pathauto but has trouble with terms that use a URL alias - but the instructions I've found for other approaches either don't work or require considerable coding. If you devise a better way, or somebody else has ideas, I'm all ears.


How to switch from recommended release of module to dev release?

From the working directory (site root) use this command:

drush dl module_name --dev

To get the DEV version.

Or:

drush dl module_name --select

To display a list of available versions.

Afterwards do drush updatedb to apply any database updates made by the module. You should check out https://drushcommands.com/ and all the commands on that page (the aliases are at the end of each section). For example, drush up will check for all possible updates.

In most cases you will not need to disable and uninstall things first but always make sure you are working in a dev environment and have regular backups (e.g. use the backup_migrate module). Drush will also backup the previous version of the module when usingdrush upbut NOT if you directly overwrite withdrush dl`.


form_comment_form_alter modify comment body

To add default value to your comment form body use the following snippet,

 $form['comment_body'][LANGUAGE_NONE][0]['#default_value'] = "Your default value";


Adding RewriteCode in https does not work for links other than base url

Adding these lines to the default .htaceess file worked for me

# Force HTTPS across the Drupal site
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>

Also enable clean URLs for that site


Login button not showing after upgrade to PHP 5.3

To diagnose the problem, make sure you display all errors (notices included) and that they reported somewhere (log, watchdog, ...), it should be a function incompatibility. Usually it is about parameters that are passed by reference for certain native functions or something like that (introduced in PHP5.3).

Then when you have identified the problem, open an issue on the module project (I bet it will be a contrib module or one of your custom module) so that the module maintainer can update it.

Drupal 6 is relatively old and versions prior to 6.14 are not working with PHP 5.3. Make sure you have the latest version, see also http://drupal.org/requirements/#php.


How to I hide menu items based on its access to different roles?

We do this with the Menu Per Role module.

  This module allows you to restrict access to menu items1 based on user roles. It depends on the Drupal core menu.module—just activate both modules and edit a menu item as usual. There will be a new fieldset that allows you to restrict access by role. The fieldset also appears in the node edit form.


How can I send an email to the previous comment author when a user places a new comment?

There are two situations and they might be a bit hard to combine. Drupal has a concept of threading comments, where the last comment is not necessarily the last in line. Like this:

- Comment 1
  - Comment 3 (reply to comment 1)
- Comment 2

Who should get the mail? The poster of comment 2 (the last comment author), or user 1? Or both? Also note that you can disable threading comments on the content type settings page.

In order to send a mail to the author of Comment 1, you can create a Rule on After Saving New Comments. Use the Send mail action and for the to: field you can use the token [comment:parent:author:mail]. (The mail of the author of the comment above this one.)

If you want to send a mail to the author of comment 2, your rule gets a bit more complicated. The initial action need to be Before Saving New Comments (so last comment is actually the last comment before yours).
For the first action choose Add a variable, the type is List of comments and you choose the value to be comment:node:comments. This variable holds all comments on the node.
Now you need to find a way to keep removing items from this list and send an email to the last one.

Below is based on experience and not tested, but I guess you can add a loop and loop over the items in your newly created variable. Then, in the loop Add a variable to contain a comment entity and set it with the current item in the loop. This will redefine this variable for every comment in the list and in the end this variable will hold the last comment.
Then below (not in) the loop, add your mail action and use the author of your newly created variable.

If you want to send a mail to all commenters, place the mail action within the loop (you can omit the comment variable in this case).

Update

This can also cause the author of comment 3 to get a mail triggered by comment 4:

- Comment 1
  - Comment 3 (reply to comment 1)
- Comment 2
- Comment 4

If you want to have more control, you'll need to create a Rules Component and call that component from the loop. Within the component you can add conditions to check if the comment has parents and skip the variable assignment based on that.


How to build a webform with a slider field

You will actually need to create a custom module to create a new webform component. This link contains more information on how to get it done http://jamestombs.co.uk/2012-09-24/create-new-webform-element-drupal-7


Can I call menu_rebuild() only for one module or specific hook_menu?

I am afraid that's what the function does. From Drupal docs:

  This function will clear and populate the {menu_router} table, add entries to {menu_links} for new router items, and then remove stale items from {menu_links}. If called from update.php or install.php, it will also schedule a call to itself on the first real page load from menu_execute_active_handler(), because the maintenance page environment is different and leaves stale data in the menu tables.

I guess you could try to reimplement the function into your own custom one and modify its source according to your needs. It looks like a lot of work though. You'd probably have to reimplement more functions.

Source: https://api.drupal.org/api/drupal/includes!menu.inc/function/menu_rebuild/7


Get a list of available migration destination plugins

With Drupal Console:

$ drupal debug:plugin migrate.destination

Or short:

$ drupal dpl migrate.destination

gives:

------------------------------------------ ---------------------------------------------------------------------------------------
  Plugin ID                                  Plugin class
 ------------------------------------------ ---------------------------------------------------------------------------------------
  component_entity_display                   Drupal\migrate\Plugin\migrate\destination\PerComponentEntityDisplay
  component_entity_form_display              Drupal\migrate\Plugin\migrate\destination\PerComponentEntityFormDisplay
  config                                     Drupal\migrate\Plugin\migrate\destination\Config
  d7_theme_settings                          Drupal\system\Plugin\migrate\destination\d7\ThemeSettings
  entity:action                              Drupal\migrate\Plugin\migrate\destination\EntityConfigBase
  entity:base_field_override                 Drupal\migrate\Plugin\migrate\destination\EntityBaseFieldOverride
  entity:block                               Drupal\block\Plugin\migrate\destination\EntityBlock
  entity:block_content                       Drupal\migrate\Plugin\migrate\destination\EntityContentBase
  entity:block_content_type                  Drupal\migrate\Plugin\migrate\destination\EntityConfigBase
  entity:comment                             Drupal\comment\Plugin\migrate\destination\EntityComment
  ...

With drush:

$ drush php
>>> array_keys(\Drupal::service('plugin.manager.migrate.destination')->getDefinitions());

gives:

=> [
 "entity:block",
 "entity:comment",
 "entity:comment_type",
 "d7_field_group",
 "field_group_entity_form_display",
 "field_group_entity_view_display",
 "entity:file",
 ...
]


How do i print image title in custom node for image gallery

Create a view of your content type, then in this view select the fields as your content and then select the title and the image. then every image will have its own title. you can also theme it in any way that you want.

you need to output this view in your node page, so simply in your template.php and in hook_preprocess_node function suggest a theme hook for this content type (for example page--node--gallery.tpl.php) and then in the page--node--gallery.tpl.php output the view using views_embed_view("view_name","display").


Cannot install bootstrap theme in drupal 8 via composer fresh install

Sounds like you're in the <project_root>/web folder. You need to be in <project_root> when using the Drupal Project to manage modules.

Just cd .. and run composer require drupal/bootstrap again, it should be fine.


You can group existing flagged content into smaller groups through the Content type Group you created with the help of Views display type Entity reference.

Create Content Views listing nodes that user might flag, don't create Page nor Block display, then when you save the View add the Display Entity reference from the Add dropdown.
Under Format: Entity Reference list Settings choose Content: Title as the Search field

In the results you should now see a list of node titles that can be flagged.
Add a new Relationship Content flag from the Flag category and configure it:
Tick Include only flagged content
Flag Bookmark (or whatever the name of your flag is)
By Current user

This will now filter out only the nodes that are already flagged by the current user. You are probably logged in as admin so you will now only see nodes that admin has bookmarked.
Adjust other views settings (Pager for example to show all items), No results behavior to You haven't bookmarked any content yet and save the View.
Edit your Group content type and add a new Reference field that references unlimited number of Content (nodes).

You'll probably want to make it a Required field

Under Reference type Reference method choose the Views you created in the first step. You will only see views displays of Entity reference type here.

A new option will appear View used to select the entities. Choose your exact views display here.

There are no arguments to pass, leave that empty (it is done through the flag relationship).
On the Manage form display settings for that field choose Check boxes/radio buttons.

Now when your users go to create a new Group node, they will be able to choose from a list of nodes they had already flagged:

In case you need your users to control the order in which the selected nodes appear in the Group you can change the field widget to Autocomplete, that way the choices can be reordered:

but this way the users have to search for node titles. You can help them by duplicating the views into a Block display and displaying it only on Create/Edit Group pages so users can see which title to search for.


Submitting a form causes 'secure connection failed' error that persists

For those who end up in this situation, the reason for this to happen is an error somewhere in your PHP code that is not caught by the PHP interpreter or Drupal itself and the server disconnects to your browser immediately before sending any information (including for example the web server certificate). It is not a network-related error as suggested above here.

To solve the problem, install the xdebug PHP module, configure it and run your scripts again. You will now get far better insight in the cause of the error(s) and it is actually caught before a disconnect.

In my case, the disconnect was caused by a recursion limit hit in my code, which was not caught by the PHP interpreter. Took me a few hours, mostly looking in the wrong direction (network issues, certificate issues).


Specify what the Facebook "Like it" button shows on Facebook

You can also look into the Open Graph meta tags module which allows you to specify which fields Facebook looks at when constructing its likes.


How to get variables of field from a view in twig?

If you do kint(), then it will try to output the raw data from the sql query and that is obviously to much for kint.

In this template there is not much going on and so there is not really much you can inspect with kint:

function template_preprocess_views_view_field(&$variables) {
  $variables['output'] = $variables['field']->advancedRender($variables['row']);
}

You can check the output with

{{ kint('output') }}

But this will only be the field content.

If you want to put a wrapper around the field, that is no problem, that is, what this twig is used for in most cases:

{{ output -}}

If you want to debug the variables, see what variables are available in the view templates, look in core/modules/views/views.theme.inc and inspect them one by one with kint.