Batch API operations are driven by the end user and browser with meta refresh, which makes it not possible to use in web services. However we can think about implementing the same thing using Queue API.

This should give you enough to go on to re-implement your RestResource or Controller to use your own Queue service.

Summary

I've used the following pattern in the past.

First request has a payload that can instantiate the operation.

It's important to make sure we're not flooding the serve so make sure you have flood protection.
Make sure that we have access to do the operation.

A response is returned with progress state and a queue item ID.
Subsequent requests have a payload with the queue item ID from the previous response.

These requests process 1..n queue items.
We need to claim queue items ourselves because we're processing queue items manually and not with a cron queue worker.
Make sure that things are valid and return the appropriate response code for validation, fatal or other errors.

Request payloads

Initial: {"queue": null}
Subsequent: {"queue": {"item_id": 1}}

Response payloads

Initial

{
   "success": true,
   "finished": false,
   "queue": {"item_id": 1},
   "progress": 0,
   "max": 23,
   "errors": [],
   "result": "something custom here",
}

Finished

{
   "success": true,
   "finished": true,
   "queue": null,
   "progress": 23,
   "max": 23,
   "errors": ["something wrong happened at some point"],
   "result": "something custom here",
}

Queue API

The complexity here is that we cannot use cron queue workers. So we need to implement the database calls to get and claim queue items ourselves. Unfortunately the current Queue API classes are pretty limited in both Drupal 7 and Drupal 8. In the former, I used custom functions to fetch and update queue items directly from the database while in the latter we can create our own service, based on DatabaseQueue, and inject that into your RestResource plugin or Controller.


When using &drupal_static to cache variables how do I store an empty return result of null or false?

drupal_static()'s default value is null. So instead of doing this

