Better way of adding Image as Block in home page

This is sadly a reasonable solution - one of the easiest. However, as you can see, it's sad because your content - the image - isn't being managed by the entity which is displaying it. This is very confusing when you go back and edit your content. You'll have to wonder - "Where is this being displayed?"

A better solution is to use the BEAN module. This will allow you to build a block type - much like a content type - which has an image attachment. Then, you can manage the display of that image on the block itself. In fact, you can any fields you like to your block type!

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


You need to use event named order_paid_in_full.

the mollie module does not take of that, it just create the transactions.
(take a look at payment tab in the order)

So you have two options:

Create you own rule, based on the event above, and grant the user the role.
Use commerce_license module - it has a role module, and this is what you need.


View comments in admin area before approval

Default comment administration page does not show you the entire comment. But it shows author and some other helpful information that should be helpful for most users to decide anther delete it or not.

You can replicate this form using Views and Views Bulk Operations module.

Just install both modules and create a new View on comment entity.
You can add a new page with a path like admin/content/comment2 (so you are not overriding the default page - if you want to do so, enter same path as core comment admin page).

Add necessary fields and set style as table. You can add a VBO checkbox and actions by adding a checkbox field.

There is an action "delete comment" that you can use to delete comments via VBO.
hooks will work without a problem.


Want to Install picasa gallery and best is PWI

I copied the folder(js,css,images to the root ) and created a node using the demo code given. It works. Now need to find how to format it, this got me the answer but don't know whether this  is right way or not.As I am new to drupal.


go to core\themes\stable\templates\views folder and copy views-view-table.html.twig or .tpl.php (depending if you are on Drupal 8 or 7)

copy the file and re-name it views-view-table--[view-name]--[machine-name].html.twig or .tpl.php

Then edit the file and add the class

If Drupal 8

{%
  set classes = [
    'cols-' ~ header|length,
    responsive ? 'responsive-enabled',
    sticky ? 'sticky-enabled',
    'my-custom-class',
  ]
%}
<table{{ attributes.addClass(classes) }}>

If Drupal 7

<table <?php if ($classes) { print 'class="'. $classes . ' . ' ' . 'my-custom-class"'; } ?><?php print $attributes; ?>>

Now place your template file in your theme's template folder.

Clear/flush the cache to see changes.


custom HTML in search form ( site/search)

You can use hook_form_alter and use render API to alter the html attributes. You can add attributes such as class, id, wrapper tags(prefix and suffix), attaching css and js file to the rendered form this way too. It would be something like this.

function yourMod_form_alter(&$form, &$form_state, $form_id) {
 if(strstr($form['#form_id'], 'search_form')) {
   $form['#attributes'] = array(
    'class'=> array('search-form-custom-class'),
    'id' => array(),
    );
   $form['#attached'] => array(
     'css' => array( drupal_get_path('module', 'yourMod') . '/css/yourMod.css' ),
   );
   $form['#prefix'] = "
";
   $form['#suffix'] ="
";
 }
}

I advise to read more on the render API to see all attributes that you can alter.


How can I convert special characters to normal characters in an URL query string?

To generate URL we use url() function. l() function is used to generate a text with link. See the example below:

// Generate a Text with link
echo l('Link Text', 'node/' . $nid . '/delete', array('query' => array('destination' => 'chapter/' . $cnid)));

// Generate a Link.
echo url('node/' . $nid . '/delete', array('query' => array('destination' => 'chapter/' . $cnid)));


Views Slideshow: how to change items per slide based on screen resolution

We use the Owl carousel for this.  It lets you specify four breakpoints and the number of slides to show.

There is a D8 recommendation for Flickity but it has some licensing restrictions.


Create an Availability calendar/table in Views

An update.. in the end I decided against using views, and used a library called dhtmlx scheduler timeline. It's turned out to meet the requirements spot on, and wasn't too difficult to wrangle into Drupal..


Would something like the following work?

{ "rules_after_login_redirect_to_page" : {
    "LABEL" : "After login redirect to page.",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "0",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_login" ],
    "IF" : [
      { "NOT text_matches" : {
          "text" : [ "site:current-page:path" ],
          "match" : "^user\/reset\/",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [ { "redirect" : { "url" : "your_page_url" } } ]
  }
}


Everything that is render cached in Drupal is by default varied by interface language specific.

If that's not enough and you have different interface and content language for example, you need to use cache contexts. Which works exactly like anywhere else, with $form['#cache']['contexts'], see https://www.drupal.org/docs/8/api/cache-api/cache-contexts for more information.


I would like to share my own working solution. If you see any improvements, please correct me. That would be helpful. If not I hope this script can be helpful for someone else...

I've created my own module and used this function to alter the query:

<?php

use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\taxonomy\Entity\Term;

function search_cities_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
    // machine_name of view
    if ($view->id() == 'zoek_een_bedrijf') {
        foreach ($query->where as &$condition_group) {
            foreach ($condition_group['conditions'] as &$condition) {
                // check which field must be changed
                if ($condition['field'] == 'node__field_stad.field_stad_target_id = :node__field_stad_field_stad_target_id') {
                    $value = $condition['value'];
                    // get ID from taxonomy term
                    $city_id = $value[':node__field_stad_field_stad_target_id'];
                    // load taxonomy term info
                    $term = Term::load($city_id);
                    // load reference field with taxonomy term ID's
                    $term_field = $term->get('field_aangrenzende_gemeenten')->getValue();
                    $cities = array();
                    // add ID from parent taxonmy term
                    array_push($cities, $city_id);
                    // add taxonomy terms from reference field (children)
                    //print_r($term_field);
                    foreach ($term_field as $key => $value) {
                        array_push($cities, $value['target_id']);
                    }
                    // update the condition before sending query to database
                    $condition = array(
                        'field' => 'node__field_stad.field_stad_target_id',
                        'value' => $cities,
                        'operator' => 'IN',
                    );
                }
            }
        }
    }
}


Copy commerce-cart-block.tpl.php file to your theme and edit that copy. Remember to clear your cache before you reload the page. That's all. Don't rename. Don't play with suggestions.


Is table prefixing controlled by db_set_active()?

When you use db_set_active you change the config that Drupal uses, so in theory you could use db_set_active to use the same database but change the prefix used.

Drupal will use the configuration defined, and the changed they imply.

You should note, that db_set_active won't work if you use multiple db backends for older Drupal versions (Drupal 6 and earlier, several MySQL backends are fine, but you can't switch from PgSQL to MySQL)


How to send a custom Solr Distance Query with SearchApi

Debugging around I found the solution:

$index = Index::load('default_solr_index');
/* @var \Drupal\search_api\Query\Query $query */
$query = $index->query();
$query->keys($form_state->getValue("keys"));
$location_options = (array) $query->getOption('search_api_location', []);

$location_options[] = [
      'field' => "field_geo_koordinaten",
      'lat' => 48.1371079,
      'lon' => 11.5753822,
      'radius' => 50,
    ];

$query->setOption('search_api_location', $location_options);
$results = $query->execute();

Thanks for pointing me in the right direction.


How to get last insert ID of drupal_write_record

Assuming your {user_log} table has a PRIMARY KEY with it, or something else serial, then it should be set in in the array you passed to it.  In your case, it would be something like

$last_log_id = $log['log_id'];


Maybe you're looking for this module : Field Permissions

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


Ajax not working with existing field in hook_form_alter

for this you can delete this line

$form['field_event_1_role']['und']['#options'] = array('_none' => t(' - '));

The problem is most likely because of a requirement for FAPI ajax which is documented, though can be easily missed:

  Changes to the form must only be made in the form builder function (ajax_example_autocheckboxes() in the example here), or validation will fail. The callback function must not alter the form or any other state.

From AJAX Forms in Drupal 7.

The fact that you're setting the form element [#options] in the ajax callback is definitely a problem. The ajax callback should only return the array or HTML to be printed, not change the form. Only the return line should be in that callback.

The changes to your form should be made in the form_alter. Also, you should use the form_state array to check whether a value has been selected for your first dropdown. This will be updated during an AJAX request.

I recommend looking at the examples module, as well as these pages for more information on AJAX in FAPI. It can definitely be tricky.

AJAX Forms in Drupal 7
AJAX Framework


How do I view the string pulled from feeds image importer?

I haven't solved my problem, but I found the hook needed to spit out the pre-parse data.

\**
* Importer testing.
*/
function wpi_events_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
dpm($result);
}

This spits out the source strings, which is great, because it tells me my xpath selector is wrong.


How can i have a custom theme created by myself for multilingual site?

Theming pages based on node id is not the way to handle this because you will have to copy each template to the corresponding translated nids.
A better approach is to create content types based on differences (which can be different layouts as well).
You can create a content type "404_page" for 404 pages in each language and create a template node--404_page.tpl.php to style them. This is all node specific.

There are also page specific overrides like:

page--front.tpl.php
page--user.tpl.php
page--blog.tpl.php

Edit: Some extra information on Theme hook suggestions can be found on the Drupal 7 Theme Hook Suggestions documentation page.


In a view how to replace the date of creation of the comment by the date of the flag?

Views filters have nothing to do with tokens. What you need to do is build the necessary query for this, which is something that tutorial ignores completely as it is a pretty simple condition.

A bit of searching pointed me to \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTidDepth::query as an example that builds a complex subquery condition in a filter.

I don't know your level of expertise with PHP/Drupal/SQL, so I would recommend you start by building the SQL that is needed for this by hand. In the views settings, enable to show the SQL query on the preview. Then copy that query, remove the {/} execute it by hand and try to adjust it to contain the filter you need. You probably want to add a relationship to flaggging already.

Once you have that, implement that in PHP in the query method of your filter.


In order to create blocks dynamically in Drupal 8, you will have to define a plugin derivative. Plugin Derivatives.

This way you can create multiple instances of the same block. Hope this helps.

Block Derivatives Example

Remember to respect the folder structure when creating your derivative and block class.

Derivative

<?php

namespace Drupal\YOUR_MODULE_NAME\Plugin\Derivative;

use Drupal\Component\Plugin\Derivative\DeriverBase;

class YOUR_DERIVATIVE_NAME extends DeriverBase {

/**
 * {@inheritdoc}
 */
public function getDerivativeDefinitions($base_plugin_definition) {
// @todo might as well include your configuration here and assign a value.
  $block_urls = ['1', '2', '3'];

  foreach ($block_urls as $block_url) {
    $this->derivatives[$block_url] = $base_plugin_definition;
    $this->derivatives[$block_url]['admin_label'] = 'Sample Label ' . $block_url;
  }

  return $this->derivatives;
  }

}

Block

<?php

namespace Drupal\YOUR_MODULE_NAME\Plugin\Block;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Session\AccountInterface;

/**
 * Provides a block.
 *
 * @Block(
 *   id = "YOUR_BLOCK_ID",
 *   admin_label = @Translation("YOUR_BLOCK_ID"),
 *   deriver = "Drupal\YOUR_MODULE_NAME\Plugin\Derivative\YOUR_DERIVATIVE_NAME"
 * )
 */

class YOUR_BLOCK_NAME extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $id = $this->getDerivativeId();

    $build = [
      '#markup' => $this->t('Your Block Content with ID' . $id),
    ];

    return $build;
  }

  /**
   * {@inheritdoc}
   */
  protected function blockAccess(AccountInterface $account) {
    return AccessResult::allowedIfHasPermission($account, 'access  content');
  }

}

Rename YOUR_MODULE_NAME, YOUR_BLOCK_NAME, YOUR_BLOCK_ID, YOUR_DERIVATIVE_NAME accordingly.


Drupal 8 Migrations are plugins. So you can create instance and execute like this:

<?php

use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;

$migration_id = 'MIGRATION_ID';
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable->import();


How to show another user the goals I completed?

Here is an export of a view, which is an improved version of the view that is included with the Goals module (disclosure: I'm its maintainer):

$view = new view();
$view->name = 'goals_completed_by_a_user';
$view->description = 'A block showing goals completed by a user.';
$view->tag = 'Goals';
$view->base_table = 'goals';
$view->human_name = 'Goals Completed by User';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Your completed goals';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'grid';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Goal: Goal - completed by users */
$handler->display->display_options['relationships']['goals_completed_goals']['id'] = 'goals_completed_goals';
$handler->display->display_options['relationships']['goals_completed_goals']['table'] = 'goals';
$handler->display->display_options['relationships']['goals_completed_goals']['field'] = 'goals_completed_goals';
/* Field: Goal: URL */
$handler->display->display_options['fields']['url']['id'] = 'url';
$handler->display->display_options['fields']['url']['table'] = 'views_entity_goal';
$handler->display->display_options['fields']['url']['field'] = 'url';
$handler->display->display_options['fields']['url']['exclude'] = TRUE;
$handler->display->display_options['fields']['url']['link_to_entity'] = 0;
/* Field: Goal: Goal Image */
$handler->display->display_options['fields']['goal_img']['id'] = 'goal_img';
$handler->display->display_options['fields']['goal_img']['table'] = 'field_data_goal_img';
$handler->display->display_options['fields']['goal_img']['field'] = 'goal_img';
$handler->display->display_options['fields']['goal_img']['label'] = '';
$handler->display->display_options['fields']['goal_img']['exclude'] = TRUE;
$handler->display->display_options['fields']['goal_img']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['goal_img']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['goal_img']['settings'] = array(
  'image_style' => 'goal_image',
  'image_link' => '',
);
/* Field: Goal: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'goals';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['text'] = '[title][goal_img]
';
$handler->display->display_options['fields']['title']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['path'] = '[url]';
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
/* Sort criterion: Goal - completed by users: Created */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'goals_completed_goals';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['relationship'] = 'goals_completed_goals';
/* Contextual filter: Goal - completed by users: User */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'goals_completed_goals';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'goals_completed_goals';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';

/* Display: My goals */
$handler = $view->new_display('block', 'My goals', 'block');
$handler->display->display_options['display_description'] = 'Goals completed by the current user';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;

/* Display: User's Goals */
$handler = $view->new_display('block', 'User\'s Goals', 'block_1');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Goals completed user';
$handler->display->display_options['display_description'] = 'Goals completed by a selected user';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'goal_img' => 'goal_img',
  'title' => 'title',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'goal_img' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Goal: URL */
$handler->display->display_options['fields']['url']['id'] = 'url';
$handler->display->display_options['fields']['url']['table'] = 'views_entity_goal';
$handler->display->display_options['fields']['url']['field'] = 'url';
$handler->display->display_options['fields']['url']['exclude'] = TRUE;
$handler->display->display_options['fields']['url']['link_to_entity'] = 0;
/* Field: Goal: Goal Image */
$handler->display->display_options['fields']['goal_img']['id'] = 'goal_img';
$handler->display->display_options['fields']['goal_img']['table'] = 'field_data_goal_img';
$handler->display->display_options['fields']['goal_img']['field'] = 'goal_img';
$handler->display->display_options['fields']['goal_img']['label'] = '';
$handler->display->display_options['fields']['goal_img']['exclude'] = TRUE;
$handler->display->display_options['fields']['goal_img']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['goal_img']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['goal_img']['settings'] = array(
  'image_style' => 'goal_image',
  'image_link' => '',
);
/* Field: Goal: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'goals';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['text'] = '[title][goal_img]
';
$handler->display->display_options['fields']['title']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['path'] = '[url]';
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Goal - completed by users: User */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'goals_completed_goals';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'goals_completed_goals';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'raw';
$handler->display->display_options['arguments']['uid']['default_argument_options']['index'] = '1';
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';

In this view I've added an extra block named "User's Goals". This extra block has a contextual filter which I configured like so:

When the filter value is not available: Provide a default value with Type = "Provide raw value from URL" and Path component = "2" (this is what differs from the Views block delivered with the Goals module).
In the block settings I've adapted the block visibility to only show this block on pages with a path that matches user/* ( i.e. when browsing a user's account, as in your question). And of course I've then enabled this extra block also to display it in an appropriate theme region.

Note: I've also extended the list of fields shown in the block, by also adding the Goal URL (excluded from display) and Goal title, though that is not really relevant to answer the question here.


Creating readable links for nodes in a view

First way:
For second Views I assume argument handling is used (NID send as argument).

So you should modify this argument,
Add/change this argument validation - select PHP code
There you should check if this $handler->argument is numeric
if not, try find node by title ($handler->argument will title),
if found, assign to $handler->argument found NID.
Return in code TRUE if argument is numeric or node found by title.

Minus of this for nodes with the same titles, so you can use next way.

Another way is using Rules for that:

Add rule for node creation/editing
Add action and use next PHP code for inserting new alias:

     global $language;
     $path = 'node/' . $node->nid;
     $alias = 'directory/show/' . $node->title;
     path_set_alias($path, $alias, NULL, $language->language);

Be sure that $node accessible in your Rules PHP code action, if not, seek patterns like [nid], etc.
Also you should resave all your required nodes for creating new aliases for these nodes, recommend to use for it VBO module.


Prefill taxonomy term reference field while in term page

There is a module for this and it's called Entity reference prepopulate.


How to install drush 8 properly on Debian 8?

(Updated to fix links and clarify Drush 8 vs 9.)

Debian still (as of February 8th 2018) comes with Drush 5.10 which is completely unacceptable.

There is no reason to use Git to download Drush. Either

If you want the old Drush 8 (that works for Drupal 8.3 and older, including Drupal 7) download a single PHAR file using the the straight forward instructions on http://docs.drush.org/en/8.x/install/ or
If you want the current Drush 9, install a site-local Drush (with Composer) and Drush Launcher (as a PHAR file) as described on http://docs.drush.org/en/master/install/


Uploading via default image on Articles not working

This is a permissions issue. You need to chmod the directory tree.

Edit: A tutorial on setting directory permissions can be found on drupal.org at Securing file permissions and ownership .


You may consider the FreeLinking module.