<?php
$third_party_info = &drupal_static(__FUNCTION__);
if (!isset($third_party_info) && is_null($third_party_info)) {
?>

Try this

<?php
$third_party_info = &drupal_static(__FUNCTION__);
if (is_null($third_party_info)) {
?>


Custom content type and custom list view

If you're wanting to build "lists" of things then I would check out the Views module. You will create a new content view and filter by the new content type. If you're struggling building a View just google for 'drupal views tutorials' and there will be a ton to show you how to build things with views.


Displaying products per store in a marketplace

After 3 days of trying all kinds of Views setting, I finally found a solution to this issue, https://www.drupal.org/project/commerce/issues/3153177


I am trying to modify a form element using hook form alter but I can't find the correct field name

When you can't find an array key, the best thing to do is to dump the entire form array and search for it. If you use the Devel module, you can use the following:

dpm($devel);

This will give you a nice collapsible output through which you can search. Or you can use the old-school method that I use, and dump it directly using:

die('<pre>' . print_r($form, TRUE) . '</pre>');


Yes, Drupal is a good choice to get started.. You can create and maintain site without PHP knowledge using Drupal since your requirements is very simple and can be achieved using out of the box Drupal.

You can try using OpenPublish Distro..

  OpenPublish is a packaged distribution designed for the online news
  industry. It is ideal for the implementation of a variety of media
  outlets sites including magazines, newspapers, journals, trade
  publications, broadcast, wire service, multimedia sites and membership
  publications. OpenPublish is built for flexibility, customization, and
  extension -- a powerful CMS to help publishers focus on their content.


hook_form_alter and fields in user_profile

As Kaido24 mentioned, the profile view tab is not a form. You can add elements to it in hook_user_view_alter().


Filter view based on displayed part of an Open Layers map

We had the same requirement in a recent project. It was solved with javascript, there is no out of the box way to do this.

Please see https://www.transpower.co.nz/projects

Here is some code to get you started:

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

  // ...

  $(function(){

    if($(".not-front .openlayers-map").length && !$('.node-type-project').length) { // only run when there is actually a map on the page, but not on the home page

      if ($('body').hasClass('page-community-initiatives')) {
        is_ci = true;
      }

      mapData = $(".openlayers-map").data('openlayers').openlayers;
      pointLayers = mapData.getLayersByClass("OpenLayers.Layer.Vector");

      // cycle through all layers and points on those layers, adding the points to an array
      for (var i in pointLayers) {
        for (var j in pointLayers[i].features) {
          pointData.push(pointLayers[i].features[j]);
        }
      }

      // if we've pulled out some points, go make a list
      if (pointData.length) {
        makeList(pointData, ".pane-openlayers-map");
      } else {
        $('.pane-openlayers-map').append('

Your search returned no results, please try again.

')
      }

      // add event listener to the map to be fired whenever the user interacts with it.
      // calls refreshList function above
      mapData.events.on({
        "moveend": refreshList
      });

      Drupal.openlayers.popup.popupSelect.events.on({
        "featurehighlighted": popupOpen,
        "featureunhighlighted": popupClose
      });

    }

  });

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

The entire JS file can be download (unminified) from the theme. Please alter to suit your needs.


Page title with substitution on views page

You can't change the route object in a hook. Use a RouteSubscriber to add a dynamic _title_callback to the view route.

Otherwise setTitle() should work. The bug you've described is not a bug. It's about caching in general. When you add dynamic data you also have to add the cache metadata, which defines what kind of dynamic data this is.

For example if the dynamic title depends on the node 123:

$output['#cache']['tags'][] = 'node:123';


Using field_create_field and field_create_instance to add a checkbox to a content type

This is how you create a single boolean checkbox field and field instance: I have excluded checking whether the field or instance exists, for brevity.

field_create_field(array(
  'field_name'  => "my_bool",
  'type'        => 'list_boolean',
  'cardinality' => 1,
  'settings'    => array(
    'allowed_values' => array(
      /*
       * The docs say that this is optional, but without it,
       * the value is never saved to the datbase (tested with Drupal 7.28)
       */
      0 => '',
      1 => '',
    ),
  ),
));

field_create_instance(array(
  'field_name'  => "my_bool",
  'entity_type' => 'taxonomy_term',             // or 'node'
  'bundle'      => 'my_vocabulary_machine_name, // or 'my_content_type'
  'label'       => t('My boolean checkbox'),
  'required'    => false,                       // because not ticking a checkbox omits the value from $_POST
  'display'     => array(
    'default' => array(
      'type' => 'hidden',                       // optional. I want to hide it
    ),
  ),
  'widget'      => array(
    'type'     => 'options_onoff',              // gives you a checkbox
    'settings' => array(
      'display_label' => 1,                     // uses 'My boolean checkbox' as the label next to the actual checkbox
    ),
  ),
));


It's not too clear to me what you are asking but if you want to relate a content-type to another content-type you can use the Node reference from the References module.

You can include a field on your Event content type called Featured Event and relate it back to the All Events content type. Then limit the amount of values to one. Then when you create a node from the Event CT, you can relate it to whatever node you want from the All Events CT. Vice-versa you can create a relationship through the All Events nodes if you wanted to as well.

Then if you wanted you could use the Corresponding node references module to sync up node to node. This module will warn you if you have overloading references (more than 1:1 for a node) basically helping keep the integrity of the 1:1 relationship.


Long wait time for website and taking too much CPU+Memory

There are tons of performance options, I think with the beefy server resources you have we can tune it tremendously by doing the following:

Database tuning

MySQL - make sure QueryCache is setup, and InnoDB is the only table type being used. You'll want to look at the high performance sample my.cnf (config) that ships with MySQL.
Memcache - configuring Memcache will speed up tons of the queries and sub-queries Drupal is notorious for.
Session Cache - for handling a lot of concurrent [unique] login sessions you can consider using a NoSQL database engine like CouchDB/MongoDB, it'll free up your MySQL db from managing those sessions.

Web Serving tuning

OpCode Caching - speeds up PHP a lot, is basically a requirement on all Drupal servers nowadays. I use APC, and there are other solutions but APC will work reliably with very little setup; this one is a no brainer.
Caching - you seriously need to cache at least the home page for anonymous users, and when a user logs in their unique session will be handled correctly. Consider using Varnish (it'll allow your site to handle over 100x more anonymous traffic and there are tons of tips on how to use it with Drupal.

These are just the quick highlights of what you need to utilize. If someone says you can't use caching on your website then there is a flaw in either the product design or the system design. There are literally thousands of popular Drupal sites that manage tons of logins and anonymous traffic working just fine with this recipe.


Content type / block or page .. how do we create a small text for a page in D8

Blocks can be used for many things including showing simple texts. Go to /block/add and create a block. Here you can provide a description and some body text. After saving your block you are redirected to the block configuration where you can place it.

By placing the block Drupal creates a block instance. For more information please see: https://www.drupal.org/docs/8/core/modules/block/overview


It's under 'Advanced' on the right hand side. Then 'add' a NO RESULTS BEHAVIOUR.


Find webform submission ID in a custom submission handler

I have been able to get the submission ID in a custom submission handler using the following code.
$webform_submission->setSticky(!$webform_submission->isSticky())->save();
$sid = $webform_submission->id();


Why is the backup of the site not behaving the same as the original?

The problem was caused by .htaccess not being processed due to the "AllowOverride None" directive in my "httpd.conf" file.

Changing to "AllowOverride All" and restarting Apache cured it.


How to create Taxonomy Term using Services?

I'm using POSTER plugin (for Firefox) to post data.

Here are the parameters.

URL: [your path]/[end-point]/taxonomy_term.json

Content Type: application/json

Actions: POST

Here are the JSON formats.

To create Taxonomy Term

{
    "vid": "1",
    "name": "My First Tag",
    "description": "Term description",
    "vocabulary_machine_name": "tags"
}

To update Taxonomy Term

{
    "tid": "14",
    "vid": "1",
    "name": "My First Tag Edit",
    "description": "Term description changed"
}

Here tid is taxonomy id and vid is vocabulary id of the Taxonomy.

Hope it helps someone.


The node title is a property, not a field:

$product_query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'product')
  ->fieldCondition('field_line', 'tid', $selected)
  ->propertyOrderBy('title', 'DESC');


You should be able to do it with hook_module_implements_alter(&$implementations, $hook) in your module. Simply test $hook and if it is the hook you don't want implemented, unset($implementations['email_auto_login']).


The Wordpress Migrate module is a great example of how to implement a UI to upload a file and create a migration for it. Once you have that, it shouldn't be too difficult to run the actual migration via code.

Create Migration configuration from information and file provided to your Wizard Form. Then the following should work.

$migration = Migration::create($configuration);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable->import();


Can I have a views field handler with an exposed form, or a filter handler with pre_query?

If I understand your question correctly, here's how I would go about this:

What you need to do is create a base node view. This should have all fields which are present regardless of other options selected. You'll want at least one exposed filter, so that views will render a form which you can hook into for form alter. Your process for modifying the view on the fly will be two fold.

The first will be a hook_form_alter() in which you make any modifications needed to the exposed views form. Add in any custom form elements which you'll use to control the fields displayed in the view. In your submit handler, you'll need to stuff the form values into session, so you can access them later.
The second is to use hook_menu_alter to override the default page handling in views and provide your own callback. In that callback you'll need to programmatically load and display the view. You can also add/remove additional fields to be displayed on the fly by calling $view->override_option('fields', array($some_fields));. I recommend looking at exported views to get the proper format for this, as anything you see in there is valid to do before executing the view. After you've added the fields you need, just return $view->execute_display(); to render the view. You can see an example of where I do this at http://890234892342.privatepaste.com/6b72c3e011 -- In this case, I'm only swapping out views displays / filters / arguments on the fly, but the exact same method will work for adding/removing fields. Again -- looking at exported views code is a great method to understand how you can swap this stuff out on the fly. When trying to figure out the format for modifications I need to make, I actually modify the view, export it, look at the exported code, and then revert it back to what it was originally. This allows me to see how views is formatting various fields and what array I need to pass into $views->override_options() to get the desired behavior.

It's not a particularly easy process to either explain nor do, but this is an effective method for programmatically altering views on the fly. Feel free to ask followup questions if there is something you don't understand.


Custom Module Route run by External Cron Task

I would make an API endpoint with authentication. Like:
mysite.com/api/crontasks?u=user&p=password

And then authenticate it via controller!


How to display only the menu items and not the parent menu?

The Menu block module is the way to go.

Install the module
Go to your blocks page
Click on "Add new menu block"
Select your menu and the level you want it to show
Add that block to your footer region and you're set


Allow admin to discount line item price or give a user credit

This sounds like a good use case for commerce_coupon + commerce_discount.

Add these two modules (and dependencies).
Add a new discount for an arbitrary % or $ off.
Add a new coupon code for a particular user.

If the client wants to lock it down even more, you can modify the discount to specify a particular course/product that it applies to. You can also modify the coupon code to only apply to a particular user with a limited number of uses, date range it's valid for, and more.

You'll definitely want to add an "Order discount condition" to the discount to ensure that other products, shipping costs or donations are not discounted.

Once the client has set up the discount and coupon code, they can send this to the user they need to give the discount to.

It's difficult to say where you're getting stuck applying the discount to the order, but I'd guess it has to do with the relationship between discount + coupon. At first I found it really confusing why discounts and coupons needed to be set in two different places.

It also appears that the commerce_discount module is incompatible with default configuration of commerce_account_balance. No matter how a coupon code is applied or how much of the total it supposedly reduced, it still requested a downpayment to cover the total (undiscounted) balance. It's likely this could be fixed by changing the order that the rules are executed so that the discount is run before the balance is checked.


How to track users actions on a form in my website

PHP saves data once you click the submit button, so finding which fields they filled before quitting might not be that straight forward.
But you can always see how many times form was loaded and number of submitted entries to find the ratio.


You're missing the first required variable in the signature of your form declaration so things will never work quite as you're expecting.

The function signature should be:

function review_m_form(&$form_state, $node) {

Then you would attach it to your node content like so, remembering to pass the node as a parameter:

$node->content['form'] = drupal_get_form('review_m_form', $node);


How to display a specific form mode in a programmatically displayed form

You need to specify a form operation in the handler section of the custom entity:

/**
 * @ContentEntityType(
 *   id = "property",
 *   handlers = {
 *     "form" = {
 *       "default" = "Drupal\mymodule\Form\MyEntityForm",
 *       "status" = "Drupal\mymodule\Form\MyEntityForm",

You can define multiple operations for the same form class. In this example I used status for the form operation, because this name usually doesn't contain the entity type name.

Then you should be able to use the form mode status in the entity form builder:

\Drupal::service('entity.form_builder')->getForm($property, 'status')


read new menu link id (mlid) before new menu item is saved

As Clive points out, the best way to do pass a menu link ID (mlid) when a menu item is created or updated is to use hook_menu_link_insert(), hook_menu_link_update() and hook_menu_link_delete() instead of hook_menu_link_alter().


The Drupal theming system has a concept called "template suggestions". When a theme hook is invoked, Drupal checks if the theme hook is implemented as a template or as a function. In case of a template, All preprocess functions for that theme hook are invoked. This means that every module or template can add its own data to the variables that will be made available to the template. Those variables are passed around as a large array, $variables. This array can contain a list of template suggestions as a nested array called $variables['template_files']. Drupal will later reverse that list and use the first existing template it can find. See the documentation on drupal.org for more details.

Now what you can do is:

Add a function to your theme's template.php named [themename]_preprocess_[themehook] (eg. function mytheme_preprocess_block(&$variables) {} )
In that function, construct the desired template name suggestions
Add those suggestions to the $variables['template_files'] array

By the way, if I'm not mistaken you cannot use the region name in the template suggestion, because at the time the block is rendered, it is not yet known in which region the output will be shown.

PS 1: It helps if you tell us which Drupal version you're using.

PS 2: I'm voting for this question to be moved to https://drupal.stackexchange.com/


Nexus theme slider is not showing up when logged out

Yes, it is because your custom.js is causing conflict with the slider.

You need to use the proper synthax for jQuery.

As mentioned in Working with JavaScript and jQuery

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

    //code starts
    $('#main-menu > nav > ul').mobileMenu({
    prependTo:'.mobilenavi',
    groupPageText: Drupal.t('Main'),
    topOptionText: Drupal.t('Select a page')
    //code ends

  }
};
})(jQuery);


Hide a field on a user profile if the logged in user has a specific role

You need to download and install module Field Permissions as suggested by @Pierre.

Then click on configure link:

Here you will find that Y field on which you want to apply permissions:

Then click on User link and you will be redirected to a form:

Here you can add custom permissions like I did.


CSS class for view display not being applied

I said IF its D7 bc I could not find what version. I was reading it on my phone. But here's your Drupal 6 answer:

But here's the template suggestions for D6:
http://drupal.org/node/1089642

You can download devel module to get template suggestions as well.

-OR-

Download this module to add css classes to specific blocks:

http://drupal.org/project/block_class


Specified template file for user-profile-form based on role

You can simply load $user variable in your template file and check which role current user is having and simply based on the role print your form.
for e.g

if ($user->roles[4] == 'role1') {
  print render $form['form_field1'];
  print render $form['form_field2'];
}
if ($user->roles[5] == 'role2') {
  print render $form['form_field_field1'];
  print render $form['form_field_field2'];
}

In the end don't forget to print the following

print drupal_render_children($form);


Errors when attempting to load Salesforce object from mapping admin page

I found the issue. For anyone in the future running into this error, I found that you must have both the push and pull submodules enabled for the mapping to work. I was only planning to push records into Salesforce so I mistakenly assumed I didn't need the pull modules enabled. With it enabled, the mapping worked like a champ.


Nope, there is none. No matter if by "current" you mean 7.x or 8.x, skipping 6 is too much gap, and even upgrades from 6 to 7 are known not to be painless and safe.

You may try to rebuild site's structure from scratch, and then use Drupal-to-Drupal data migration module to import your data:

  migrate_d2d provides a framework based on the Migrate API for migrating content from Drupal 5, Drupal 6, or Drupal 7 sites into the Drupal 7 site where it is installed. As of 7.x-2.1-beta1, it requires Migrate 7.x-2.6-beta1 or later.


can I implement select_or_other just with core form API?

Yes you can do that with FAPI & #states.

You would do something like this:

$form['options'] = array(
  '#type' => 'select',
  '#title' => t('Select'),
  '#options' => array(
    'one' => t('One'),
    'two' => t('Two'),
    'three' => t('Three'),
    'other' => t('Other'),
  ),
);
$form['other'] = array(
  '#type' => 'textfield',
  '#title' => t('Other'),
  '#states' => array(
    'visible' => array(
     ':input[name="options"]' => array('value' => 'other'),
    ),
  ),
);

This would make the "other" field visible when the value of the "options" field is "other".

For more info on states see the docs for drupal_process_states()


There are a couple of ways to tackle this...

If you're coding the node content yourself you can use the following snippet to get the output of a particular block into a string:

$block = block_load($module, $delta);
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
$output = render($render_array);

There's the Block Reference module

  Defines a field type Block reference which creates a relationship to a block and allows the block to be displayed as the content of the field. It saves this relationship using the block's bid, not its delta + module.


SMTP Error: Could not connect to SMTP host

Doh! It turns out this was not a Drupal issue, but a Centos issue with SELinux. I was able to check SELinx settings by running the following commands

getsebool httpd_can_sendmail

which returned

httpd_can_sendmail --> off

and

getsebool httpd_can_network_connect

returned

httpd_can_network_connect --> off

I enabled them by running this

setsebool -P httpd_can_sendmail 1
setsebool -P httpd_can_network_connect 1

And the Drupal SMTP module worked beautifully after that. Hopefully this helps someone else as well.


How do I add a cachebreaker to a specific image style in drupal 7?

Use template_preprocess_field() to set a flag with drupal_static() when a particular style is being used. This function needs to sit in your themes template.php:

function MYTHEME_preprocess_field(&$variables) {
  // Check field type is an image.
  if($variables['element']['#field_type'] == 'image') {
    // Loop over each image.
    foreach($variables['items'] as $k => $item) {
      // Check the image style is the one we want to append a timestamp to.
      if($variables['element'][$k]['#image_style'] == 'timestamp') {
        // Set a flag to say to modify this URL.
        $append_ts = &drupal_static('append_ts', TRUE);
        $append_ts = TRUE;
      }
    }
  }
}

Then we can use hook_file_url_alter() to modify the URL if the flag is set. This function can live in your themes template.php or a custom module.

function MYMODULE_OR_MYTHEME_file_url_alter(&$uri) {
  // Fetch our flag we set in bartik_preprocess_field.
  $append_ts = &drupal_static('append_ts', FALSE);
  // Fetch an array of URI's that this function has already processed.
  $processed_uris = &drupal_static(__FUNCTION__, array());
  // If the flag is true and we've not already processed this URI...
  if ($append_ts && !in_array($uri, $processed_uris)) {
    // Add this URI to our processed list.
    $processed_uris[] = $uri;
    // Set flag to false so we only edit this URL.
    $append_ts = FALSE;
    // And finally create the new URL with a timestamp.
    $uri = file_create_url($uri) . '?t=' . time();
  }
}

The use of the flag in this instance is necessary as we can't check what style the image is using in hook_file_url_alter(), but it is possible in template_preprocess_field().

To append a timestamp to the image on the edit node page

Use hook_theme_registry_alter() to add a preprocess function to the image_widget:

function MYMODULE_theme_registry_alter(&$theme_registry) {
  $theme_registry['image_widget']['preprocess functions'][] = 'image_widget_preproccess';
}

In the preprocess load the field instance config settings, and then check them to see which image style is being used. If the correct one then make changes to the markup to add a timestamp:

function image_widget_preproccess(&$element) {

  $entity_type = $element['element']['#entity_type'];
  $field_name = $element['element']['#field_name'];
  $bundle_name = $element['element']['#bundle'];

  $field_instance_info = field_info_instance($entity_type, $field_name, $bundle_name);

  if($field_instance_info['display']['default']['settings']['image_style'] == 'timestamp' && isset($element['element']['preview']['#markup'])) {
    $element['element']['preview']['#markup'] = str_replace('?itok', '?t='.time().'&itok', $element['element']['preview']['#markup']);
  }

}


Programmatically update Webform Submission by sid

Try using \Drupal\webform\WebformSubmissionInterface::getData(); and
\Drupal\webform\WebformSubmissionInterface::setData($data);

// Load submission using sid.
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = \Drupal\webform\Entity\WebformSubmission::load($sid);

// Get submission data.
$data = $webform_submission->getData();

// Change submission data.
$data['element_key'] = 'custom_element_value';

// Set submission data.
$webform_submission->setData($data);

// Save submission.
$webform_submission->save();

Update: Use a capital "E" in "Entity" for the class name. (Recently got updated).


Hide/Remove core simpleTests in Drupal 7

You can implement hook_simpletest_alter, e.g.

function hook_simpletest_alter(&$groups) {
  // An alternative session handler module would not want to run the original
  // Session HTTPS handling test because it checks the sessions table in the
  // database.
  unset($groups['Session']['testHttpsSession']);
}


Build custom module with similar maintenance mode behaviour

You are getting the regions being printed because your page callback is returning a string. If you want your page callback to just print your output, you need to change your code to the following one.

function my_custom_module_page_callback() {
  print theme('my_custom_module_template');
}

The reason is visible in drupal_deliver_html_page(), which uses the following code.

// Menu status constants are integers; page content is a string or array.
  if (is_int($page_callback_result)) {
    // Omissis
  }
  elseif (isset($page_callback_result)) {
    // Print anything besides a menu constant, assuming it's not NULL or
    // undefined.
    print drupal_render_page($page_callback_result);
  }

If your page callback returns NULL (which also happens when it doesn't have an explicit return statement), then drupal_render_page() will not be called. As result, just the output from your page callback will be returned to the browser.

This is what node_feed() does: It prints an RSS feed without letting Drupal output anything else. Contrary, the output would not be handled as a RSS feed from the client side.


How to use a views contextual filter OR?

Try the patch in this issue : Pull filter value from an argument

It allows you to pass the value from the contextual filter to the "normal filter". There you can do your advanced conditions.


CyberSource order gets stuck 'In Checkout', never completes

Figured out the issue: In uc_cybersource.module there is a line in function uc_cybersource_hop_form($form_state, $order) that reads

$data['orderPage_version'] = '4';

It needs to be changed to the current orderPage version (as of this writing it is 7).

$data['orderPage_version'] = '7';

This should definitely be documented somewhere!


Is it possible to use an Image Style in a text field?

It depends on what you mean by "possible" :-).

The Scald module (integrates with the WYSIWYG CKeditor) uses something called "contexts" that in turn makes use of the preset image styles.  So it is certainly possible to do this if you use Scald to insert images into WYSIWYG.

Scald has a drag'n'drop UI that allows you to place an image (or "atom" in Scald-speak) into WYSIWYG. When you do that, you can set its legend (i.e. caption), context and alignment (see sample dialog below):

In this case, the "Context" is set to "Full page". which I have associated with the preset Image Style known as "Large 480x480".

Below, you can see the markup that is generated by Scald as a result of this, and you can see that it links to the image using the path:

public:://styles/large/public/thumbnails/image/fredespenbenth.jpg

the styles/large path is indeed the image cache for the preset "Large 480x480" image style.

This is the caption that will appear under the image..

Now, as you can see, Scald is doing this, so it must be possible.

And you can (to some extent) do the same thing without Scald by inserting similar markup "by hand" or with the help your own custom module.  But Scald has in place additional magic to regenerate that style of the image in the image cache if it does not exist.  If you do this just by inserting the markup, you can't be sure that the image exists in that style, so you have to use other means to make sure the image cache is populated with the styles you actually use.  (For example sniffing for URLS pointing into the cache in hook_preprocess_node(), and regenerate those that are missing.)


How to comment out code in a .tpl.php template

I actually prefer to use this way

<?php if (FALSE): ?>

  <?php if ($submitted): ?>
    <?php print $submitted ?>
  <?php endif; ?>

  <?php if ($terms): ?>
    <?php print $terms ?>
  <?php endif;?>

<?php endif; ?>

This make it easier to put the block back in (change FALSE to TRUE), or attach a variable to the conditional.

EDIT:

To address your example, I would do it one of two ways

<?php if (FALSE): ?>
<?php if ($logo): ?>
  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
  <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />

<?php endif; ?>
<?php endif; ?>

or

<?php if (FALSE && $logo): ?>
  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
  <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />

<?php endif; ?>

I would normally lean towards using the second in my daily work.


You're overriding wrong submit handler, normally VBO submit handlers are available under $form['select'] key in $form array. You can confirm this in your case by printing $form in hook_form_alter(). Make sure to use proper form ID as well before using, you can confirm form ID by printing $form_id variable available in hook_form_alter(). Below is example of altering VBO Form and overriding submit handler (In my case I've only one submit button).

/**
 * Implements hook_form_alter().
 */
function [MODULE_NAME]_form_alter(&$form, &$form_state, $form_id) {
  // Confirm $form_id before using.
  // echo "{$form_id}<br>";
  switch ($form_id) {
    case 'VBO_FORM_ID':
      // In VBO, normally submit handlers are available under 'select' key.
      $form['select']['submit']['#submit'] = array('MODULE_NAME_vbo_submit');
      break;
  }
}

/**
 * Submit handler for Views bulk operations.
 */
function MODULE_NAME_vbo_submit($form, &$form_state) {
  // Do your processing here.
}


Is there a way to get all researches one particular scientist has?

Yes, search for the scientist target id:
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([
  'type' => 'research',
  'field_scientists' => $scientist_id,
]);


Set the role of users when you're not the administrator user

See the Role Delegation module for this feature.


Printing fields in a View template file (Devel / Krumo)

You not using the correct Views template, views-view.tpl.php is the base template. You need to use views-view-field.tpl.php but you need to use template overrides in your theme.

Firstly, copy views-view-field.tpl.php from the Views module into your theme, make a copy of views-view-field.tpl.php calling it views-view-field--field_image.tpl.php and make your adjustments, remember to clear your template cache so Drupal picks up these files.


Try changing the following:

<?php
print theme('breadcumb', $breadcrumb);
?>

to:

<?php
print $breadcrumb;
?>

in your page.tpl.php

Source: https://drupal.org/node/481704


Link to anchor on current page with smooth scroll

Solved by using the Void Menu module and using the id of the anchor as one of the void options.

For example, my menu item says "<void2>" where void2 contains the id of the div "#aboutus".


EntityStructureWrapper for file field is not being inflated properly while iterating

Sadly, I am posting a very bad workaround for future reference. Anybody who can improve this is welcome:

function mymodule_node_insert($node) {
  //copy terms
  $nodew = entity_metadata_wrapper('node', $node);
  //@todo this is not cool, figure it out
  foreach ($nodew->field_media->value() as $delta => $files) {
    $filew = entity_metadata_wrapper('file', $files['fid']);
    $filew->field_taxonomy_entity_reference = array_unique(array_merge($filew->field_taxonomy_entity_reference, $nodew->field_taxonomy_entity_reference));
    $filew->save();

  }
}


Tag is the views cache plugin: \Drupal\views\Plugin\views\cache\Tag, that is in core.

If you are missing that then the files of your installation are messed up, you are possibly missing other files as well. You might want to re-upload all files and also consider using a more reliable deployment method like composer and not upload files over FTP or so.


Different suffix for multiple field value

You could use field collection and create two fields, one for the value and one for the suffix.


Reducing attached items within node.tpl.php

I like the Gallery Formatter module for my galleries. It's the Colorbox module is nicely integrated with galler formatter to give you a cool lightbox popup. Gallery Formatter will use the first image in your multi-value CCK image field as the first slide image, so you can drag the order of the images in the node form into the order you want them to appear in.

If you want to display the first image of your multi-value CCK image field separate from your gallery (like in a view that gives a preview of each gallery), I would first create an ImageCache setting that you want to use to display that image, and then output that image in your node template like so:

<?php print theme( 'imagecache', '[your_image_cache_preset_name]', $node->field_gallery_images[0]['filepath'] );?>


How to require one of many modules in your own module?

One option is to feature detect the modules using function_exists() or class_exists(), and then use some logic to pick the one you want.

You can also wire up a hook_requirements() to hard fail in the $phase == 'install' step or soft fail in the $phase == 'runtime' step.

How you handle the failures really depends on your application.


Views Exposed Filters - position each filter independently

you can add more functionalities to Exposed Filters forms, or control his style/layout, touching template views-exposed-form.tpl.php. try this resource http://drupal.org/node/320992 or this http://ykyuen.wordpress.com/2011/07/25/drupal-theme-the-exposed-filter-in-views/ to see guides about how to implement it.


Try Printer, email and PDF versions module.

  This module allows you to generate the following printer-friendly
  versions of any node:

  Printer-friendly version (webpage format) (at
  www.example.com/print/nid)

  PDF version (at www.example.com/printpdf/nid)

  Send by email (at www.example.com/printmail/nid)

  where nid is the node id of content to render.


My slider's images have larger file-size than their originals

Replace image style from the Slider's View (At Views module). I kept it without any style so the image won't be scaled to a larger style (You could scale it yourself with CSS in the relevant Div at the slider and it won't affect size).


Change field value with hook_views_pre_render()

I was trying to do something similar as well. I had an integer field and I wanted to replace the integer column with a string value. That was not working. So I had to add a separate string field, maintained the integer field as a hidden field and then overwrote the string field. The code that worked is given below.

function module_views_pre_render(ViewExecutable $view) {
  // Change the comments column in the list of filings table in the view case
  if ($view->id() == 'my_view') {
    foreach ($view->result as $key => $value) {
      $custom_id = $value->_entity->get('custom_id')->value;
      $string = convert_id_to_string_get_user_name($custom_id);
      $value->_entity->set('string_field', $string);
    }
  }
}

There is documentation and sample snippets here but looks like it needs more documentation.

https://api.drupal.org/api/drupal/core!modules!views!views.api.php/function/hook_views_pre_render/8.2.x


You can add search box in a preprocess function in your template.php:

<?php
/*
 *  Preprocess page.tpl.php to inject the $search_box variable back into D7.
 */
function MYTHEME_preprocess_page(&$variables){
  $search_box = drupal_render(drupal_get_form('search_form'));
  $variables['search_box'] = $search_box;
}

Then you just need to print the variable in your page.tpl.php:

<?php print $search_box; ?>


What are my options for a url based cache tag?

You could add a listing cache tag for the content type:
  'tags' => ['node_list:message'],

This cache tag was introduced in Drupal 8.9. See the change record Added an ENTITY_TYPE_list:BUNDLE cache tag.


Static variables are initialised once per page build. As soon as you refresh the page you'll lose any vars declared in your page build, including static ones.

If you want to persist data between page loads you need to use session storage


If you're running on localhost there is a great chance your emails will not be sent.

I would recommend using webform for your form modules as this is a very good tool for this.

And test the email part on an actual server. If you want to send emails locally you will need to set up your php.ini file:

See more info on that here: explanation here


Unable to import date from csv with Feeds module

Got it.  Turns out that adding a new mapping that used the same date field with the Deadling for Proposals: start target solved things.

This wasn't particularly intuitive for me, so maybe this will be helpful for someone else too.


Pass nid variable to Ubercart order in D7

If you are using Cart Links (/admin/help/uc_cart_links), you could pass a value for a text-field type of attribute on your product.
You'd have to add an attribute to the product node, and hide it via css or form_alter method on the product view page so that they couldn't overwrite it or delete it.
When they add attribute to the cart with the cart link, you can feed in the value with the url parameter like ( /cart/add/e-p23_q5_aThisNiceEscapedString. ).
Note that you can't just pass an integer to it, or Cart Links will think you are passing the AID (attribute ID)


Write anything as an author name on an article

Create a field that allows a user to enter text.
Implement a preprocess function that changes the values available to node templates (see the source code of template_preprocess_node() for a list of
available variables).
In the preprocess function, change $variables['submitted'] using the field you defined.

To use the already existing author widget, you would have to implement hook_form_alter() such that it removes the validation function from the form.

Now that the validation function is removed from the form, you also need a way to validate the node. For this, you can add your own validation function. This validation function would temporarily set the author field to a valid value and then call the original validation function.

You also need a new column to store the entered value in the database. The original column is not suitable, because it only holds integers. You also have to add an extra submit handler to the form, so that your data actually gets saved.

So yes, it is possible to use the author widget. But I advice against it. You will lose the information who really created the node. You have to manually deal with loading and saving the entry. And you are giving a well established widget a different meaning.


Remove Configuration Management Destination

Check please the arguments: https://drushcommands.com/drush-8x/config/config-export. You can use directly sync in your command

   drush cex sync -y


How to manage patches in composer when they're merged into the module?

Run your deploy build locally and if a patch fails during composer up and you see that it has already been integrated into the module, then delete the patch from composer.json.


Limit taxonomy terms that can be selected to 2nd level terms only?

One way would be to install the Hierarchical Select module which gives you the option to limit selections to lowest-level terms only:

The module overrides the default widget for the hierarchy on the default taxonomy page as well, so it might even take care of your second question for you (although I haven't tried that myself before).


comma separated cck multivalues in a view

Per the following on drupal.org:
http://drupal.org/node/1018198#comment-3993646

  You can do this by copying "views-view-field.tpl.php" into your theme's directory, under
  a name the view will recognize it selectively. Put the following code in it:

    print preg_replace('/<\/div><div[^>]+>/i', ', ', $output);

In your case, I think it would be:

  views-view-field--VIEWNAME--field_authors_value.tpl.php


validate a base field in a particular content type

Base fields are by definition not bundle specific, you can't add something for a specific bundle in that hook.

However, what you can do is save it as a base field override. See how NodeTypeForm::save saves different default values and labels for base fields as base field overrides.


Where is name defined in image_effect_info_alter(&$effects)?

First of all: I think the alter method should not exist if this is the easier way.

Call hook_image_effect_info() and just pass

  label, help, effect callback, dimension callback and form callback

this way it won't ask for

  name


How do I add a class to the search block form?

You can use the template_preprocess_form

function THEMENAME_preprocess_form(&$vars) {
  // Add class to your specific form
  if ($vars['attributes']['id'] == 'search-block-form') {
    $vars['attributes']['class'][] = 'form-inline ';
  }
}

NOTE: the preprocessor you are using adds class to the block element


Is is_front variable available in menu.html.twig template?

is_front variable is not available in the menu template by default. You can add it there by adding this into your themename.theme file:

function themename_preprocess_menu(&$variables) {
  try {
    $variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
  }
  catch (Exception $e) {
    $variables['is_front'] = FALSE;
  }
}


I don't think there's anything already in page.tpl.php but it really depends on what is happening in the preprocessor(s) of your theme. I don't know what theme you're using.

If you're worried about calling a function like comment_count_unpublished() multiple times in one page load why not statically cache the result with drupal_static()?

Have you actually profiled that query and shown that it will cause problems on your site? Drupal generally runs hundreds of queries each page load so I don't think counting the unpublished comments in that table would have a noticeable impact on most sites.


Display blockquote of text in article post, while showing original

You can style the block quote using the blockquote {} tag in CSS.

For example, something similar to the image you uploaded...

blockquote {
float:left;
margin:20px;
font-size:1.2em;
color:red;
}

However, your client would need to enter the piece of text twice.


Drupal 6 site running slow on my localhost

Profile it; it's on your local box, so it can be done. Until you do that it's a bad guessing game. What all contributes to drupal page execution time?


This is not really an answer but closer to one than I've been before; even though I cannot go any further.

In /core/themes/bartik/templates I've placed a copy of commerce-order-receipt.html.twig. I can change the wording in this template, refresh the cache and I can see that come through in new emails. I see there's a mention of an 'order_entity' which I do not know how to reference so it appears in an email receipt.

If you can see the screenshot I've uploaded, it may become clear where I'm at or where I'm going wrong.

I thought I might be able to change one of the columns in the order item (as the current four columns are exactly those that appear in receipt emails) and then try and reference it through {{ order_entity.getSomething }} in commerce-order-receipt.html.twig (after clearing the cache).

If I can get the fields in 'Purchased Entity' into the receipt email, I can then complete my business case for my Drupal site as everything else works a treat.

Thanks again.


Views with attachment - How do I exclude pagination offset on every page but the first?

There is a workaround described here: https://drupal.org/comment/4109006#comment-4109006. It is for D6 but as far as I can tell it should work in D7 too. The approach seems a little odd and I didn't try it out on my own, but it might solve your problem.


How do I test if a field has a value in twig?

There is an issue about this on Drupal.org: Checking for empty fields in Twig templates is complicated.

Use the following syntax and keep an eye on updates:

{% if content.not_required|render %}
    {{ content.not_required }}
{% else %}
    {{ content.required }}
{% endif %}


You could use the Rules module to do this.


Don't allow role to delete published content even its their own

Simply search for and disable the permission "Delete any content" for any / all content types for the role of "writer".

This is also a very handy module to help you find permissions https://www.drupal.org/project/permissions_filter


How to build an editable view of two entities linked together?

You are making a relation and editing a field of the relationed content "Survey", if a "User" is relationed to the same Survey content, will change on all of them.

If it is a different node "Survey" for each "User", it should't change all of them. I just did a test with your conditions and everything is going great. Could you give more information like configuration, multivalued, etc. of  those fields?


Showing content associated with node reference in a view

If I understand correctly, you have a single node (type TV Show) with several related nodes of type Episodes, each Episode node describing an episode of the particular TV show.

If this is correct, this is a common error. Your node reference field should be on the Episode type, and should refer to the TV Show type.

Then a simple view of Episodes with a contextual filter on Node ID will give you what you want. Just make sure the reference goes in the correct direction.


How do I remove the tab provided by a third-party module?

I solved this with the Tab Tamer module.

  Tab Tamer is an administration utility that provides easy re-ordering, hiding, and deactivation of tabs and subtabs.

  Tab Tamer makes use of Drupal's drag ordering, but degrades gracefully when javascript is disabled.


Use Url Argument in contextual filter for Block View

I found the solution for this issue. I used PHP code by selecting "Provide Default" and Select PHP code as below to extract arguments from URL and provide a filter to your view.

$path = drupal_get_path_alias();
$path = explode("/", $path);
return $path[2] /* Since explode function return array of url arguments, select required arguments starting with 0.*/


What theme do you use?
Have your tried unsetting the comment links in your node template using something along unset($content['links']['comment']['#links']['comment-add']);?


You can always alter any form by hook_form_alter,in your case it would be somewhat closer to following

// Implements hook_form_form_id_alter().
function my_module_name_form_user_register_form_alter(&$form,&$form_state) {
  $form['help_text'] = array(
    '#markup' => 'Your help text will go here',
    '#weight' => $form['mail']['#weight'] + 1; // Or could be a fix value.
  );
}


My suspicion is you are having an issue because you are trying to access this in a Display Suite template, rather than from a page template.

You can probably access it via {{ ds_region.field_color.0 }} in the ds-3col.html.twig file. Some notes:

Replace ds_region with the name of the ds_region you want - e.g. middle.
The 0 will mean it prints the first item in the array - if you only have one item, this should be enough
You will need to have the field in the region on your Manage Display page.
Once done, you can then print {{ left|without('body') }}.
Make sure to clear your cache

I hope this helps.

You could also try to {{ dump }} the variables and see what is available for you (or better still {{ kint }} if you have the devel module installed), that will help you drill down through the options to get the one you need.


Its simple, follow the steps.

Create a view of employees.
In the Format section show fields instead of content
Add the fields, Employee Name, Skill, Company Name
Add a Contextual Filter, Content: Has taxonomy term ID

Provide default value as Taxonomy term Id from URL
Select Specify validaion criteria

Select the validator Taxonomy term and choose your vocabulary - Skillset
In filter value type, select Term name converted to Term ID

Add a relationship Entity Reference: Referenced Entity
Now add the fields, Phone, Address, but make sure you are selecting the relationship that you added.


How can I add superscript character in a textfield

On a vanilla drupal 7 site you can set the text format of the field to full HTML and use standard HTML to render the superscript.

For the paste from word functionality, I would recommend adding the WYSIWYG module and following the instructions to get a proper editor like ckeditor. Will be a world of difference.


Creating menu items for views during installation of a custom install profile fails

I've found it!
Adding "'customized' => 1" to the options of each menu item did the trick.


The submit function is correct. By default, Drupal should call Mymodule_user_profile_form_submit() function without declared it with the '#submit' attribute. Could you publish all the code to have a deeper exploration of it?

Edit:

You could try this:

$form['profile']['profile-share']['profile-save-reset-btn']['submit']['#submit'][] =  'Mymodule_user_profile_form_submit';

The atrribute is in the upper side of the rendering array. The attibute should be at the same level to be fired when the submit button is pressed:

Here an example of form api reference:

$form['actions']['delete'] = array(

  '#type' => 'submit',

  '#value' => t('Delete'),

  '#weight' => 15,

  '#submit' => array('node_form_delete_submit'),

 );

You could also attach the '#submit' in the upper level if you declare '#type' as 'form'. For example:

$form['#type'] = 'form';
$form['#submit'] = array('your_function');
$form['first_tree']['element'] = array( ... ) ;
$form['second_tree']['element'] = array( ... ) ;


You need to override the theme_link function.
In your template.php file add this. (changing THEME to the name of your theme).

function THEME_link($variables) {
  if ((isset($variables['path']) && ($variables['path'] == $_GET['q'] || ($variables['path'] == '<front>' && drupal_is_front_page())))) {
    // Return text instead of link if current menu item active
    return ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text']));
  } else {
    return '' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '';
  }
}


Problem with getting number of nodes created by a user in a View

You should make sure that you have no sort criteria set in your view that splits your aggregation.


Include full term name including "in" "and" etc when used for URL alias

You can choose "strings to remove" on the settings page:

/admin/config/search/path/settings


You need Simple Drupal AJAX load with jQuery and delivery callback  which is explained in  5 simple steps this page.

So include a anchor link through the form alter and have the link render the content through attached javascript file through jQuery.load() function.

To attach js file,

$form['#attached']['js'][] = array(
  'data' => drupal_get_path('module', 'module_name') . '/some_file.js',
  'type' => 'file',
);

For Drupal ajax forms refer this official documentation.


Create a custom module and use the hook_views_Data. Here is a link for doing that


How do I apply different css files to different viewports with Omega subthemes?

The way I see it you've got 2 options:

Option 1: Don't use multiple style sheets. You can have conditional elements in a single CSS file using CSS media queries like this:

// Default styles
.content {max-width:960px}

// Tablet styles
@media only screen and (min-device-width: 600px) and (max-device-width: 960px), screen and (min-width: 600px) and (max-width: 960px){
  .content {max-width:600px;}
}

// Phone styles
@media only screen and (max-device-width: 600px), screen and (max-width: 600px) {
  .content {max-width:100%;}
}

That will even work on a desktop PC with a small window. For more info go here.

Option 2: There is a way to include those conditions in a link tag. That way you can divide up your CSS files for easy viewing. Like this:

< link rel="stylesheet" type="text/css" media="screen and (max-device-width: 600px)" href="mobile-view.css" />

You'll have to include it manually. I don't know if drupal_add_css will work with media property. You might have to use drupal_add_html_head.


They aren't junk files, they are aggregated files are generated when you have CSS aggregation turned on. They make your page load times faster, as multiple files are aggregated into a single file, meaning less files have to be downloaded to the browser.


Is there any way to reorder the nodes in a View?

You may also consider using the draggableviews module. Basically you create an "administrative" display of your view allowing arbitrary reordering of the content of the "main" display using drupal drag-and-drop interface.

There's also a comparison page for node ordering modules on drupal.org


My Superfish menu is being repeated 4 times. Why?

Fixed. I did all sorts of things but it looks like it was just being cached.


Show a form element only to certain roles

Generally when you are hiding fields from user roles there are security implications.

The visibility state functionality you mention just hides things on the front end, which is not secure in terms of stopping users editing fields they are not actualy allowed to use.

If you want to use custom code, you can do this:

/**
 * Implements hook_form_alter().
 */
function MODULENAME_form_alter(&$form, &$form_state, $form_id) {
  // To get the currently logged in user.
  global $user;
  // To target the required form.
  if ($form_id == 'FORM_ID') {
    // Set the role ID of the role that can edit.
    $rid = ROLE_ID_FOR ROLE USER NEEDS TO EDIT;
    // If user doesn't have the role in question.
    if (isset($user->roles[$rid])) {
      // Deny access to the field.
      $form['FIELD_NAME']['#access'] = FALSE;
    }
  }
}

This is a basic example and you might have to change it to deal with multiple roles having access or something.

This is ok for custom forms or if you only need to control access to a couple of fields but if you want more control or don't want custom code, etc, the best option is the field permissions module.

With that module you can go to the field edit form and select to use custom permissions, after which you can select which roles can access the field.

EDIT
To answer the edit in the question, your code

// If user doesn't have the role in question.
if (isset($user->roles[$rid])) {

Is doing the opposite of what the comment says it is doing.
To do what the comment says you would want to do this:

// If user doesn't have the role in question.
if (!isset($user->roles[$rid])) {


how to create template file for single page in drupal 7

use "page--node--nodeid.tpl.php" template. you can find the nodeid for this page when editing.

edit "about us" page, you will got url like this http://www.example.com/node/1/edit

digit "1" in the url is node-id.


How do I make theme suggestions for pagers?

mytheme_suggestions_pager_alter is the correct way to use the hook. The issue was my pager in the view footer was not working and this stop the function from being called


Check this line in buildItems() which is called by $menuTree->build($tree), in \Drupal\Core\Menu\MenuLinkTree.php:

  // Generally we only deal with visible links, but just in case.
  if (!$link->isEnabled()) {
    continue;
  }

It's designed to exclude links that are not enabled. I played around with something like this to get them all showing:

foreach ($tree as $id => $treeItem) {
    // Get the link definition.
    $definition = $tree[$id]->link->getPluginDefinition();

    // Skip links that are already enabled.
    if ($definition['enabled'] == 1) {
        continue;
    }

    // Change definition and enable link.
    $definition['enabled'] = 1;

    // Recreate the link.
    // I'm not 100% sure about the correctness of this part.
    // This is my first time playing with this stuff. Hopefully someone can fill in this blank.
    $pluginContainer = \Drupal::getContainer();
    $conf = [];
    $newLink = \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::create($pluginContainer, $conf, $id, $definition);
    $tree[$id]->link = $newLink;
}


How can I change a rendered user display to a combination of fields linking to the user?

One option would be to use:
Real Name

The RealName module allows the administrator to choose fields from the
user profile that will be used to add a "real name" element (method)
to a user object. Hook_user is used to automatically add this to any
user object that is loaded. It will also optionally set all nodes and
comments to show this name.

For Example:

By default only the raw username is being shown, as you can see at the
top of the page.

Change this to:

Result:

source: Change Drupal Usernames with the Real Name Module


How to apply flags retrospectively for group subscriptions using Organic Groups?

I seem to understand from your question, that you're looking for a way to flag the existing members of an OG group.

If that's what you want, then a possible approach to make this work, is to process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

load the VBO list of users (of an OG group) that you want to be processed.
add a loop to perform a Rules Action, whereas you just flag each user contained in your Views results.

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".

PS: if this is NOT what you want, by using this approach (anyway) I believe your question about "Is there a way to force Flag to check if a group subscription exists already?" became obsolete ...


It really all depends on where $total_order is defined/declared etc.  You might be able to use the http://drupal.org/project/computed_field module to do the math and just rewrite the field with the text "spend [field] euros more...." to do it, or, if that doesn't work, or adds too much complexity, just create a views template for the field that does the math in php there and displays the field.


Drupal patch files - Why do Drupal patches have complicated file names?

It just provide good information about the patch.

Here is the proper way to name a patch

[project_name]-[short-description]-[issue-number]-[comment-number].patch

Why? Here is a list of why these name are useful...

[project_name] - We use the project name to distinct the patch from other projects. Sometimes some project have multiples sub-modules and it just nice to have a name in front of the patch.
[short-description] - This is just a well practice from git, which is adding a small description about the patch.
[issue-number] - With unique issue number we can make sure what this patch is trying to solve because we can visit drupal.org/node/[issue-number] and see what is trying to solve.
[comment-number] Usually, there are multiple patch in the same issue queue and we need way to distinct different patch for this reason we add the comment-number so we do not get confuse when we are reviewing patches.

For more information about patches naming visit - Making a Drupal patch with Git

  And also a subtle question: If I download a file with a long name and
  than changed the name to something like "fix1.patch" just for
  navigation comfortability, Will it still work as normal as it should
  have been?

Patches names does not have any affect to the patch content. This been said, it will work, it just that developer was very lazy and did not want to name it the proper way (or he/she did not know how to in Drupal we name patches).


Strange Issue with displaying information of the current term

If the contextual id is working on the 3rd view, then you should set the validation criteria to convert the term to an id:

That might fix the "inherit filters" of your views footer.

EDIT: An answer to your second question about reflecting your architecture in the url structure and breadcrumbs.

I have made two videos where I've concocted two different ways to make a Drupal Commerce Catalog using hierarchical taxonomy (either with one vocabulary or multiple vocabularies). Both of these ways of using Views and Taxonomy creates urls that reflect where you are. I'd bet with a little creativity you could make views create a breadcrumb as well.

Hierarchical Views Catalog using Taxonomy
Multi-vocabulary Hierarchy Views Catalog

Hope that helps!


Organic Group: Can not create group type content?

You should change the number of value for the group_group field to unlimited.
That field must be in the content type which you defined as group.


Add product variations to product display with rules

Even though I've quite a bit of experience with the Rules module, I don't know (yet) of how to do exactly as you described in your question (also because your question does not exactly include the details about which Event(s), which Condition(s) and which Actions you are looking for (try to be more specific on that (by editing your question accordingly).

I might enhance my answer (soon), but while waiting you may want to look/investige if either of the approaches below can be of any help ...

Commerce Bulk Product Creation

Consider using the Commerce Bulk Product Creation module. Excerpt from its project page:

  ... facilitates the creation of groups of related products in bulk. Product administrators can select a number of options for various fields, and a product will be created for all possible combinations of these values. Out of the box, only list fields are supported for this, but an API exists to enable other types of fields for 'combination creation'.

Attention: this module doesn't have an official release yet (only an RC6), though with over 1.600 reported installs, it seems it is pretty stable / trustworthy.

Commerce Backoffice

Another option to consider is using the Commerce Backoffice module, e.g. because of the auto creation of product display nodes. It provides the backoffice functionality present in Commerce Kickstart (V2), and contains these sub-modules:

Commerce Backoffice Product (commerce_backoffice_product).
Commerce Backoffice Order (commerce_backoffice_order).
Commerce Backoffice Content (commerce_backoffice_content).

This module (and a few dependencies) provides the rich store owner experience that has made Commerce Kickstart 2 so popular (and prevents that you have to install the entire Commerce Kickstart distribution). And there is a great video introduction about it also.

Note: if you use Commerce Backoffice, you most probably also want to use the Shiny administration theme, also used in Commerce Kickstart (V2).


If you can use Views, it'll be simple.

Views can provide each field's value as a row. Set it up to display fields, add your multivalue body field, filter by node id, and you can set up views pager to show one row per page.

Then, use Pathauto to create nice addresses for nodes of that type, like /multibody/[nid]. In views, use the same address and voila - node pages got overriden with your view. Use Global Redirect to redirect from /node/[nid] to /multibody/[nid] to make sure users will not end up reading whole node at once.


Is it possible to add translation to smiley alt and title in CKEditor?

Never tried but I'm pretty sure that's possible.

If you use the ckeditor module, you can alter JS settings through PHP with hook_ckeditor_settings_alter.

Knowing that, it becomes pretty easy to wrap all strings with the t() function:

function yourmodule_ckeditor_settings_alter(&$settings, $conf) {
  foreach ($settings['smiley_descriptions'] as $key => $smiley) {
    $settings['smiley_descriptions'][$key] = t($settings['smiley_descriptions'][$key]);
  }
}

If you use the wysiwyg_ckeditor module, you can use hook_wysiwyg_plugin. That's pretty much the same thing, you can find a pretty good example on how to use this hook here.

Again, the code hasn't been tested, but it should be a good starting point ;).


How to know which file to delete in a submit function?

Ok I solved this but it will be different for each type of form.  The form I was adding this managed_file upload to is actually the image effect form. (image_effect_form(), I had to do some form_altering to add my submit function.) My goal was to add a new image effect that allows placing a source file onto the destination image.

What I finally did was compare the $form_state variables in the submit function for the following actions:

uploading a file when none was previously there
removing a file and submitting no file
removing a file and uploading a new file

For this particular form I came up with the following variables:

$new_fid = $form_state['values']['data']['myformfile'];
$old_fid = $form_state['image_effect']['data']['myformfile'];

Once I got what the new FID is and what the old FID was It was trivial to put together some logic that deletes the file at the appropriate place. The problem is that this isn't universal logic that works for every type of form that has a managed_file in it. There didn't seem to be a standard way to get what the old file FID was. I found it for this specific form but for the next time I do a managed_file I'll have to examine $form_state again and find out if/where the old file FID is stored.

My code for the submit function is below. I also added some logic for the file_usage table.

$source_file_new_fid = $form_state['values']['data']['source_file'];
$source_file_old_fid = $form_state['image_effect']['data']['source_file'];

if ($source_file_new_fid != 0) {
  $source_file = file_load($source_file_new_fid);
  $source_file->status = FILE_STATUS_PERMANENT;
  file_save($source_file);
  file_usage_add($source_file, 'imagemerge', 'image_style', $form_state['image_style']['isid']);
}

if ($source_file_old_fid != 0) {
  $del_file = file_load($source_file_old_fid);
  file_usage_delete($del_file, 'imagemerge', 'image_style', $form_state['image_style']['isid']);
  file_delete($del_file);
}


get node by address field and part of name

You could do this by building the query up in smaller chunks and using a loop to add the field conditions for the mulitple words .  I'm not sure how of how you'll be passing the data in but say you have an array of words in $words.

$query = new EntityFieldQuery();
$query-->entityCondition( 'entity_type', 'node' )
    ->propertyCondition( 'status', 1)
    ->fieldCondition( 'field_adresse', 'locality', 'Paris' );

foreach ($words as $word){
   $query->fieldCondition('name', 'value', $word, 'CONTAINS');
 }

$result = $query->execute();

This code isn't tested and I've written off the top of my head. https://api.drupal.org/api/drupal/includes!entity.inc/function/EntityFieldQuery%3A%3AfieldCondition/7.x


How can I exclude folders when updating drupal using drush?

If you want to update Drupal core without updating contrib, use drush pm-update drupal.  Always upgrade a copy of your site and test it before modifying your production site.

If you want to avoid updating just a specific contrib project, use drush pm-update --lock=skipthis.  The lock is persistent until removed with --unlock.


How to use/show different path alias of same URL according to user roles?

The ensure the right path is used when displaying links, you need to implement hook_url_outbound_alter() in a custom module.

/**
 * Implement hook_url_outbound_alter().
 */
function MODULE_url_outbound_alter(&$path, &$options, $original_path) {
  if ($path == 'node/add/my_content_type') {
    $path = user_is_logged_in() ? 'addlink' : 'suggestion';
  }
}

Ensuring the right path is always used can be achieved with a hook_menu_alter(). There, you can alter the page callback for node/add/my_content_type. And in your callback, check whether the user is accessing the page using the expected path.

/**
 * Implements hook_menu_alter().
 */
function MODULE_hook_menu_alter(&$items) {
   $type_url_str = str_replace('_', '-', 'my_content_type');
   $items[['node/add/' . $type_url_str]['page callback'] = 'MODULE_my_content_type_add';
}

/**
 * Page callback for the add new My Content node page.
 *
 * @see MODULE_hook_menu_alter
 */
function MODULE_my_content_type_add($type) {
  $expected_path = user_is_logged_in() ? 'addlink' : 'suggestion';
  if (current_path() != $expected_path) {
    drupal_goto($expected_path);
  }
  else {
    return node_add($type);
  }
}

If you site use multiple language with prefix language selector, then current_path() will also contains the language prefix whch need to be accounted for in your code.


You've structured your data in such a way that this can't be done with a single SQL query. You'll always be asking the database for two separate things: (1) a list of people based on their real names, and (2) a list based on their nick names.

But it doesn't have to be this way.

The easiest way to accomplish Picture 4, by far, is to always represent a person's "Name" as an additional "Nick Name".

So "Daina" should have 4 Nick Names: "Kristi", "Rita", "Sweetie", and "Daina". Then, all you need to ask the database for is a list of nick names.

This probably isn't the answer you're looking for. But I would argue that it's a more correct way to store your data. Think of the "Nick Name" field not as a list of alternate names, but rather as a list of all names that the person is known as. Based on the requirements of your situation, that's what it sounds like you're really after, anyway. It's a more complete model for your name data.


No search results display when using core search

Actually, It was just a refresh happens to the page, while clicking the search button.  Anyway, I just added custom search module in drupal and its now working fine :).  Thanks for all :)


Why can't I override my menu in Drupal 7 with theme_menu_tree?

Drupal 7 theme can implement a THEMENAME_menu_tree__MENU_NAME() or THEMENAME_menu_link__MENU_NAME() function to override theme_menu_tree() or theme_menu_link() for a specific menu.

References for overriding the specific menu:

https://gist.github.com/gagarine/3201854
https://gist.github.com/henrijs/6225177

Can you once try passing $variables as reference to the THEMENAME_menu_tree__MENU_NAME() as below:

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

Note: Clear the cache after making the changes to the code in order to make sure implemented changes reflects on the site.


Views - how to create a chart AND a table from the same filter selection

I can do that in the following ways:
a. Create View page to generate table with exposed filter
b. Clone the view page (table), and change the title name and the path
c. Change the cloned page from Table to Chart, set the field for the chart setting to display, then save
d. Open the original table page view, the add footer -> global view -> select the view chart that you created in (b)

Now you have table with filter on top, and the chart below (also with the same exposed filter). The chart follows the results of the filter on the table.
I use CSS to hide the filter for the chart on the footer.


How to define a custom menu and show it like an admin menu in Drupal 8?

This is how i add custom menu :

In a custom module :

  xxxx.module :

/**
 * Implements hook_toolbar().
 */
function xxxx_toolbar() {
    $items = [];

    $items['Boutique'] = [
        '#cache' => [
            'contexts' => ['user.permissions'],
        ],
    ];

    if (!\Drupal::currentUser()->hasPermission('Access the Commande overview page')) {
        return $items;
    }

    $items['Boutique'] += [
        '#type' => 'toolbar_item',
        '#weight' => 1,
        'tab' => [
            '#type' => 'link',
            '#title' => 'Boutique',
            '#url' => \Drupal\Core\Url::fromUri("internal:/admin/boutique/commandes"),
            '#attributes' => [
                'title' => 'Boutique menu',
                'class' => ['toolbar-icon', 'toolbar-icon-boutique'],
            ],
        ],
        'tray' => [

            'configuration' => [
                '#type' => 'link',
                '#title' => 'Commandes',
                '#url' => \Drupal\Core\Url::fromUri("internal:/admin/boutique/commandes"),

            ],[
                '#type' => 'link',
                '#title' => 'Livraison',
                '#url' => \Drupal\Core\Url::fromUri("internal:/admin/boutique/livraison"),

            ],
            [
                '#type' => 'link',
                '#title' => 'Configuration',
                '#url' => \Drupal\Core\Url::fromUri("internal:/admin/boutique/configuration"),

            ],

        ],
        '#attached' => array(
            'library' => array(
                'boutique/admin',
            ),
        ),

    ];
    return $items;
}

And the result :

You can manage access with :

  if (!\Drupal::currentUser()->hasPermission('Access the Commande
  overview page')) {
          return $items;
      }

in the xxxx.module like me.


Filter date + between dates is not possible

I followed the following steps using a Date field and got the intended result:

Firstly add your date field as a View filter

I left the configure date filter settings as default here

Configured the "greater than" exposed filter

Configured the "less than" exposed filter

Exposed filters appear correctly

Those are the exact steps I followed to get the two exposed date filters. Hope you come right!


Unable to add images to content "Image field is required"

The error message appears to be a red herring. Even though I thought I had fixed the nginx upload file size limit, I found that it was still at the default of 1mb. I fixed the upload limits to be sufficiently large in both nginx and php, and I was able to successfully add media content.


Here is how you can do it:

  $params = drupal_get_query_parameters();
  $form['cat'] = array(
    '#type' => 'select',
    '#title' => t('Categories'),
    '#options' => $categories,
  );

  if(isset($params['cat'])) {
    $form['cat']['#default_value'] = $params['cat'];
  }


PayPal Payflow Pro not allowing user to buy product

No one but me seems to have encountered this problem. But in the oft-chance someone ever does encounter it, here's why.

This error is occurring because I had removed the default address field from the customer profile > billing information in my drupal commerce store in favor of custom fields. But you apparently HAVE to use the default dynamic address field, or at least I don't know a way around it.

Since most of those fields are valuable anyway, and I just wanted them really in a different order, I found it valuable to KEEP that field, add some custom fields as well, and then just re-order them using hook_form_alter() and the '#weight' property of each form element. Additionally using this function you may also hide any of the fields in the default address field (it contains multiple fields) that you don't want.


You'll need to use a validation function alongside an ajax call to check for validity, you might want to look at other solutions like How to validate and submit a form using AJAX? to get an idea about how this could be done.

If you are using the Addressfield module (D7) you may find some of these problems are already taken care of, or are easier to solve than with a standard set of input fields.


Filter by specific field when webform exports

You need to use the Webform View Integration and create a custom Views Data Export.


Use Private Files download permission module to set permission to download to certain users.

Also you can go for Field Permission Module


Determine Array Key For Field Type Programatically

My solution ended up being this:

$field_structure = field_info_field($field_name);
$keys = array_keys($field_structure['storage']['details']['sql']['FIELD_LOAD_CURRENT']['field_data_'.$field_name]);

This gives an array of all the posible data columns for $field_name, where $field_name is something like 'field_my_field'.


How to display a video file without using the video hosting websides?

The Media project (https://www.drupal.org/project/media) has support for displaying uploaded video files using native HTML5.


basic question: fast mobile site with omega

Adaptive Image is great for loading a smaller version of the images on smaller devices. It determines breakpoints, or you can set them, and saves an image into different sizes. Then automatically loads smaller images on smaller screen sizes.

For hiding content, you need to decide if you want the website to be adaptive or responsive. If you are hiding block regions on a tablet view (<768px), and someone who had their window size reduced makes their browser window full screen on a desktop, are they suddenly going to be missing blocks and regions?

I tend to just use CSS media queries, and re-arrange the content on smaller devices, and If I really have to, then hide content with display:none when the browser window, or device screen size gets reduced to a certain width.


Bootstrap framework - Sub-theme template.php not having any effect

If you change in template.php then you have to clear the theme cache. Because the contents of the this file is cached in the database, so altering it will not be noticed by Drupal.

You can clear cache from here

Drupal 7: Administration > Configuration > Development > Performance (admin/config/development/performance)

For more information visit Clearing the theme cache


Is there an option in the Views 3 UI to reset one section of a non-master display to the default state?

Yes, just edit a filter or field and choose "revert to default"


Go to /admin/appearance/settings/YOUR_THEME_NAME and scroll to the bottom and find the logo field and upload your custom logo

See the following for a nice visual walkthrough.

http://www.inmotionhosting.com/support/edu/drupal-7/customize-theme/upload-custom-logo


syncronize drupal 7 users with magento 1.7 customers

I would use Rules to trigger an action whenever a new user is created (and/or updated which will also matter in your scenario). This action can be a PHP script so the possibilities you have to interact with other software (Magento) are endless.


How do I get a hold of the session object in my form handler?

The conversion to the Symfony session component is not yet complete, therefore you still have to access the session using the superglobal.

Follow https://www.drupal.org/node/1858196 and its sub-issues, if you like to stay up to date regarding this issue.


If it's a limited set of pictures that you have then I would just write a custom formatter that displays for example an image tag with a data attribute that has your list of image paths (maybe with the first image already set as non-JS fallback maybe). then you just need small bit of JS that picks one of those randomly and sets it as the actual src attribute. Your page is fully cacheable then and while it might still be a noticeable delay until the image shows up, that can even happen with static image links on slower connections.

And it will certainly be much faster than an ajax request.

The placeholder approach might also work and Drupal supports that kind of out of the box with dynamic page cache, doesn't need a reverse proxy or so for that. but you would have to disable the internal page cache then on that page. See http://www.qed42.com/blog/lazy-builders-drupal8 for an example on that.

The way that works with Dynamic Page cache is that the whole page with the placeholders is cached, and then calls the defined lazy builders which returns the actual content for the current request. You would want to use a similar approach as with JS, prepare all image urls for example already as arguments and then just pick one from that array and render it.


Why do I get "Command pm-disable needs a higher bootstrap level to run"?

This generally means that drush can't identify the site information, e.g. which settings.php to use.

A quick fix is to cd into the directory with the setting.php file for the site.

A more permanent fix is to create a site specific drush alias for the site and use it.  E.g. drush @mysite dis varnish. See this Drupal page.


For theming cart page add page--cart.tpl.php in your theme's templates directory.

For theming checkout page add page--checkout.tpl.php in your theme's templates directory. If you want to theme only the checkout review page add page--checkout--review.tpl.php in templates directory.

After adding tpl files do not forget to clear cache.

If you want to know about more hooks do a dpm($variables) inside YOURTHEMENAME_preprocess_page function and look into the theme_hook_suggestions array.

For details read this comment http://drupal.org/node/1142800#comment-5365466


found it here
 $view->field['field_description']->options['label'];


Create a Rule that assigns a specific role to a user after they have completed a form

Sure you can! This is a way of doing it with the Rules module.

This also requires the Webform Rules Module.

Download that, enable it, and be sure that the Rules UI module within it is enabled as well.

Step 1 - Create Rule

Start by creating a new Rule under Admin>Config>Workflow>Rules.

Name it whatever you'd like, but have it react on "After a webform has been submitted"

Step 2 - Find Webform's NID

In another tab, view your Webforms in Content>Webforms. Hover your mouse over the Edit link next to the Webform you were talking about to find its Node ID (NID). You will need this in a second.

Step 3 - Only Apply Rule to that Particular Webform

Return to the Rule you created a bit ago and click the "Add condition" link under "Conditions".

Select "Data Comparison" as your condition.

Here, you are going to select "node:nid". This is because you only want this rule to fire up when the Webform you mentioned earlier is submitted.

Below that, enter in the Node ID for the Webform

Step 4 - Add Action for Adding Role

Return to your Rule and click on the "Add Action" link in the "Actions" settings.

For your Action, you are going to select "Add user role"

Under the Data selector, you are going to choose "user"

Below that, select the Role(s) that you want the submitter to gain.

Hope this helps!


Can you force users to put all new content in at least one Organic Group?

In admin/og/og search the "Audience required" setting, and change it from optional to required, if you don't need it for administer accounts also.


Why do images rendered with image_style_url disappear on iPhone?

The problem is with jcarousel. The images are rendered fine, but width and height is set to 0 on mobile.
You should be able to set widht and height in CSS.
See possible solution here: https://www.drupal.org/node/576016#comment-6041834
Attached is iphone rendering:


You can achieve that using the Popup On Load module.

The module allows to display a popup once after a certain delay on a page load. This fills a gap in popup modules family (Popups, Popup), which are designed to show popups only after a click on an HTML element, or to implement a complex behavior like modal dialog forms.
If you want to just display a popup after a page load, the Popup On Load module possibly fits your needs

The following are one of the module's main features. See project page for more.

Create an action for popup display, which can be easily integrated
into Rules system.

Create a default rules set for popup display.


How to change redirect after adding node of a particular content type

You can do this with http://drupal.org/project/rules.

Just import this declaration and adjust it to your needs:

{ "rules_redirect" : {
    "LABEL" : "redirect to view",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_insert" ],
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "page" : "page" } } } }
    ],
    "DO" : [ { "redirect" : { "url" : "path/to/your/view" } } ]
  }
}


How to map term name via XPath node feed using xpathparser into Term reference field?

You create taxonomy vocabulary by name property types and attach this to the content type you are using for feeds import.
Map the fields accordingly.

//properties/item as context
propertytype to the term reference field you have attached to the content-type

But remember just create vocabulary and don't add any terms. Once you do feeds import you can see the terms under property type vocabulary.


user relationships - add friend link in a content-profile node

I followed the instructions that I found in the documentation of the module, and everything worked absolutely perfect. The steps for your reference were:

Enabled the modules: UR-API, UR-Mailer, UR-UI, UR-Views
Created a new relationship (e.g. friend)
In Permissions make sure that you have enabled the can have relationships permission in the user_relationships_api module (this is what I forgot the first time)

The rest of the permissions are pretty straight-forward. If you follow the instructions to the letter, you will get the link in the user profile page.

P.S: The guide in the above-mentioned link has a screenshot for the required permissions: make sure that your permissions match this screenshot's EXACTLY.

As for the block that you want to create:

Enable the UR-blocks module. It creates sample useful blocks (including a block for each relationship that you created). You can insert this block directly in the profile node using the corresponding tpl.php file and a code like the one that you can find in this article:

Drupal - How To Display Block In Node?


Display values from exposed field in Views as a Dropdown

There is a small mistake in the code

$value = $node->{$field_id}['und'][0]['locality'];

should be

$value = $term->{$field_id}['und'][0]['locality'];


It's a common issue that is reported here and even in the drupal documentation, the issue is reported so I think it's not yet solved at all so you need to find another solution that AHAH for the file upload filed.


No Ajax gets initialised from inside the modal

It could be that your behaviors aren't processing the newly added modal elements because of an internal JS error.

I determined this because that was the problem discussed in this D7 answer:

How to trigger Drupal.attachBehaviors after successful Ajax


Change text format used for text field when displayed in a view?

I found an issue concerning something similar to you question on Drupal.org

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

There is some module code provided which may be useful to you.

The module looks like it uses a field formatter.  Instead of taking out the media tags, it aims to strip out the resulting html tags.

$pattern = array('/
.+<\/div>/im', '/
<\/p>/im', '/
]+><\/p>/im');
  $item['safe_value'] = preg_replace($pattern, '', $item['safe_value']);


If I save created view and visit the view page it showing only filter field

I think you set  "age expose field  required" it cause in first load nothing show up till user enter something in filter.
try it with removing "Required" checkbox.


What is the best way to make a page that filters a content type using Ajax

Assuming you are using Drupal 7 Views is easily used and AJAX enabled. Advanced > OTHER > Use AJAX on the view edit screen. There are lots of documents, answers and functions to help you on your way.


private file downloads don't work with IE8 only when using hook_file_download

I found that if I added "'Cache-Control' => 'private, must-revalidate'" to the returned array within hook_file_download that the file also downloads for IE8 (see below section).

$mime_type = file_get_mimetype($uri);
return array('Content-Type' => $mime_type, 'Cache-Control' => 'private, must-revalidate');


how to export custom installed module(s) configurations?

These are my finding. Drush provides the sync, using mysql dump and restore as complete, not the changes made after some interval.
Many things can be tracked with

Configuration Module
Features
Extra Features

Please see the presentation for futher.
https://docs.google.com/file/d/0B6Sp-HBmxgGMMnhhQXVrR1hDUVU/edit?usp=sharing


How do I change my navbar from "left to right" to "right to left"?

Note: Following answer is for D7, but the concept is same for D8 also I think, if you want to do using CSS, Just you need to apply the same logic where to apply CSS float: left; and float: right;.

This you can do with CSS.

If there is just a menu with list of items, you can do easily with float: right at appropriate place.

But, bootstrap's default nav-bar contains Logo Site name primary-menu and Secondary-menu, Hence css will be some complicated.

Now, I have used the following set (LTR Default),

And after looking their HTML I have applied following CSS,

.navbar {
    .navbar-header {float: right;
        a.logo { float: right !important;}
    }
    .navbar-collapse{
        nav {

            ul.menu.navbar-nav {float: right;
                li {
                    float: right;
                }
            }
            ul.menu.navbar-nav.secondary {float: left !important;
                li {
                    float: right;
                }
            }

        }
    }
}

After applying the CSS, It has arranged in such a way.

If you slightly practice, you can by yourself come to know how it works, it is easy.


Drush minimal bootstrap only for variables for vget

The general answer to your question is that you cannot change the bootstrap level of a Drush command as a user; Drush has already specified the minimum bootstrap level in each command's command record.  Running a command at a lower bootstrap than it needs will cause it to fail.

However, in the case of variable-get, it looks like you are correct.  vget is set to use a full bootstrap, but it would probably work just fine with DRUSH_BOOTSTRAP_DRUPAL_DATABASE.  This could be classified as a Drush (performance) bug.

If you would like to help out here, you could submit an issue to the Drush issue queue.  Add DRUSH_BOOTSTRAP_DRUPAL_DATABASE to the variable commands, test it and post a patch, and the maintainers would be happy to commit it.

Here's what the record for variable-get would look like:

  $items['variable-get'] = array(
    'description' => 'Get a list of some or all site variables and values.',
    'arguments' => array(
      'name' => 'A string to filter the variables by. Variables whose name contains the string will be listed.',
    ),
    'examples' => array(
      'drush vget' => 'List all variables and values.',
      'drush vget user' => 'List all variables containing the string "user".',
      'drush vget site_mail --exact' => 'Show the variable with the exact key "site_mail".',
    ),
    'options' => array(
      'format' => array(
        'description' => 'Format to output the object. Use "print_r" for print_r (default), "export" for var_export, and "json" for JSON.',
        'example-value' => 'export',
      ),
      'pipe' => 'A synonym for --format=export. Useful for pasting into code.',
      'exact' => 'Only get the one variable that exactly matches the specified name.',
    ),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_DATABASE,
    'aliases' => array('vget'),
  );


"Your command line PHP installation is too old"

I had a similar problem and I was able to specify what version of PHP Drush will use by adding the following to my .bash_profile file:

export DRUSH_PHP=/usr/local/php53/bin/php

That got mine working.  I had tried a more general approach where I specified PHP 5.3 for my command line generally, but this didn't work.  Specifically targeting Drush is what it took for me.


Theme CSS overrides my CSS. How do I fix this?

Copy html.tpl file from your core module and place it in your themes folder ,look at the head element of your template then copy the path(link) of your CSS file and place it (at the last)after the
themes CSS into the head tag.


The question sounds like coming from a Drupal 7 background :)

If I understand it correctly, you are looking for a way to execute some PHP logic before rendering the content. Just like what we were used to do in the *.tpl.php files.

However, PHPTemplate was removed and replaced by Twig for a reason. For truly separating business and presentation layers - on of the major reason.

This does not mean that you loose on to the control which you had with PHPTemplate files. This only means that you are now forced to follow the best standard practices ;-)

Ideally, in both Drupal 7 and 8 the template functions the rendering should be broken in two steps:

Business logic - The function which is responsible for initializing the data (to be returned to page). This could be a function which calls the theme() function, like the page callback of your hook_menu implementation where you pass the variables into it. These could also be the preprocess functions which could be used to add new and or change existing $variables to the theme element being called.
Presentation logic - These are nothing but the functions or template file responsible for printing the values that it gets from the Business layer into appropriate markup. In D7 we used *.tpl.php, whereas in D8 we use *.twig.

To deal with the issue at hand, you will need to the template_preprocess() function. The *.twig file is responsible to only print the variables, with minimum logical checks.


Display a field of a node that is referenced on another node via a relationship

In your view style template you can access the node reference value, load the related node and then do whatever you need with that. You don't need a relationship for this approach.


Most directories and files in a stock Drupal environment just need read/execute for the IIS user - this allows IIS/PHP to read and execute the .php, .inc, and other files. For your "files" directory - typically in sites/default/files - IIS will also need write permissions, so it can write uploaded files and create new files (for instance, ImageCache derivatives).

As for how to do this in Plesk, it will vary, but here's a guide that should get you pointed in the right direction (depending on your host, some of the user/group names may differ, but should be close):

http://knowledge.3essentials.com/web-hosting/article/478/Setting-file-folder-permissions-from-Plesk-control-panel-for-Windows.html


Get id of an organic group inside a view

Do you have a corresponding template file in your sub-theme?

Themes cannot have a preprocess function without a corresponding .tpl.php file

https://drupal.org/node/258089


How do modules end up in the profiles directory in distributions?

I found the problem.

I have two make files - drupal-org.make.yml & build-xq42_d7_sk.make.yml. I was including the following in the build-xq42_d7_sk.make.yml:

includes:
  - drupal-org.make.yml

Turns out this caused the problem. There's no need to include any reference to that file at all in the build-profile-name.make.yml file.

This is the first make file I've built and I created it by reading documentation and looking at existing make files for other projects. I saw this line in one of the make files I used as an example and assumed it was OK.

Now I know...!