The Freelinking module adds a text filter for using Wiki-style markup for creating links automatically, by searching the node body for markup.  It supports a number of methods for creating the link, including Nodetitle (which sounds like the one you're looking for). You may even add methods by adding your own link plugin.

However, you need to indicate the text you want to be considered as a candidate for automatic linking by markup: i.e. by surrounding it with double square brackets.  This is how your example will look like:

The [[drupal]] is one of best CMS systems

It even lets you create placeholder links to pages that has not been created yet. Both internal and external links are supported by the module.

There tutorial is about using the Freelinking module, with a little help from the companion WikiTools module, here.

If the way Freelinking does this is not good enough for you, here are a couple of alternative solutions:

Alternative solution #1: You can write your own custom text filter for this.  I suspect that to create something that works during node saves without freezing or killing your site will be very hard to do.

Alternative solution #2: If you can accept a solution that delays the creation of links, you can place new and altered links in a queue, and then use a cron job  to parse them for links.  This allows you to space out the parsing of node bodies over time and will avoid the performance problems a real-time text filter would create.  For the record: There exists no module that does the parsing of node bodies and add links like this.  You'll need to write it yourself.


You can render the status messages and send them as anohter AJAX command.

For example:

$commands = array();

// Add other commands

$commands[] = ajax_command_prepend('div#ajax-status-messages-wrapper', theme('status_messages'));

return array('#type' => 'ajax', '#commands' => $commands);

At least this is the way I solved this problem when I faced it.


This is not a complete answer, but maybe it helps to have a look at the nd_views_node_helper function. If I understand correctly, it's the helper function that allows Views rows to be rendered through Display Suite.

You can also make your custom code dependent on views: create a view which takes node IDs as argument and renders the nodes through Display Suite.

Hope that helps!


You need to implement hook_theme_suggestions_HOOK_alter() in your theme.
For siderbar_first region it would look like follows:

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function THEMENAME_theme_suggestions_region_alter(&$suggestions, $vars) {
  if ($vars['elements']['#region'] == 'sidebar_first' && Drupal::service('path.matcher')->isFrontPage()) {
    $suggestions[] = 'region__sidebar_first__front';
  }
}

Now region--sidebar-first--front.html.twig can be used for theming sidebar on the front page.


Get the number of followers and following in user relationship

The following function works for me to display the count of friends a user have:

function mymodule_user_friends_count ($user) {
  $count = user_relationships_load(
    array("user" => $user->uid, 'approved' => 1, "name"=>'Friend'),
    array('count' => TRUE));
  return $count;
}

Notice I only count approved friends and only relationships of type 'Friend'


How to make two date fields related to each other?

You can use Date module to create multi date field, Check this article for more information


Faceted Search Block displays values from other facet blocks

I finally got the answer by myself. Never thought it would be such a little setting:

If you're going to index a "text field" (and maybe going to enable the related facet block), make sure the text field is declared as string instead of fulltext.

Just go to -> Search API >> edit the correlating index >> Fields

and check the textfields. Following this you just have to re-index the items.


How do I set the default value of an exposed filter to a value that is not "-Any-"?

Try this:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function bootstrap_barrio_subtheme_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ( $form_state->get('view')->id() == 'office_locations_doctor_detail'){
     // Set the default value as tid not the name of term.
     // Change 'Select Doctor' by the tid of it.
    $form['field_doctor_reference_target_id_1']['#default_value'] = '1';
    // Remove - Any - option.
    unset($form['field_doctor_reference_target_id_1']['#options']['All']);
  }
}


How do i show a not-equals operator for rules while setting up commerce shipping conditions?

Choose "=", then at the bottom of your condition, enable "negate".  It's just below where your screenshot is cut-off.


Search engine for Drupal site, Apache Solr or ElasticSearch?

Use Apache Solr.It has every feature you dream and the searching is super fast.It can search through pdf as well. As per your requirements I suggest to use Apache Solr. It can be easily done with it.


Have a look at Administer › Site building › Pages for the page you are wanting to design.

Click on the Content link in the left column and you should see a button for 'Show Layout Designer'.


Is there a module that can display items in database?

You can use views module to display list of content.

  Views module provide functionality to admin to display list of content
  in any format without using code.

If you want to implement autocomplete functionality with views, then you can use views autocomplete filters module.

  Views autocomplete filters module provide functionality to set
  autocomplete to node title or any fields.


Theme not working when using non-standard port number

It should just be a matter of setting the $base_url in settings.php

  If Drupal is generating incorrect URLs on your site, which could be in HTML headers (links to CSS and JS files) or visible links on pages (such as in menus), uncomment the Base URL statement below (remove the leading hash sign) and fill in the absolute URL to your Drupal installation.

For your case that would be:

$base_url = 'http://mysite.local:89';


An alternative solution I found was to use get the target_id and use Term::load($term_id)->getName() to get the value we wanted.

use Drupal\media_entity\Entity\Media;
use Drupal\taxonomy\Entity\Term;

function mymodule_preprocess_views_view(&$variables) {
  $results = $variables['content']['#view']->result;
  foreach($results as $row){
    $media_entity = Media::load($row->mid);
    $media_target_id = $media_entity->get('field_media_type')->target_id;
    $media_type_name = Term::load($media_target_id)->getName();
  }
}


How to handle files for Drupal in cloud when in multi-site mode?

This is why platform as a service solutions like platform.sh, getpantheon and others are so popular. They provide solutions to problems like this.

If you don't want to use them, then you can still learn from them. In this case, the answer is environment variables. You commit a settings.php file that reads the configuration from environment variables, e.g. which database server/solr/redis/... to connect to, configuration overrides and so on.

platform.sh also automatically generates a settings.local.php that some configuration built in, but they move more and more towards just documenting how to do it yourself as that's more flexible. See their example setups and specifically, settings.php of the 8.x-composer approach.

How to actually get those environment in place yourself is a non-drupal related question that you'll have better chances for good answers elsewhere. It also depends a lot on how you actually instrument those cloud servers.

So far, I've haven't had the need for customized services.yml files, all I do sometimes (beside having a services.local.yml, just like settings.local.php), is to dynamically load additional files, e.g. with the redis configuration. If you need that, you can either generate those files or you can implement a site specific service provider that generates the service/parameter definitions dynamically.

For twig, while they are generated PHP files, unless you do something really weird, they are based only on the static .html.twig files that you are deploying. So, you do not need to share them between your servers, you just need a deployment step that deletes the files on all servers when you deploy new code. Or, you could write a script that pre-generates them, then you less of a performance hit when re-deploying. Haven't seen a script yet for Drupal that does that, there might already be a question about that here.

The container is in cache, by default in the database, with a bit of configuration you can also have it in Redis or Memcache, see https://github.com/md-systems/redis/issues/12.

I'm not aware of any other files that need to be maintained like this. (other than public or other stream wrappers, which you apparently have already solved).


If .myclass img { your code goes here } is not good enough and you must have the class inside the img tag, then:

1) Download and enable the Image URL Formater Module

2) On your view's picture field, select url as format.

3)

Option A) In the rewrite results field type

Option B) if you want to use the .tpl.php file, put this inside it.

<img src='<?php print $fields["field_image"]->content; ?>' class='yay-we-did-it'>


Rewrite output for view field only when certain condition is met?

You can do this with the UI with some of my favorite Views trickery.

Go to your content type, click the Boolean field and change its Off value to 0.
Create a new view and add the Title field twice. Rewrite the link for one of them, and Exclude both from Display.
Add your Boolean field to the view and..

a. Rewrite the title of this field: [title]

b. No Results behavior: [title_1]

c. Count the number 0 as empty: ✓

d. Hide rewriting if empty: ✓

Because you changed the Off value of the field to 0, you can make Views trigger the No Results Behavior for the field. I've just tested this and it works fine so ask if you have any trouble.


How can I show comments on nodes displayed in a view?

My suggestion is that you use the 'node' display, but make changes to your node.tpl.php file in your theme. This will give you the results that you want, but it obviously won't be very point-and-click.


Try to use: menu_tree_all_data(). It will get a menu tree of your given menu machine name.


How activate Privatemsg Module to all users?

You should change permissions for the Privatemsg module for authenticated users or whatever role you want in the permissions page(admin/user/permissions)

See http://drupal.org/getting-started/6/admin/user/permissions


Displaying and selecting data from a database in a module

Basic php error, it's $query['distance']


How to open a popup form from a view link?

Your code is building an ajax response. This only works in ajax callbacks, nowhere else.

If you want to make a link modal, so that it will open in a popup, you have to set the class use-ajax and the attribute data-dialog-type. Like in this example from ConfigSync.php:

$links['view_diff'] = [
  'title' => $this->t('View differences'),
  'url' => Url::fromRoute($route_name, $route_options),
  'attributes' => [
    'class' => ['use-ajax'],
    'data-dialog-type' => 'modal',
    'data-dialog-options' => json_encode([
      'width' => 700,
    ]),
  ],
];

For modal links to work you need to attach a library, see How to create modal windows (pop-ups)?


I saved the file in prepareRow() and map the fid with my field.

$this->addFieldMapping('field_image', 'fid');
$this->addFieldMapping('field_image:file_class')
  ->defaultValue('MigrateFileFid');

In my prepareRow method :

  public function prepareRow($row) {
    if (parent::prepareRow($row) === FALSE) {
      return FALSE;
    }
    $files_dir = '/mnt/files';
    $file_name = str_replace('sites/default/files/', '', $row->image);
    $file_path = $files_dir . $file_name;
    $row->fid = _my_migration_upload_file($file_path);
    return TRUE;
  }


Send user a reminder email after x-number of days if Profile2 field is empty and user has specific role

Here is my solution, based on tenken's advice:

I created a Rule COMPONENT with the condition "User has role: Role A" and the action "Send email".

I then created a Rule...

Events: After saving a new user account
Conditions: None
Actions: Schedule component evaluation

In that Action, I chose these options:
Component: the component from step 1
Scheduled evaluation date: account:created
Add offset: 5 days
User > Data Selector: account


How do I change text on the submission button in the node form?

In #value is a translatable string. You can override it with a simple text value:

if ( isset($form['actions']['publish']) ) {
   $form['actions']['publish']['#value'] = 'New Text';
}

Or you can put there a new translatable string with the t() function, if you want to translate the new string in different languages:

if ( isset($form['actions']['publish']) ) {
   $form['actions']['publish']['#value'] = t('New Text');
}

Edit: Answer the question in comments

What you see in dpm() is the result of t(), which is used in the original form in NodeForm.php:

$element['publish']['#value'] = t('Save and publish');

In D8 this is an object, which will result in the translated text when used in a string context. For the enduser you simply use it like a string value, but magically it will always be translated. You don't have to look into this object to find a way to change it. To set a new value you simply generate a new translatable object and put this into the place of the old one.


I'd do it this way:

Create a custom module
Create a class inside the src folder that consumes the API
Create a custom block inside your module: call the class there

Mostly it is better to fetch f.e. each hour and save the api data to custom entities. In this way you can cache the content in the block which enhances performance.


Register User with Services (JSON) with Custom Fields

Hope this will help you,

In Drupal 7 you can use the below JSON format to add custom fields(field_user_image)

{
    "name": "test",
    "pass": "password",
    "mail": "test@gmail.com",
    "field_user_image": {
        "und": [{
            "fid": "2"
        }]
    }
}

I have tried in my local and it is working fine.

Created new field UUID

Calling the Service using Firefox poster add-on

Code

  {
    "name": "testuser123",
    "pass": "testuser123",
    "mail": "testuser123@gmail.com",
    "field_register_uuid":
      { "und":
        [{
          "value": "65C7DCA4-8F03-473C-9E8F-08B3F29E91AE"
        }]
      }
  }

I can able to create new user with the custom field

References

How do I POST a new node using the Services module?
Services module. How to construct the JSON data with session info for creating node?


Views - alter date field granularity on exposed filter mid-request?

Working solution thus far:

/**
 * Impliments hook_form_views_exposed_form_alter
 *
 * Used to change exposed date filter to year only, as this is not available in the views UI
 */
function bain_views_form_views_exposed_form_alter(&$form, $form_state)
{
    if( $form['#id'] == 'views-exposed-form-news-items-page')
    {
        // dpm($form_state['input']['date']['value']);
        if (isset($form_state['input']['date']['value'])
            && empty($form_state['input']['date']['value']['month']))
        {
            // Switch date formatter to year only
            $form['date']['value']['#date_format'] = 'Y';
            // Add extra validator to handle filter submit
            $form['#validate'][] = 'bain_views_views_exposed_form_validate';
        }
    }
}

/**
 * Custom validator for exposed date filter
 */
function bain_views_views_exposed_form_validate(&$form, &$form_state)
{
    if ($form['#id'] == 'views-exposed-form-news-items-page')
    {
        $handlers = &$form_state['view']->filter;
        $date_handler = $handlers['field_news_date_value'];
        // dpm($date_handler);
        if (!empty($date_handler->options['exposed'])
            && isset($form['date']['value']['#type'])
            && $form['date']['value']['#type'] == 'date_select'
            && $form['date']['value']['#date_format'] == 'Y')
        {
            $date_handler->options['granularity'] = 'year';
            $date_handler->format = 'Y';
        }
    }
}


Drupal simplenews doesn't subscribe the users registed via social networks

The reason users aren't signed up is due to how simplenews works. It does the work of newsletter signup by modifying the Drupal core registration form to capture the newsletters (or setting them automatically in case of the silent option) then takes that data to sign users up following account creation.

For both HybridAuth & FBOauth, they subvert this process with their own forms to do authentication with a 3rd party. Both HybridAuth & FBOauth however, provide their own API hooks to take action upon user registration (hook_hybridauth_user_insert() & hook_fboauth_user_save() respectively). You can implement their hooks in a custom module to do the same work HybridAuth does to signup users automatically.


using entity reference fetch different fields automatically

On the content type that has the reference-field, on the "Manage Display" section, you can choose if you want "Label" or "Rendered entity", which will output the full node.


How can I import and export Drupal Commerce Products?

You can look at the Commerce Feeds module in Drupal

You can use this Views Data Export module to Export in CSV or Excel Format. Further read more details on that module for installation and configuration.

You can also watch View Tutorial


Bah, nevermind -- I realized that I can just remove the view from the config table in the db. Then  all updates are free to proceed. Thanks!


Access Denied when redirecting to alternate view

Please check if cookie & javascript is enabled on the test machines for Mozilla & Safari browser.


Custom contextual filter on views using Group module in Drupal

I did not found anything about view filters for the group module. You can only list group entities, not nodes from a group.

Looks like there some support for Panels but I don't know the module that much.

So I took the time to write some code, I just finished testing it.

Just change yourmodule and your_view_id with the correct data and your view should only display nodes attached to groups from the current user:

/**
 * Implements hook_views_query_alter().
 */
function yourmodule_views_query_alter(&$view, &$query) {
  if ($view->name == 'your_view_id') {
    global $user;

    // Get current user groups.
    $groups = group_membership_load_by_user($user->uid);
    $groups = array_keys($groups);

    // Add join to filter on group ID.
    $join = new views_join;
    $join->construct(
      'group_entity',
      'node',
      'nid',
      'entity_id',
      array(array(
        'table' => 'group_entity',
        'field' => 'gid',
        'value' => $groups,
      )),
      'inner'
    );

    $query->add_relationship('group_entity', $join, 'node');
  }
}


How do I pass field variables for a database insert helper function

This was answered on the drupal.org forum by @Jaypan:

$id = db_insert($table)
  ->fields($fields)
  ->execute();


The easiest way is to use the Bundle copy module, but if you can't get that to work I'd recommend the Configuration Management module.

  The configuration management module enables the ability to keep track of specific configurations on a Drupal site, provides the ability to move these configurations between different environments (local, dev, qa, prod), and also move configurations between completely different sites (migrate configurations) without the use of modules with all configuration being owned by the site.

It's basically features with the stuff you don't need. Its sole purpose is to move configuration from one site to another.


"Uncaught TypeError: Cannot call method 'call' of undefined at 507 jquery.validate.js"

Try closing Drupal.behaviors.dynamicTextfieldValidator with a semicolon

  };
})(jQuery);


Updating Drupal project using Composer fails

Solved it. I had to add that "webflo/drupal-core-require-dev" to update command to be updates as well, because without that core couldn't be updated:

composer update drupal/core "webflo/drupal-core-require-dev" --with-dependencies

Saw that in "known issues" section. :/
It's really strange - what's the purpose of --with-dependencies when I have to add dependencies manually after all...


How to import content in markdown format?

Why complicate things by importing markdown? If html format is what is desired, there are many options to convert it beforehand. For example this simple python implementation.

As tenken suggested, Markdown filter is an option to consider.


Display all nodes for which user appears as a field on that user's profile?

Add a contextual filter for that entity reference field and in its settings, provide default: uid from url. That will only show nodes where the uids match.

There are two options, "referenced" and "referencing".. I'm pretty sure you want referenced but try both.


Change order status string from "Completed" to "Shipped"

The best thing for you to do would be to alter the order status info array to give the "Completed" status a new title. The example in the documentation actually demonstrates specifically how to change the title of the completed status. Look for hook_commerce_order_status_info_alter() in commerce_order.api.php.

There are ways to override strings through the user interface, but this is such a small module change that I'd really recommend directly making it in a site-specific module.


There is nice article on drupal.org on recovering administrator's password. Here is the link

Specifically, you would probably be using one of the two commands below:

Drush can generate a one-time login link.

drush uli

Reset password

drush upwd --password="givememypasswordback" admin


Make sure you clear your cache (drush cc all) after (re)registering your classes.  Not doing so will often result in the migrate page showing error ClassName no longer exists.


A more robust solution that avoids needing to ensure unique node titles would be to write a custom Views Plugin Argument Validator that converts a contextual filter to node ID.

In your case in which you want to validate node path aliases, you would want to extend the class views_plugin_argument_validate_node in views/modules/node/views_plugin_argument_validate_node.inc to overwrite options_form() to provide your own option. You probably want something like this:

function options_form(&$form, &$form_state) {
  parent::options_form(&$form, &$form_state);
  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Filter value type'),
    '#options' => array(
      'convert_path_alias' => t('Node path alias converted to Node ID'),
    ),
    '#default_value' => $this->options['type'],
  );
}

You would also need to overwrite validate_argument() to convert the argument (path alias) passed into the function into a node nid, set $this->argument->argument to the converted node nid, and return TRUE if the path alias was successfully converted.


Create View That Overlays The Theme When Field Clicked

You can achieve this effect like this for example:

You put a view block on top (which will overlay the other content) and put the other content below, position them on top of each other with position: absolute.
Then create a button and position it however you prefer.
Use jQuery .click() with this button (http://api.jquery.com/click/) to hide and show your view block. One possible solution is that on click, you examine if the view block has a "hidden" CSS class (for example). If it has "hidden" on click, you remove the class with .removeClass("hidden"), if it doesn't have the class, you add it with .addClass("hidden").
CSS styling should be like this: .hidden{ display: none; }


Wrong date field format on mobile iOS / Android

The solution is not to use :

<input type="date">

but

<input type="text">

With Form API, replace :

$form['my_date'] = array(
    '#type' => 'date',
);

with

$form['my_date'] = array(
    '#type' => 'textfield',
);

And attach a date picker like the jQuery Datepicker available in Drupal 8 or other library like Bootstrap Datepicker

In safari, i need to test in private mode because sometines the Safari cache prevents me to see update in my JS.


Is there a way to know the view type from PHP code?

The nomenclature for what you're talking about in Views is the display handler.

If you have the $view object (which you should in virtually all Views scopes), you can find the current object for the display handler at $view->display_handler. You can find the name by using get_class():

get_class($view->display_handler);

will return something like

views_plugin_display_page

which is the machine name of the display handler. But in conditionals, you can just use the instanceof type operator:

if ($view->display_handler instanceof views_plugin_display_page) {
  // ...
}


Is there a better way to make a user profile tab using a view?

There isn't any need to use a custom module for this: The Views module already allows you to associate a URL to a view and make the view appears as a menu tab.

The following screenshots are for Views 7.x-3.x-dev, but the settings are present also in previous versions of the module.
Under "Page settings," there are two options: "Path" and "Menu." The screenshots shows the settings used for a view implemented by a third-party module (the Flag module), whose view is shown as menu tab.


I have this in my html.tpl.php file:

<html
    xmlns="http://www.w3.org/1999/xhtml"
    xml:lang="<?php print $language->language; ?>"
    version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"
>

where $language is a global object, it prints, in my case:

<html
    xmlns="http://www.w3.org/1999/xhtml"
    xml:lang="en"
    version="XHTML+RDFa 1.0" dir="ltr"
>

Check out the variables available to you in html.tpl.php.

Make sure to clear your cache after you change the template.

EDIT: Full contents of html.tpl.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"
    <?php print $rdf_namespaces; ?>>
    <head profile="<?php print $grddl_profile; ?>">
        <?php print $head; ?>
        <title><?php print $head_title; ?></title>
        <?php print $styles; ?>
        <?php print $scripts; ?>
    </head>
    <body class="<?php print $classes; ?>" <?php print $attributes;?>>
        <?php print $page_top; ?>
        <?php print $page; ?>
        <?php print $page_bottom; ?>
    </body>
</html>


I'm guessing this is a Drupal 6 issue:

The Comment module create the links with hook_links(). You can alter those in a custom module using hook_links_alter().


The only moment where the node access table could be empty is when node_access_write_grants() (or node_access_rebuild()) deletes the content of the table before to repopulate it.
In the case of node_access_write_grants(), the table could become empty only if the table contained the access data for a node; in the case of node_access_rebuild(), the table becomes empty in any cases.

Sometimes the all entry can vanish, as node_access_acquire_grants() adds that entry only if no modules returned access records for the node passed as argument to the function, and node_access_rebuild() adds that entry if no module returned access records.

To notice also that, in the case the $realm passed to node_access_write_grants() doesn't match with the value contained in $grant['realm'] (for all the grants passed to the function), then node_access_write_grants() will delete the access records for the node passed as argument, but it will not save any access records.

// Only perform work when node_access modules are active.
if (count(module_implements('node_grants'))) {
  foreach ($grants as $grant) {
    if ($realm && $realm != $grant['realm']) {
      continue;
    }
    // Only write grants; denies are implicit.
    if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
      db_query("INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (%d, '%s', %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']);
    }
  }
}

The same can happen if a module calls node_access_write_grants() using the default value for $delete, and there aren't modules implementing hook_node_grants().
In these cases, the node access table can become empty if the table contained data only for the node passed as argument to node_access_write_grants().


Programmatically submit user reset password form

An alternative approach is this:

global $language;
$account = user_load_by_name($username);
if ($account) {
// Mail one time login URL and instructions using current language.
$mail = _user_mail_notify('password_reset', $account, $language);
  if (!empty($mail)) {
    watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
  }
}

Essentially all you need is:

_user_mail_notify('password_reset', $account, $language);

More info: user_pass_submit


The closest I know you can get by doing just site buiding is by using the views autocomplete filters module which gives the possibility of using an autocomplete widget for the exposed filter by simply checking an option in the exposed filter options in the view.


Trusted_host_patterns not working with domain

Figured this one out after some trial and error. I don't know if it is necessary due to some server settings I have, but I fixed this by adding the private IP of my server to the trusted host names setting. I'm uncertain as to why this is necessary since all the other examples I've seen don't need any reference to the private IP, but in my case it seems to be needed.


Yes, the Disqus module has it own table (named disqus).

To see this table, look up the file disqus.install and examine the array called $schema.

You'll find this file inside the project directory (normally sites/all/modules/disqus/) where you installed Disqus, or in the project's git repo at drupalcode.org.

The Disqus schema is reproduced below for easy reference:

$schema['disqus'] = array(
  'fields' => array(
    'did' => array(
      'type' => 'serial',
      'not null' => TRUE,
     ),
     'nid' => array(
       'type' => 'int',
       'not null' => TRUE,
       'default' => 0,
     ),
     'status' => array(
       'type' => 'int',
       'unsigned' => TRUE,
       'size' => 'tiny',
       'not null' => TRUE,
       'default' => 0,
     ),
  ),
  'primary key' => array('did'),
  'indexes' => array(
    'nid' => array('nid'),
    'status' => array('status'),
  ),
);


You just need to use curly braces; there's no need for variable variables in this case:

$tid = $node->{$taxonomy_field}['und'][0]['tid'];


Apache Solr Search show only currrent user language

One way to do this is to implement hook_apachesolr_query_alter() to automatically filter on the current language. In a custom module called "mymodule", the code snippet would look similar to the following:

/**
 * Implement hook_apachesolr_query_alter()
 */
function mymodule_apachesolr_query_alter($query) {
  global $language;
  $query->addFilter("ss_language", $language->language);
}


How do I change the order of the form elements?

@AjitS Credit to you for resolving OP's issues.. Adding more details so that it will be helpful for others..

Drupal weights works using below logic...

  Lighter weights Float.... Heavier weights sink...

That means field weight with low value comes to top... Field with Weight high values goes to bottom...

You can also set Negative weights to Fields...

Please find different scenarios of ordered fields with weights below..

Field A : 0

Field B : 1

Field C : 2

Field D : 3

Field E : 4

Field F : 5

Field A : -5

Field B : -4

Field C : -3

Field D : -2

Field E : -1

Field F : 0

Field A : -2

Field B : -1

Field C : 0

Field D : 1

Field E : 2

Field F : 3

In your case Click on Show Row Weights to edit Weights and set weights base on above logic and click save..


Theme hook suggestion for nodes within a menu link?

As this requirement may get even more complex, I would suggest adding a taxonomy selection to the content types in question. You can use this to assign the proper theme suggestions as the value will be saved on the node object. You may also want to check out ThemeKey.


How to display the entity ID next to the title of an ECK entity

$title is an available variable in that entity template. So, yes if you need to pass entity ID and UUID then you will have to pass them via preprocess hook.


How i can use the feed module for uploading the images in the image field of the content type?

Just put the url of the image in your csv and the feeds module will import the image.


Disable cache on base url for redirecting unauthenticated users

Not Drupal specific, but you should use the status code 302. Redirects with a status code 301 are cached very aggressively by browsers.

In Drupal custom code, never send a response directly, set it in the event, so that it can be returned and cached properly by Drupal, which is by the way not a bad thing, because the page cache can handle different cached versions for authenticated and anonymous users:

$event->setResponse($response);


I spent a couple hours working on this, and it seems as soon as I posted the question I found an answer. The Feeds Tamper module will do the trick. It provides a lot of preprocessing functionality before the data is mapped to the entity fields. When configuring the data mapping, select the feeds tamper link. The explode plugin will explode the values into an array. Fields can have multiple values within an array map to a single field.

I hope that anyone else that has this problem finds this to save them some time.


I used drush cache-rebuild and now it works!


How to check if 2 email fields have the same value entered during content creation?

Assuming this question is about D7, you could use the Rules module and create a (rather basic) rule like so:

Rules Event: Before saving content
Rules Conditions:

Content is of type "custom signup".
Entity has field (related to your 1st eMail field).
entity has field (related to your 2nd eMail field).
Data comparison: the value of the 1st eMail field is NOT equal to the value of the 2nd eMail field.

Rules Action: Show a message on the site (of type "error").


In first_module.routing.yml, controller there is no src and you use 2:  ::

first_module_hello_world:
    path: '/hello-world'
    defaults:
        _controller: '\Drupal\first_module\Controller\TrainingModule::helloWorld'
        _title: 'hello world'
    requirements:
        _permission: 'access content'

Also without src in drupal 8 there si no need to use  return $output;
Alsi class is not good. Class is TrainingModule not TrainingModuleControlle and file need to cole the some TrainingModule

namespace Drupal\first_module\Controller;
use Drupal\Core\Controller\ControllerBase;

/**
 * Controller routines for hello_world module routes.
 */
class TrainingModule extends ControllerBase {

 /**
  * Return the 'Hello World' page.
  *
  * @return string
  *   A render array containing our 'Hello World' page content.
  */
 public function helloWorld() {

  return array(
    '#type' => 'markup',
        '#markup' => $this->t('Hello World!'),
  );
 }
}

change first_module_hello_world: to first_module_hello_world.help:

make the file first_module_hello_world.module and write this code

function first_module_hello_world_help($route_name, $route_match) {
 switch ($route_name) {
  case 'first_module_hello_world.help':
    $output = '';
    return $output;
 }
}


How to filter types of Webforms with Views

You can enable Webform functionality on all the different content types. You don't have to use the Webform content type which comes pre-packaged with the module.

Make a new content type, and go to: /admin/config/content/webform and enable webform functionality on the new content type you created. Then add the webform to it.

Then you just need to filter by content type on Views.


Paragraphs Align Media Left or Right of Text with CSS

Yes, just CSS. You could use Classy Paragraphs to append CSS classes to your paragraphs depending on some field values, or you can do this very easily yourself (recommended) by preprocessing the paragraph in your theme's *.theme file.

Let's assume the position field is a single-value List (Text) field with the following allowed values:

image-left|image-left
image-right|image-right
image-top|image-top

Then you can easily retrieve that value and append it as CSS class by implementing hook_preprocess_HOOK:

/**
 * Implements template_preprocess_paragraph().
 */
function MYTHEME_preprocess_paragraph(&$variables) {

  $paragraph = $variables['paragraph'];

  // Retrieve certain field's values and add them as CSS classes.
  $classy_fields = [
    'field_image_position',
    'field_background_color',
    'field_social_media_type',
  ];

  foreach ($classy_fields as $classy_field) {

    if ($paragraph->hasField($classy_field)) {

      if (!$paragraph->get($classy_field)->isEmpty()) {

        $variables['attributes']['class'][] = $paragraph->get($classy_field)->getString();
      }
    }
  }
}

Which will result in image-right or whatever other class getting appended to this paragraph's attributes and it now can by styled accordingly:

<div class="paragraph-MYPARAGRAPH view-mode--default image-right">


How can I disable a single checkbox in a 'checkboxes' FAPI element?

A clean way does exist in Drupal 7! Apparently, per this post, it's not yet documented.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  $form['checkboxes_element']['#disabled'] = TRUE; //disables all options
  $form['checkboxes_element'][abc]['#disabled'] = TRUE; //disables option, called abc
}

Another example.

You can also set #access function to FALSE, to completely hide the checkbox.


You can use the http://drupal.org/project/blockreference.  It's a standard on our projects now.  It also works well with the http://drupal.org/project/bean module


In drupal 8 there are new display modes. They are not only to view the node (view mode). They are also for the node add form (form mode).

For example to change the node add form of the content type article you go to:

/admin/structure/types/manage/article/form-display

Here you can select which fields you want to show and how they are formatted (field widgets). You can make more adjustments with php in form alter hooks or with twig in templates.

By default you have one form mode for each content type. You can create more if you go to the admin interface of display modes:

/admin/structure/display-modes

If you want to use different form modes for different users you can use this module:

Form mode control

Readme:

  WHAT FOR ?

  Form Mode Control allows you to use the form modes for any bundle /
  entity, per role and for edition / modification. Which means using
  different forms (fields, order, widgets, etc.) for different roles.

  HOW TO USE IT ?

  A - DEFAULT FORM MODES

  1 - You must at first add form mode for content entities. Ex. : go to
  "www.your-site.com/admin/structure/display-modes/form/add" to add a
  new form mode.

  2 - Activate the form mode for the related bundle of the right entity.
  Ex.if we want to activate a form mode named Super 2 (machine name =
  super_2) for an article (entity type : Node, Bundle : Article). Go to
  www.your-site.com/admin/structure/types/manage/article/form-display
  and activate it.

  3 - Go to www.your-site.com/admin/people/permissions, a section named
  Form modes control was added for all form modes activated (and only
  activated), So , configure all permissions and give roles permissions
  to access form modes. NB, the permission Access all form modes allow
  you to access to all form modes linked to bundle and entity type.

  4 -  Then configure on the Form mode control administration page
  (www.your-site.com/admin/structure/display-modes/form/config-form-modes)
  and give for each role a default form modes for creation / edition (of
  course, each role must have access to the form mode).    B - ACCESS
  DIRECTLY FORM MODES    You can also use it with a simple extra query in
  the URL (?display=machine_name_of_the_form_mode) if the role is
  allowed to see it. Of course, the user must have the right permission
  for it.        Ex. : if you want to access to super_2, go
  www.your-site.com/node/add/article?display=super_2.


Table view: "Hide Empty Column" checkbox doesn't seem to work

Someone elsewhere suggested that I disable Twig debugging. This fixed this issue. Weird.


When you use Drupal's "attach" behaviors, use the provided context parameter in your jQuery selectors to limit the selector scope to only the part of the page that is being modified by AJAX:

(function($) {
  Drupal.behaviors.watch = {
    attach: function(context, settings) {
      $('.my-input', context).val('foo');
    }
  }
})(jQuery);


Limit account applicants with certain email addresses

In drupal 6 you can use the built in Access Rules to limit user sign ups to certain domains. It can be found at admin/user/rules/add

This no longer exists in drupal 7 because the functionality was moved into a contrib module called User Restrictions


hide passwords in drupal module settings

As you've already noted in the question, you can set '#access' => FALSE to any form element to remove it from display.

The correct place for this is in hook_form_alter():

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'relevant_form_id') {
    $form['some_element']['#access'] = FALSE;
  }
}

If you're asking for a way to do this generically, without having to target each element with a specific form ID/element key, then you're out of luck. Those fields are nothing special, just standard text fields, so there's nothing to distinguish them from any other text field.

Bottom line - you need to decide exactly what fields you want to disable, find the appropriate form IDs/element keys, and use the method above to apply the rule one-by-one.


Updating Drush when installed using pear

Although there is a pear package for Drush-8.x-6.x, if you are going to run this version of Drush I would recommend cloning it from git, and updating it with git pull.  You can also check for newer code with git status instead of drush self-update.

Discussions on the deficiencies of drush self-update should probably happen in the Drush issue queue. Briefly, it no longer handles the update operation itself, and while it works well enough when using stable versions of Drush, it is easily confused in other circumstances (e.g. when Drush-7.x-5.8 is newer by date than the 8.x-6.x-dev that you are running, even though 7.x-5.8 is built exclusively from features backported from 8.x-6.x-dev.)


Trying to figure out which view to edit!

You can perhaps figure out what View it is from the id and class names on the containing markup which should tell you the view and the view display to edit. You can also change the theme to a core theme like Garland to get around whatever CSS issue you're having to get into the edit mode so you can identify the view.


Global PHP "sort through" vs other fields

It has to be supported by the module supplying the field. In hook_views_data(), each defined field has a 'sort' element that defines the sort handler function for the field.


You can use the following snippet,

jQuery('body').ajaxSend(function((evt, request, settings)){
  if (settings.url == "<something>") {
    // Perform your operations
  }
});

However this function will be called for all the ajax requests, so you need to have perfect condition to determine the right URL.


Add help text to radio button when it's disabled

I would suggest you might want to think about using the Conditional Fields module and having two separate fields for the change in Group B.

But for this specific question-- not knowing your HTML structure exactly -- you'd likely just be adjusting the HTML of the label. And that would then be more of a JS design question than a drupal one (unless you are building a modue around the idea) ... how to do that best depends on how re-usable you'd want it. In straight up JS: I'd likely store a hashed array of the label text, then have arrays of the option b input radio button ids -- one for option a1, the other for option a2. And then have a function that works on the appropriate array, passing in whether it should be enabled for not: foreach optionba1; change state, unselect anything checked, change text (return to original or add new text).


bundle is the property on the object. It's where the value is stored. Properties can be assigned one of three ways:

public: these properties can be directly set or read on the object. Example:

$object->key = 'value';
$value = $object->key;

private: These can only be accessed by methods (functions) of the class itself. Nothing else can access it. For example, this will throw an error:

$value = $object->key;

Whereas this would be allowed:

class Example {
  private $key;

  function getPrivateValue() {
    return $this->key;
  }
}

$value = $object->getPrivateValue();

$key cannot be accessed outside of the class, since it is private. This can be used to enforce rules on the types of data to be stored in the property. Checks can be run to ensure it's an allowed data type.
protected: These are like private properties, however if a class extends the class, the extended class can access the property. If the property is private, extended classes cannot access it.

One thing for you to understand is that $node->bundle and $node->bundle() are not the same things. The first is a property, the other is a method. This should help understand, as a (non-real) example:

class Node {
  protected $bundle;

  public function bundle() {
    return $this->bundle;
  }
}

The above class has the property $bundle, and the method (function) bundle(). The method returns the value stored in the property.

Look at the error you are seeing: Cannot access protected property Drupal\field\Entity\FieldConfig::$bundle. This is because you are trying to access the $bundle property, but it is protected, meaning you cannot access it from outside the class.

To get the bundle of a node, you need to call the bundle() method on it, which will give you the bundle type. This is the answer to your question about which to use.

  And in a more general point of view, are there some guidelines when to  use functions and when to use variables?

It's generally thought to be a best practice to not provide direct access to properties on objects, and instead create setter and getter methods (functions) on objects to set and retrieve the property values. That way you can say, enforce a pattern:

class Example {

  protected $username

  public function setUsername($username) {
    if (!is_string($username)) {
      throw new \Exception('Username must be a string');
    }
    elseif (!preg_match('/^[a-zA-Z0-9_-]{3,12}$/', $username)) {
      throw new \Exception('Username must be between 3 and 12 characters, and may contain only alphanumerics, underscores or hyphens');
    }

    $this->username = $username;
  }

  public function getUsername() {
    return $this->username;
  }
}

The above enforces that username is both a string, and is the right length and only contains allowed characters.

Edit: Additional comment from Leigh:

another reason to avoid accessing the property directly is when you have multiple values. e.g. if you have a field "my_field" on a node which has multiple values if you use $node->my_field->value you'll only get 1 value returned


For the default value for the field (under Field Settings), in the "Summary" field, you can put a blank " ". This will force the summary field to show up. If you want to do it the correct way, then you will have to check the Javascript that shows/hides the field.


Feeds importer pass header values when fetching feed

feeds httpfetcher append headers was the module I needed. Once i switched the fetcher I was able to pass in the password & user name into the get request to authenticate the request.


content field user reference populated by view (views2)?

The way I understand it, CCK will list all views on your site that return USERS, so, make sure your view is of type USER not NODE.


How to pass a value from form(block) to the page and show this page?

Read about hook_menu and wildcards. Here is an example:

function my_form($form, &$form_state) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Name',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Ok',
  );

  return $form;
}

function my_form_submit($form, &$form_state) {
  $form_state['redirect'] = 'path/' . $form_state['values']['name'];
}

function MODULE_menu() {
  $items['path/%'] = array(
    'title' => 'TTITLE',
    'page callback' => 'my_page_callback',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function my_page_callback($var) {
 return 'HELLO ' . $var;
}


entity_load not fetching the updated column

If I have understood you correctly, as well as updating the table you must provide an updated schema definition for the entity. Drupal uses this definition to determine the names and properties of the columns in the entity.

Note you do not need to do an 'update' action for the schema definition: just change it to match the current code. You (only) need the update hook for databases that enabled the earlier version of the module. Also, importantly, the update hook must both add the column to the database, but set the new property value for any rows appropriately. Often this can be done by the database default value, but not always.


Change the Default " - Choose -" text in Ctools Jump menu?

Just had a look at the ctools_jump_menu function's code here.
I would try the following:

$options = array( 'choose' => 'CUSTOM TEXT' );
$form = ctools_jump_menu(array(), $form_state, array($url => t('Classified Ad'),$url2 => t('Places'),$url3 => t('Facility')), $options);

Hope this helps!


You've got two underscores in your menu function declaration, try changing it to:

function module_menu() {

Other than that your code is fine, although on the off chance you're using this module to create a custom content type I'd recommend changing the name of your callback function so you don't get a collision with hook_form().


How to fix my Rule to notify authors of products by email at order completion?

Preface
I have the impression that there is indeed "something wrong" in your rule, but please allow me to start with some (constructive intended) critique about the rule you created ...
Your issue may be partially caused because of the naming conventions you used for the variables in your Rules Actions. Your rule processes thingies such as entity_created, list_item and entity_product_created, etc. And you didn't post many details about what this rule is supposed to actually do/achieve. So probably only somebody who knows how to "read" Rules in its export language, may possibly be able to understand your current rule.
Imagine how much easier it would be to READ your rule if you'd have used variables such as admin_order_confirmation_msg, line_item and ordered_product.
What your current rule seems to be doing
By using the kind of variable names I suggested, it seems to me that your last Rules Action is an attempt to send the entire content of the message that you created in your first Rules Action (to be delivered to commerce-order:owner as per that same 1st Rules Action). But in this last Rules Action you ask the Message Notify module to eMail that very same message to what appears to the eMail Id contained in a user object whereas that user object corresponds to the ordered_product in the line_item being processed.
To move on, let's assume you really want the entire order (of X line items) to be eMailed to each (cfr your Rules loop) user that matches a specific ordered_product in any line_item. If that assumption is wrong, then make sure to add another Rules Actionn to create another message (entity) specific to a single line item (which is what I'd do, so that these messages would only contain data about "a" line item, not all of them ...).
Maybe the message module is confused
I've never tried, in a rule, to send the same message "entity" via Message Notify module and also have that same entity delivered (saved) with the Message module. So could it be that you're just confusing the Message module?
And another cause of possible confusion is within the rules module, where sometimes it gets tricky to "save entities". So possibly adding an appropriate intermediat "save entity" action may also help (if nothing else helps).
Time for some basic Rules debugging
Just (temporary) add a Rules Action to "display a message" (located within group "System"). And show the actual value of your token event-creator:mail as part of that message (btw: this is a Drupal status message, not anything related to the message module).
Based on the actual eMail Ids that will be shown in those debugging messages, you'll know in which direction to move forward to fix your rule.
Maybe add 'Replacement tokens' to your Message entity
If anything above does not help to solve your issue, then it may well be that you can get it to work with the technique of Replacement tokens. For (way) more details on that, head over to the answer to What's the purpose of "Replacement tokens" of a Message type?. I'm pretty sure that using this technique you can create a perfect solution to your issue. If you have more questions about that, use this link.


You can use Views Bulk Operations, which allows you to replace that administrative page with a view. As you are using a view, you can add an exposed filter to filter the list of nodes by the title, or any other parameters you choose; the screenshot shows a view that can filter the node list by the author or the state of the nodes.

As far as I recall, VBO comes with an example view that can replace the administration page for the content; you just need to change the URL used for the view, and customize the view itself.


Cached "Page not found" for anonymous users

Is the page actually handled by Drupal or is it a static .html file?
It looks like a file that shouldn't be handled by Drupal, the 500 error
http://www.checkupdown.com/status/E500.html indicates a fatal server error.

If it is handled by Drupal can you change the url to one without the .html & see if that works with caching. You could use the global_redirect module to forward the .html addresses, once you figure out why it's failing.

If it is a flat file you may need to change the .htaccess or settings.php file to allow the .html to be processed by the webserver without bootstrapping Drupal.

There is a massive thread about this issue on Drupal.org http://drupal.org/node/76824#comment-3299738 You may find an answer in there.

PS
If this is served on a shared host you may want to contact your provider, they can have some strange setups & can fix quickly if you explain clearly what is happening.


What module or views recipe can display a featured node with different layouts from the rest?

Seem that you can go with the module called views_nodes_split https://www.drupal.org/project/views_nodes_split

BUT, this is better solution if your using display suite already:
You can just use Display Suite + Views as there is a setting when choosing an output. Display suite lets you pick which view mode to use for each output:


How to change order_number on hook_commerce_payment_order_paid_in_full or hook_commerce_checkout_complete

I don't think it's a good idea to change the order id.

I would rather goto admin/commerce/config/order/fields and a new number field which will be used to store the 3rd party's order id in the field.

That way you are not changing the default workflow of Drupal commerce and it will also be easier for you to compare your order id against the third party order id if something goes wrong.


Is there a way to do concurrent editing?

You can use etherpad kind of feature which allows you to do concurrent edit of node body.

Etherpad is collaborative editor by which you can write any node field using concurrent editing. Check Readme.txt for installation purpose.

And one more thing if you have no permission to install etherpad on your server(as shared hosting will not allow it) then you can use Piratepad module, which allows you to embed the pad using iframe from piratepad site.


Custom Apache Solr search per usertype (Profile2 Module)?

Checkout the Search API module - this was developed to solve problems exactly like this. With Search API, you can configure multiple search engines, define the datasource it pulls them from (ex. Apache Solr) and then use its built-in views integration to create custom search sets (ex. for care givers pull only from these entities / content types, and show only these fields).


If you are running drush on you're local site, you do not need to include @pantheon.thecottagepress.dev to run the command. Just run drush from your site root as so: drush rr. Drush won't be able to run the command on a remote machine if it can't resolve the domain name.


Yes. You can do that with Fieldable Panels Panes (FPP). Here is a quote about it (from the module's project page):

... creates an entity that may be used in panel panes to create fieldable entity panes. These panes can be created either directly in the Panels UI or in a separate administrative UI and later added.
Once added, they can appear in the "Add content" dialog to be easily reused. Since they are fieldable entities, they can contain any kind of data that field API can provide.
Each entity supports revisions, and any revision can be made current without having to make a new revision.
Access control is provided by the CTools access method, for both view and edit access.
Bundles are supported and can be added via the UI or hook_entity_info_alter().
A Trello board is being used to help coordinate development.


You should be able to select the Path as a field as well. Then use that as a replacement token.

.

Optionally you can use the title as anchor title or alt attribute, but then you have to make sure to uncheck the "Link to Content" box.

.


You can do this in a couple ways.

Easiest, if you have only one Views page that needs this, you could go into your theme's directory and copy page.tpl.php to page-PATHTOVIEWPAGE.tpl.php and then inside there, put in the id, eg,

<body id="ID" ... >

Just change any /s in your path to this page to -s in the template name and you should be all set.  Take a peek at Drupal 6 Template Suggestions for more info.

Now, if you are going to want to do this in multiple pages or need it to be more extensible, then, yes, you will most probably want to add in a preprocess_page() hook in template.php as well as another custom page.tpl.php template file.

What you could do would be to copy page.tpl.php inside your theme to, let's say page-with-body-id.tpl.php.  Then, inside there, you could put something like this:

<body id="<?php print $body_id; ?>" ... >

Then, inside template.php you would add in a preprocess_page() hook, eg, something like this:

function YOURTHEME_preprocess_page(&$variables) {

   $whereami=$_GET['q'];  // eg, www.yourhost.com/WHEREAMI

   switch ($whereami) {

     case 'events':
     case 'news':
     case 'press':

       $variables['body_id']=$whereami;
       $variables['template_files'][]='page-with-body-id'; // and use this new template

       break;

    }

    // any other page preprocessing goes here

 }

Just make sure you don't create a page template that would match an existing path on your system.  I doubt www.yoursite.com/with/body/id exists but you never know :)

Otherwise, another good place to look for info is here: Overriding Theme Templates in Drupal 6.

Also, if you can use a body class instead of an id, this is even simpler:

function YOURTHEME_preprocess_page(&$variables) {

   $whereami=$_GET['q'];  // eg, www.yourhost.com/WHEREAMI

   switch ($whereami) {

     case 'events':
     case 'news':
     case 'press':

       if (empty($variables['body_classes'])) {
         $variables['body_classes']='view-' . $whereami;
       } else {
         $variables['body_classes'].=' view-' . $whereami;
       }

       break;

    }

    // any other page preprocessing goes here

 }

which will add view-WHEREAMI to the list of classes for the body in (most) default page templates.

RE: How do I do an if conditional based on a view in template.php, you can also do something like this in the appropriate spot:

$mgi=menu_get_item();

if ($mgi['page_callback']=='views_page' && $mgi['page_arguments'][0]=='WHATVIEWYOUARELOOKINGFOR') {

  // you are on the views page you are looking for

}


How to create custom access permissions for entity form

The reasons the dpm()'s in your hook are not showing is that this hook function is not being called when you access the form as an administrator (administrators bypass all access restrictions). I tested this for authenticated users, and it does work. The hook is called as expected. (To test it yourself be sure to allow devel permission to the authenticated user so that you can see the output of the dpm).  The hook is being called when a user accesses the form.


Hide views tab display on user profile to profile owner

You might have already thought about this, but you could make a Panel Variant that only shows to those roles.


Login Users action in, $action_links, how do i edit it?

In D7, if you visit core FORUM module & open forum.module file you will find this code between line no 186 to 208 -

if (empty($links)) {
        // Authenticated user does not have access to create new topics.
        if ($user->uid) {
          $links['disallowed'] = array(
            '#theme' => 'menu_local_action',
            '#link' => array(
              'title' => t('You are not allowed to post new content in the forum.'),
            ),
          );
        }
        // Anonymous user does not have access to create new topics.
        else {
          $links['login'] = array(
            '#theme' => 'menu_local_action',
            '#link' => array(
              'title' => t('Log in to post new content in the forum.', array(
                '@login' => url('user/login', array('query' => drupal_get_destination())),
              )),
              'localized_options' => array('html' => TRUE),
            ),
          );
        }
      }

This is responsible to generate the link & text which you are talking about. But hacking core is not advisable so please find a way to do it in some other way..


How can I improve as a site builder for dealing with errors I don't know how to handle?

I'm not really aware of a way to improve your workflow. In general I would recommend limiting your usage to modules that have hundreds or thousands of Downloads by site builders, but that is not a silver bullet. And, sometimes you need to use that -dev module that has only 5 downloads because it will save you tons of time in development work on your project.

Everyone typically builds up a listing modules they are familiar with, comfortable with and trust -- build that list for yourself.

Something you didnt mention and I think is a larger problem than what you've outlined is testing module updates to an existing site that is using tried/tested modules previously. I'm more scared of things breaking during a large update (even amongst stable modules) -- then of experimenting with modules earlier in my site building process.


Views of Node Revision with Revision Update Date Expose filter

Download and Enable the module 'better_exposed_filters'
Refresh view, then change Exposed form style to use Better Exposed Filters (under advanced).
Under BEF settings, use 'jQuery UI Datepicker' widget.


The simple way, (used to do all this useless stuff before GIT and capistrano...)

Copy/upload all (hidden) the contents of your Drupal folder in the public_html or whatever your server document root is for that site.

Export your local database in a dump file.

Create a mysql database on the live server, import the local dump.

Edit the sites/default/settings.php file on your live server to serve your new database credentials.
Edit the .htaccess file on the live server to your needs.

Visit your site.Clear the cache tables.

Set the correct permissions on settings.php (check status reports for errors) and the desired setUp on sites/default/files etc for file uploads

That's all


Best way to inform users after file upload

Have you checked out the Entity Rules module? I believe this is exactly what that module is for.

I did a brief check and you can create a reaction rule on a Create Entity action and then check the type of that entity.


How to create a user with custom profile fields for a SimpleTest

in the setUp() method I simply added: variable_set('user_register', 1);

This way I could drupalPost a new account and login immediately without approval.

$this->drupalPost('user/register', $edit, 'Create new account');

Account is successfully registered and the required additional fields were collected during registration.


How to execute javascript from within an ajax request

Not sure of how you are making the AJAX call, but jQuery AJAX calls such as $.ajax let you execute a callback after the result has been returned. I recommend returning FALSE or a code indicating an error to your calling function and placing your "validation failed" logic inside of that in the success handler.


How to know if jQuery UI is being included

There's no built in way but as drupal_add_library() uses Drupal's static pattern you can find out by doing this:

function ui_is_included() {
  // Get the list of libraries included in this page load
  $libs = drupal_static('drupal_add_library');

  // The system library will pretty much always exist as it includes jQuery,
  // but it's just good sense to check just in case.
  if (isset($libs['system'])) {
    // If the system library array includes UI then make sure it's enbabled
    return isset($libs['system']['ui']) && $libs['system']['ui'] === TRUE;
  }

  // UI is not loaded if we've got to this point
  return FALSE;
}

You can even compress that down a bit:

function ui_is_included() {
  $libs = drupal_static('drupal_add_library');
  return isset($libs['system']['ui']) && $libs['system']['ui'];
}

I'd advise calling this function as late on in the page build process as possible, to ensure that all modules have had a chance to request that UI is added. hook_preprocess_html() in your theme's template.php file might be a good place to put it.


you can use the following, it implements drupal_add_css().

if($_GET['q']=="user/23/prayerrequests") {
  drupal_add_css(path_to_theme() . '/custom_stylesheet.css', 'theme', 'all');
}

Edit 1:
If you want this to be able to do it for all users, you could use me aliases module. It enables you to use me in place of %uid.
So, the code would become

// "me" from the code is automatically replaced by uid of current logged in user.
if($_GET['q']=="user/me/prayerrequests") {
  drupal_add_css(path_to_theme() . '/custom_stylesheet.css', 'theme', 'all');
}

Edit 2:
You can use the variable global $user in the above code. You'll not need to install me aliases module.

//replace THEME with your theme name
function THEME_preprocess_page(&$variables) {
  global $user;
  if($user->uid == 0) {
    return;
  }
  elseif ($_GET['q']=="user/".$user->uid."/prayerrequests") {
    drupal_add_css(path_to_theme() . '/custom_stylesheet.css', 'theme', 'all');
}

Don't forget to clear the caches.


How to have multiple instances of a field collection on single content type?

There is an issue for that: https://drupal.org/node/1569970
You can try and help that issue get moving.

Or you can give up and create several Field Collection bundles. If you go down that route, you could possibly use Bundle Copy, but it doesn't currently support Field Collections. Luckily, there is an issue for that: https://drupal.org/node/1589118
And that issue has some patches and some testing, so I'd probably just try it.


Is there a way to let every user can choose (e.g. on registration) whether their field is private or public?

If you want to do this without writing any custom code, you could use Panels.

Create a boolean field, Show my address publicly, and add it to the user profile.

Then override the user profile display with Panels.  Add all of the fields that you want to display, including the address field.  Then, add a Visibility rule to the address field and set the condition to be Show my address publicly == TRUE.

This is a bit complicated to set up if toggling the display of the address is all you want to do, but Panels offers a lot of flexibility (without writing code) that could be used for other things, too.


Go to

Home  -> Administration  -> Configuration ->  Search and metadata  -> Search API

& Edit your Index Search. Then your URL will be like below. In my case it's

Content Search

/admin/config/search/search-api/index/content_search/

So I'm using

$data['search_api_index_content_search']['inspiration_first']

I think in ur case it will be

$data['search_api_index_search_content_index']['inspiration_first']

Please share your URL if didn't worked.


Email Change Confirmation module -- Avoid confirmation email from user_login hook

After looking at the email_confirm code, I came up with a simple solution. A confirmation message isn't sent if an email address is changed to or from empty, so:

  user_save($user, ['mail' => '']);
  user_save($user, ['mail' => '<new address>']);

does the trick.


How to export / import images uploaded using CKeditor

You can get the uploaded files from the D6 files directory, and upload them to the default directory that CKEditor is set to use in D7. When you import those nodes, you can either change your XML source directly, or use the Feeds Tamper module find/replace plugin to rewrite the paths in the body field to the new location.


Restricting Field List Entries Based on User Role in Drupal 7

There is a contributed module available in drupal.org 'Field Permissions' .

http://drupal.org/project/field_permissions  We can set the field  permission based on user role.

Hope this will help you.


How do I push module update in a cached production environment?

Short answer : make extensive use of drush !

This was quite straightforward  and successful, though I'm still not really sure if I have to empty both opcache and Varnish. This would be a huge performance hint on production server. IMO the best would be to invalidate only the changed files in opcache and voilà ?

Steps I did (local dev) :

drush up flag -y
drush cc all
tested flag features, OK.
commited & pushed files to stage on a flag branch

The steps then on remote server :

git checkout flag
varnishadm -T 127.0.0.1:6082 -S /etc/varnish/secret (enter Varnish Cli)
varnish> ban req.http.host ~ dev.example.com && req.url ~ . (clear varnish cache)
reset Opcache with Opcache GUI
drush updb
drush rr (optional in that case since this was performed in flag_update_7300)


How do I add extra/custom plugins in CKEditor?

You have to build a plugin in Drupal using the CKEditor classes in the CKEditor module in core, it is not an automatic integration.

Check some of the existing modules that integrate plugins for examples on how to do this.

Checkout:

CodeSnippet
Color Button
Panel Button