Which permission should I use for a role to see a shortcut to Custom Block Library?

The permissions defined for the module are:

administer shortcuts:
  title: 'Administer shortcuts'
customize shortcut links:
  title: 'Edit current shortcut set'
  description: 'Editing the current shortcut set will affect other users if that set has been assigned to or selected by other users. Granting "Select any shortcut set" permission along with this permission will grant permission to edit any shortcut set.'
switch shortcut sets:
  title: 'Select any shortcut set'
  description: 'From all shortcut sets, select one to be own active set. Without this permission, an administrator selects shortcut sets for users.'
access shortcuts:
  title: 'Use shortcuts'

To see the shortcuts you need the permission Use shortcuts.
To see the shortcuts in the toolbar you need the permission Use the administration toolbar
To see the shortcut for the page /admin/structure/block/block-content you need the permission Administer blocks


How to not have an image in a facebook share

First of all try investigating URL you are sharing on Facebook Debugger:
https://developers.facebook.com/tools/debug/

If you are not providing og:image meta tag, Facebook will try to get the best matching one, I guess those AD images in your case.

Unfortunately there is no way you could not provide an image, you could try with empty og:image meta tag, but I don't think this would work.

It would be best if you provide an image anyway. Here are some hints:
https://developers.facebook.com/docs/sharing/webmasters#images


Some answers here including:

Theming individual CCK fields with templates and preprocess functions (credit: Stefan Lehmann)
Theming Individual CCK Fields
Theming CCK fields within a content type
Custom Formatters module


Collapsiblock module - can I have horizontal expanding tabs instead of vertical?

Search slideUp and slideDown in collapsiblock.jsand replace with animate, for example:

$(this.target).animate({width:'toggle'},slidespeed);

Useful post: Slide Elements in Different Directions


Overload permissions for specifics users

I came across a similar situation and I think my is solution either the Group module or the og module. I didn't try them yet but both seems promising. I'm about to try them now.


Can you Please Check this, Hope its help you. https://www.drupal.org/documentation/modules/contextual


Drupal 7, Ubercart, Product search by price range

There are two ways of doing it:
One is using views and 2 price exposed filters, one with  "value bigger than" and the other one with "value smaller than".
The other solution is using Search API ranges module.

The Search API "ranges" module provides widgets for Search API range queries. Currently includes:

jQuery UI min/max slider.

To use it, you will need to use Facet API, follow a tutorial here.
I hope this helps you


Display all terms from a specific vocabulary in my template

I wouldn't type anything in a file.

Instead, use the Views module and create a block view that lists all of the terms in that vocabulary, then display that block immediately after the main content on the specific page that you're talking about.


How to show a specific date format in an English view?

In views, click on your date field and select Custom as your Date format.

Then see the PHP Date Manual, under Custom Date Format type your custom date accordingly.

For Example:


How do I add another field after saving entity metadata wrapper?

The problem can be with your field format. If your field other_field is a text field check what text format is set for it in admin/structure/types/manage/your_content_type/fields. EG:

If it is different from the plain text format you have to assign an array as a value to your field. EG:

$emw_node->other_field = array('value' => $id, 'format' => 'filtered_html');

or just

$emw_node->other_field = array('value' => $id);


Change CSS of grid view (Not just for a field) in Drupal 7

You can add classes to view
https://www.ostraining.com/blog/drupal/css-views/

Also see:
How to add CSS classes to a Views-generated block? (NOT to its generated content, the block itself!)


Get field (list type) label in a twig template

You can use

{{ content.field_categorie_avis[0]['#markup'] }}

to display label.

Dont miss the [0] because drupal always store items in array in case of field size limit change.


Update Webform and not Add if there is an existing value in one of the fields

this would be heavy on resources since it needs to search all 'submissions', searching for the user. An alternative idea:

use Rules to create a 'submission' at new user registration, setting the user as author.
use Node Limit to limit each user to one of that type
use Rules to check when trying to create a new 'submission' (url contains...) and redirect to the existing 'submission' page for that user


Cache-Control response header includes "private"

This is caused by symfony. private is added via vendor/symfony/http-foundation/ResponseHeaderBag.php and as far as I understand it's not possible to not have it when system.performance:cache.page.max_age is set to 0:

protected function computeCacheControlValue() {
  // ...
  if (!isset($this->cacheControl['s-maxage'])) {
    return $header.', private';
  }

Since I don't want to hack symfony, I can remove private via apache mod_header:

Header edit Cache-Control "(, )?private" ""


node permission based on a cck user reference field

Install the User Reference Access module - it directly addresses this requirement:

  This module works with CCK userreference fields and the node_access
  module to add additional grants to nodes.

  To enable userref_access on a node, edit the userreference field for
  the node type and check the "Use User Reference Access" box.

  Any users that are referenced by this field will be given view
  permissions for the node, all other useres will be denied access to
  the node.


I would start with a standard date field and then create a new field formatter that displays the date in the way you describe.

Before you dig in I would look around for someone that has already done this, it seems like a pretty common use case for working with a date.


Pass value of a field to another content type in Drupal 7

I think it would make sense if your 'exhibit' content type references sections, which are themselves nodes (through nid reference fields) or through a reference field on the section that points back to the exhibit.  Then you can build the view with relationships to look however you want.

The point of having everything be a node is that you can take advantage of a lot of built-in functionality, as well as a lot of contrib modules which are geared towards nodes.

So if you create the structure as I mentioned above, you can add sections to exhibits with this module: Node Reference URL, which allows you to automatically fill in the nid reference field.

Does that work?


Drush command to switch to a multi-site child directory?

drush status produces a Site Path in its output which is what you're looking for. With some additional shell commands, you can parse this out.

MYPATH=/srv/www/drupal
MYDOMAIN=example.com

SITE_PATH=$(drush status --root=$MYPATH --uri=$MYDOMAIN | grep 'Site path' | cut -d':' -f2 | xargs)
cd "$MYPATH/$SITE_PATH"


View is duplicating content added by entity reference

I assume that you have a view, that shows content of type Project.
In project you have a nested reference to a Resource.
Basically you are asking views to show you all the Projects, and related to them Resources, so for every Resource that you are adding, views is showing you projects that are related to new Resource, but, since you have only one node of type Project - views showing you Project for every Resource that you added, so you have what was implied to happen.

If you want to have list of Resources on a Project page - I would suggest you to create small view blocks, using node id of a resource as a context filter to the view,  (So in this case view would be showing you list of the Resources to the given Project on each project page.)
For that you need to create another entity_reference field on a content type of Project and filter it through the view that you created.

If this is what you were looking for. It was hard to understand you tbh


I had 'Debug info' turned on in my coumpas.app. Disabling this made it work.


Can I display Media Videos in a single "media player" block

You could create a View that makes a Block, and set it to display videos that meet whichever criteria. Or, you can just embed videos directly in a block with embed code. You can try the Video module or Video Embed Field to show videos from another source or from your side.


Grouping or adding classes to CCK form fields

You can use fieldgroup on the node edit form as well. Look just below "add existing field" and you will see "add new group"


Same secondary menu bar on different pages and lead to different content

If you are just using hashes to flip between hidden divs on the page, then the submenu needs to just be relative to the current location like | sales | and your main menu would just have the paths to the nodes like | PRODUCT A |

This might seem like a pointless answer, but if my assumption about you using the hashes to switch the tabs, then the solution is super simple. You just need to create the submenu in code in the template since the admin-based custom menu system won't let you do relative hashes (I don't think so anyway)


How to add Follow Me link inside content type in Drupal 7

You should try the Flag module for this. It should solve your purpose.

  Flag is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, users, and any other type of entity. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content.


how to automatically create other entities when creating an entity

If you were looking for a code solution, you can use hook_entity_insert() to trigger the creation of the other entities.

Your custom module code would look something like this:

function mymodule_entity_insert($entity, $type) {
  if ($type == 'typeA') {
    // entity type A is being inserted
    global $user;

    // now create type B
    $entity_b = entity_create('type_b', array(
          'uid' => $user->uid,
          'type' => 'type_b', //bundle
          'field_my_field_c' => array(
            LANGUAGE_NONE => array(
              0 => array(
                'value' => 'foo!',
              ),
            ),
          ),
        ))->save();

    // now create type C
    $entity_c = entity_create('type_c', array(
          'uid' => $user->uid,
          'type' => 'type_c', //bundle
          'field_my_field_c' => array(
            LANGUAGE_NONE => array(
              0 => array(
                'value' => 'foo!',
              ),
            ),
          ),
        ))->save();

    // now create type D, etc...
    }
}

I've borrowed from the code sample posted in the comment from Mołot and for simplicity sake, I made the author of A to be the same as B, C and D.

One more thing, the entity_create() function is in the contrib module Entity API. Your custom module would have a dependency on Entity API.


Form Redirect not working if 'destination' is in URL

When a form is processed, the value of $form_state['redirect'] is sent to drupal_goto(), and drupal_goto() always favors $_GET['destination'] over its own $path parameter.

For the sake of completeness, in Drupal 6, you were somewhat out of luck without setting your own headers in hook_exit():

function mymodule_exit($destination = NULL) {
  $my_destination = 'foo/bar';
  header('Location: ' . url($my_destination));
  exit;
}

In Drupal 7, hook_drupal_goto_alter() was added for this specific use case:

function mymodule_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  $path = 'foo/bar';
}

Another option for Drupal 7, which is closer to what you want to do, is to reset the static cache for drupal_get_destination()  in your submit handler using drupal_static_reset():

function mymodule_form_submit($form, &$form_state) {
  // See note
  $form_state['redirect'][] = drupal_get_destination();
  $form_state['redirect'][] = 'foo/bar';

  unset($_GET['destination']);
  drupal_static_reset('drupal_get_destination');
  drupal_get_destination();
}

Since you call drupal_get_destination() immediately after the reset, Drupal is blissfully unaware of the destination parameter for the rest of the page build, including when it calls drupal_goto().

Note: I changed the code for defining $form_state['redirect'] because you never want to overwrite the variable: other submit handlers might've defined their own redirects. Drupal will always use the last item in the array, so if you want foo/bar to override the destination parameter (and every other redirect defined up to that point), it needs to be last.


How to create user with role(s) through REST service?

After many trials, I was able to resolve my issue

Here is the JSON format to create user with role.

{
   "name":"user343",
   "pass":"kes35@r4",
   "mail":"user343@sample.com",
   "status":"1",
   "roles":[
      "4"
   ]
}

To assign multiple roles,

{
   "name":"user344",
   "pass":"kes344@r4",
   "mail":"user344@sample.com",
   "status":"1",
   "roles":[
      "3",
      "4"
   ]
}

I hope this helps someone.


There a setting for Webform per form. This setting is located "Content > Webforms(tab) > Edit(your form) > Webform(tab) > Form settings". You can add the confirmation message or redirect to a Custom URL.


Enable Clean URL + get Pathauto module, which allows to define custom URL patterns for every type of content

If the Clean URL test fails, the web-server is not configured to support this feature. You need to configure the web-server to support Clean URL.

With Apache HTTPD as web-server, you have to enable mod_rewrite and configure the necessary rewrite rules. The rewrite rules can be found in the .htaccess file that comes with Drupal. Usually, theses rules are applied automatically, when mod_rewrite is enabled, but in some cases, the AllowOverride directive is too restrictive to allow this.

See Clean URLs in the Drupal Installation Guide for a more thorough introduction on how to get Clean URLs working in Drupal.


You need to use Entity Reference module to connect two different content types content. Add a field Entity Reference in one content type and reference it to another content type.

To auto update another content type content, you need to use hook_node_insert and hook_node_update on first content type, and get referenced nid and update second content type content using node_save.


How to display one of the fields once in drupal views?

Select settings in Format field,and select the title under Group field selectlist.


How to specify granularity for the Access log Timestamp field to display access log entries using Views?

Maybe the Views Date Format SQL module is what you're looking for. Here are some details (from its project page):

The Views Date Format SQL module allows to format date fields using SQL. This enables group aggregation for date fields using the choosen granularity.
The core functionality is to remove the date formatting from render() and put it in query(). I.e. format date values using SQL's DATE_FORMAT rather than PHP's format_date. This is achieved by assigning a new default handler to node 'created' and 'changed' date fields. This handler extends and overrides views's build in views_handler_field_date.
The UI is completely unobtrusive, only a single checkbox "Use SQL to format dates" is added to the handler configuration popup.

As an illustration, and/or to better understand the challenge here, you may want to look at Graph node input over time (support date formatting on a continuous axis) also. Comment #3 of that issue states: 'The trouble here is that neither Views nor Date modules provide aggregation options for date-based fields.'.


Deleting translate interface strings programmatically or using drush

Drupal 7 store translate interface strings in :

Table source locales_source
Table Target locales_target


Is jQuery .once() needed if we filter by context?

The short answer, is 'yes'.
The longer answer is that if all developers properly used the API, you would likely not have to use $.once(). However, you cannot count on developers using the API correctly, so $.once() insulates you against that.

This is because the context passed to Drupal.behaviors is the part of the DOM passed by developers when calling Drupal.attachBehaviors(). However, a lot of the documentation on the web has not specifically stated this, resulting in many developers not passing any value to Drupal.attachBehaviors(). If no value is passed, then the entire DOM becomes the context. This means that your code could be passed through your handler multiple times. This is why $.once() is used.


Create a view block for display of taxonomy term children

yes,you can do this by :
on CONTEXTUAL FILTERS add "Taxonomy term: Parent term" and on once you've chosen it, there's a set of radio buttons entitled When the filter value is NOT available. Set this to provide a default value and then, in this case, choose "Taxonomy term id from url" from the drop-down menu.you are good to go.


What files will Drupal poll for hooks by default?

An include file will be scanned if the hook is within a group. For example, the rules module defines a group called 'rules' and so Drupal will scan the file foo.rules.inc for implementations of rules hooks.

The hook where groups are defined is hook_hook_info.
See: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_hook_info/7

Also, look at the function module_implements that finds modules implementing a hook: https://api.drupal.org/api/drupal/includes!module.inc/function/module_implements/7


How to apply theme_menu_tree to only the top  menu

In order to theme the top level ul tag only:

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

You have to put this piece of code in your custom theme's template.php file and replace THEMENAME with your theme's name.


How to create a combination chart with the Charts module if some X-axis values are missing?

Step 1

Not sure if it's your "only" problem to get your chart right, but part of your problem is, pretty sure, that you have "holes" in your data, similar to what is detailed in Comment nr 12 of Issue nr 2052429.

About the problem

To understand what that issue about "hole" is all about, consider these data to be charted:

Note that for the Types Article and for Webform, there is no row with Published = No (that is, there are no unpublished nodes for these types). So in this scenario we have 2 so called "holes" ... And that's were the trouble start:

Problem 1: a column chart for these data looks like so:

The bar for "Article" (with value 1) is wrong, that bar is actually related to the value 1 for unpublished "Book pages". And the bar for "Book page" (with value 2) should actually be the bar for the 2 unpublished "Basic pages".
Problem 2: a line chart for these data looks like so:

In this case, the line for "unpublished" suffers similar problems. So it doesn't matter what type of chart you're creating, all charts have this issue.

How to solve this problem

Upgrade to the most recent Dev version to start with (which is much better / stable then the current rc1 version). Then apply the patch attached to the issue comment mentioned above, and check if that helps in your case. If it doesn't, know that it is a prereq for sure (without that patch you won't be able to get it to work). Attention: the patch doesn't seem to apply anymore to the most recent dev version. To make it work (again), do not use the above mentioned patch, but instead use the re-rolled patch attached to in Comment nr 31 of Issue nr 2052429.

Here is how the same column chart from above looks like after applying this correction:

And this is its corresponding line chart:

... Which I believe is the chart that exactly matches the tabular data shown above.

Step 2

If upgrading to the most recent dev version and applying the patch is not sufficient, then I'd recommend you to (temporarily) disable that Views Merge Rows module you have enabled. And (temporarily) modify your view to show the values for PASSED and FAILED as 2 separated columns. And then verify if you get the correct results. That way we can verify if this Views Merge Rows module is the culprit (solve support requests is like taking away all possible causes, 1 at a time ...).

Step 3

If step 2 doesn't help either, then I recommend what's written in the "Bonus tip" of Steps to create charts using the views UI, i.e.:

  You may find it easier to start with a "Table" display and convert it to a chart display after setting up the data. It can be easier to visualize what the result of the chart will be if it's been laid out in a table first.

In other words: before trying to create a chart, make sure the tabular version of it has the correct data displayed.

Step 4

If none of the previous steps helps, then you may want to check the result you get by correcting your view like so:

Create another display in the same view, let's say you name it "Runs Chart (Total)". It should be equal to all the specs of "Runs Chart (Passed)", but without the filter "Content: Test Case Run Status (Passed)". Obviously, it'll reflect the total Runs (both passed and failed). I'd make it a "line chart" (but that's a matter of personal preferences).
Adapt the "Chart settings" of "Runs Chart (Passed)" to have it use  "Runs Chart (Total)" as the parent chart.
Adapt the "Chart settings" of "Runs Chart (Failed)" to have it use  "Runs Chart (Total)" as the parent chart (instead of "Runs Chart (Passed)").

Step 5

If the work around in step 4 helps as a work around, you may want to further refine the chart settings of "Runs Chart (Total)", by using a color for the line chart that matches the background of your chart (like white?). Possibly something similar for any of it settings like "Legend" (like set it to &nbsp;?

Disclosure: I'm a co-maintainer of the Charts module (+ author of its community documentation),
I hope this does not violate the site's policy on self-promotion.


How to programmatically read the display name of a CCK field from the allowed list?

You can use the following code.

$field = content_fields($field_name);
$function = $field['module'] . '_allowed_values';
$values = array_values(function_exists($function) ? $function($field) : (array) content_allowed_values($field));

This code is similar to the code used by optionwidgets_options(); the difference is that optionwidgets_options() returns also the value for the empty choice.

The output of content_allowed_values($field) is an array that in your case is the following one.

array(
  'US' => 'United States',
  'UK' => 'United Kingdom',
);

As you are only interested to the options visible in the user interface, I passed the result of content_allowed_values($field) to array_values().


How to hide terms with no nodes in "Simple Hierarchical Select" in views?

There is no simple way to do that without writing custom module to eliminate the terms you wanted. That said, you can write hook_form_alter to achieve this.

/**
 * Implements hook_form_alter
 *
 **/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form['#id'] == 'YOUREXPOSEDFORMID') {
    foreach ($form['field_tags_tid']['#options'] as $tid => $term_name) {
      if (is_numeric($tid)) {
        $result_count = db_select('taxonomy_index', 'ti')
        ->fields('ti')
        ->condition('ti.tid', $tid, '=')
        ->execute()
        ->rowCount();

        // Removing the option for tags with no-content
        if (!$result_count) {
          unset($form['field_tags_tid']['#options'][$tid]);
        }
      }
    }
  }
}

NOTE: Here, I assumed field_tags_tid as the field name, should be replaced with the appropriate field name.


Does anyone know if I can only add these two lines of code to setting instead of downloading every single bootstrap file?

No, you can't do that. That's a setting from, I would guess, the Bootstrap theme itself. It allows you to choose which version of the framework to use for that theme. The Zen theme would have no reason to add Bootstrap, so no reason to use those settings.

Continuing to use Zen as a theme/sub-theme, and replacing its framework with Bootstrap, doesn't sound like a great idea. You'll have problems/headaches upgrading, and plenty of Zen-isms to remove/re-implement to get it to play nicely with the new framework.

Given that all of that work, and more, has already been done for you, setting up a new theme based on Bootstrap is worth re-considering IMO.


Simply go to /admin/structure/block and add the block to a region.

In configure block, under Visibility, click on pages tab and type path with wildcard /taxonomy/term/*.

Therefore, this block will only be visible in your taxonomy page view.


Allow content builder to 'disable' a content type form

I think you'll have to do this with code.  My quick take on this would be:

Create a content type with an "Disallow jobs" check box and the body field.
Allow the technician role to view and edit this content type.
Create a node and add it to your menu with a "Disable/Enable jobs" link.

Use hook_form_alter() to:

check for the job content type form
load your Disable / Enable jobs node
Check if the disable jobs checkbox is ticked.
Replace the $form array with a markup entry using the text from the node.

Note if you need to have this turned off automatically (e.g. lab closed), you probably can use rules to modify the disable jobs node.


Include OR Group With Exposed Filters in View

I think you can achieve it by adding new filter group from views UI.

Edit:
If your case is more special then you can achieve it using hook_views_query_alter.

if (!$new_feed) {
  $query->where[0]['conditions'][1]['field'] = 'node.nid';
  $query->where[0]['conditions'][1]['value'] = array();
  $query->where[0]['conditions'][1]['operator'] = 'IN (' 3, 4 5')';
}
else {
  $query->where[2]['conditions'][1]['field'] = 'node.nid';
  $query->where[2]['conditions'][1]['value'] = array();
  $query->where[2]['conditions'][1]['operator'] = 'IN (1, 2, 3);
}

You can unset where condition as per your use case.


How to use different mail interfaces (Mail System)?

For D7 you can define a custom mail system using the $conf['mail_system']

$conf['mail_system'] = array('mycustom_module_thekey' => 'MyCustomEmailSystem');

Then you can use the drupal_mail function

drupal_mail('mycustom_module', 'thekey', $email, language_default(), $params, $from);


Drupal core only keeps a record of countries, not all the states/administrative areas within each country.

However the CommerceGuys addressing library has that functionality. Example from their readme:

use CommerceGuys\Addressing\Subdivision\SubdivisionRepository;

$subdivisionRepository = new SubdivisionRepository();

// Get the subdivisions for Brazil.
$states = $subdivisionRepository->getAll(['BR']);
foreach ($states as $state) {
    $municipalities = $state->getChildren();
}

If need to get list of states as indexed array use the function 'getList()':

$states = $subdivisionRepository->getList(['BR']);

Then if you print the $states, you will get:

Array
(
    [AC] => Acre
    [AL] => Alagoas
    [AP] => AmapÃ¡
    [AM] => Amazonas
    [BA] => Bahia
    [CE] => CearÃ¡
    [DF] => Distrito Federal
    [ES] => EspÃrito Santo
    [GO] => GoiÃ¡s
    [MA] => MaranhÃ£o
    [MT] => Mato Grosso
    [MS] => Mato Grosso do Sul
    [MG] => Minas Gerais
    [PA] => ParÃ¡
    [PB] => ParaÃba
    [PR] => ParanÃ¡
    [PE] => Pernambuco
    [PI] => PiauÃ
    [RJ] => Rio de Janeiro
    [RN] => Rio Grande do Norte
    [RS] => Rio Grande do Sul
    [RO] => RondÃ´nia
    [RR] => Roraima
    [SC] => Santa Catarina
    [SP] => SÃ£o Paulo
    [SE] => Sergipe
    [TO] => Tocantins
)


Should scripts/*.sh files be executable?

No. You don't need to execute permissions on those scripts in a production server environment.
The only reason you'd need those scripts executable on a server is for running code testing utilities (e.g. simpletest test cases, generating dummy content, etc.) on the codebase. Unless you're wanting to run some of those testing utilities on a CI server, they don't need to be executable for Drupal to work.


Disabling language prefix for route in module

Yes, has to be redirect.module, core doesn't do that. See https://www.drupal.org/node/2854462#comment-12047347, just add the '_disable_route_normalizer' flag to your route and you should be fine.

module_sitemap.routing.yml:

module_sitemap.sitemap:
  path: '/sitemap.xml'
  defaults:
    _controller: '\Drupal\module_sitemap\Controller\SitemapController::view'
    _title: 'View Site Map'
    _disable_route_normalizer: 'TRUE'


how to implement Ajax callback on form_alter for entity field?

Posting my own answer, I will be happy if it helps someone.

function custom_form_alter(&$form, &$form_state, $form_id) {

  if ($form_id == "article_node_form"){
    $form['field_select']['und']['#ajax'] = array(
      'callback' => 'field_select_ajax_callback',
      'wrapper' => 'field-image',
    );

//Note: this $form_state is set only after ajax function call (field_select_ajax_callback)
    if(isset($form_state['values']['field_select']['und'][0]['target_id'])) {
      $node_id = $form_state['values']['field_select']['und'][0]['target_id'];
      $image_path = get_image($node_id);
      $form['field_image']['und'] = array(
        '#markup' => '
 ' .$image_path. '
',
      );
    }
    $form['field_image']['und']['#prefix'] = '
';
    $form['field_image']['und']['#suffix'] = '
';
    return $form;
  }
}

function field_select_ajax_callback($form, $form_state) {
  return $form['field_image']; // very important step, Where I did it differently from previous.
}

function get_image($id) {
  $node_id = node_load($id);

  if(is_object($node_id)) {
    $image_uri = $node_id->field_image['und'][0]['uri'];
    $image_url = file_create_url($image_uri);
    $image = '';
  }
  return $image;
}

Yay fixed it.


How to call field label & values in custom content type page template

For the objective of adding classes to fields in a node (as you made clear in your comment) you can use hook_node_view to intercept the node and then you can change the markup of your fields.
You can find detailed examples here.


how to dynamically set query parameter on menu item

The way I would do this would be overriding the menu link.

You can override a menu link by doing a theme override of theme_menu_link() however you don't want to modify the structure of the markup you want to modify the data being printed (in this case the link query string) so I would recommend overriding the variables of that function in hook_preprocess_HOOK() (in this case hook_preprocess_menu_link()).

Template variable overriding is often done in the theme, and you can do it in your theme's template.php file, however in your case I would recommend a custom module because this is functionality not visual display. If you put it in your theme's template.php and then change themes it will stop working, which is probably not what you want.

So it would be best in a custom module.

If you look back at the docs for theme_menu_link() you can see that the link is created using the l() function and looking at the parameters to the l() function you see that the $options parameter can contain "Additional $options elements used by the url() function", which you can see from the url() docs includes the query string, which is a non-encoded array of key/value pairs.

So from that you can tell that in your theme function preprocessor you need to modify/add your query string in $element['#localized_options']['query'] something like this:

$variables['element']['#localized_options']['query']['campaign'] = 'google';

You can also see that the URL of the link is in $element['#href']. Since you probably want to affect all links that point to that path I would suggest overriding the link options based on path.

Since you can access the current page's query parameters using basic PHP's superglobal $_GET you then have all the information you need to set your menu item.

You can do it like this:

/**
 * Variable preprocessor for the themeing of menu links.
 *
 * @see theme_menu_link().
 */
function MODULENAME_preprocess_menu_link(&$variables) {
  // If we have an ebook campaign code then add it to the ebook register
  // menu link.
  if ($variables['element']['#href'] == 'ebook-register.php' && !empty($_GET['campaign'])) {
    // Just add our query array element instead of setting query to a new
    // array to avoid possibly overwriting other query parameters.
    $variables['element']['#localized_options']['query']['campaign'] = $_GET['campaign'];
  }
}

One other thing worth nothing is that generally in Drupal you shouldn't have pages as custom PHP scripts like ebook-register.php.

Instead you should have a custom module that implements hook_menu() to make the path 'ebook-register' call a custom callback that then contains your page logic. See the drupal menu system docs for more information (D6 & D7 have the same menu system) and also the examples module's menu & page examples.


Should I use both caches pane and panels?

If you panel already in cache, it doesn't matter that you panes are in cache, because cache of panel are alredy include panes.

But if you panel cache have lifetime around 1 hour and some panes have lifetime around 1 day (but not all) it can be usefull and take more performance to you.

So, cache of panels and panes for the same time doesn't take more effect then cache for panels only.


Conditional fields on content type with paragraphs

Yes you will have to hook form alter.
Make sure that you have done the following to make sure it's working.
1- create a module say it's called deals
2- add the deals_form_alter(...add the default params here ) In the deals.module file.
3- clear the cache
4- add your edit form is in an if condition then right the following logic. (You can get the form is by dumping the $form['#id'].
5- use the states functionality or Ajax callback to hide and show the fields you want.

https://www.drupal.org/docs/8/api/form-api/conditional-form-fields
And https://www.drupal.org/docs/8/api/javascript-api/ajax-forms


Double check and confirm that the theme files are exactly were they should be.
Make sure the /files directory exists and writable (NOT 777 permissions though)
Double check and confirm that Drupal can access the files directory via configurations
Clear the Drupal cache

If the theme is using external CSS or JavaScript files, make sure they are accessible. (most cases its an internet connection especially for front-end  frameworks like Bootstrap)


Drupal 7 - Destroying the session when the browser closes is not working on Chrome

This is not a problem with drupal session. The feature that remembers the opened tabs when the browser is closed is the root of your problem. The feature is named "On startup"  "Continue where I left off". Turn that off and you should be fine.


Render an HTML element before the menu with hook preprocess menu

In this case you should edit the template. Changes to markup should be done in templates.

  Ok thank you. I will extend the twig file. But just to know. How do I add it within my preprocess function?

Looking into the standard menu.html.twig there isn't any place left to preprocess content to have it prefixed with some markup for example. There are just menu items that must be of type URL and attributes.

So your best bet probably is to add the markup to the block instead (in case you print your menu in a block).

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_preprocess_block__footermenu(&$variables) {
  $variables['content']['#prefix'] = 'This is my menu';
}


How to add tracking scripts from external sites?

You can add the JavaScript on the theme level. You added on template.php or any other template that you wish to appear the javascript.

An example is a little bit tricky because is all depend on how the theme is was created. But I can provide an example base on my theme.

I'm using a sub-theme base on Boostrap so on my page.tpl.php I would add the JS on the bottom. So your goal would be to find the footer region and add the JS below that.

<?php

?>
<header id="navbar" role="banner" class="<?php print $navbar_classes; ?>">

      <?php if ($logo): ?>
      <a class="logo navbar-btn pull-left" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
        <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />

      <?php endif; ?>

      <?php if (!empty($site_name)): ?>
      <a class="name navbar-brand" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>"><?php print $site_name; ?>
      <?php endif; ?>

      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        Toggle navigation

      </button>

    <?php if (!empty($primary_nav) || !empty($secondary_nav) || !empty($page['navigation'])): ?>

          <?php if (!empty($primary_nav)): ?>
            <?php print render($primary_nav); ?>
          <?php endif; ?>
          <?php if (!empty($secondary_nav)): ?>
            <?php print render($secondary_nav); ?>
          <?php endif; ?>
          <?php if (!empty($page['navigation'])): ?>
            <?php print render($page['navigation']); ?>
          <?php endif; ?>

    <?php endif; ?>

<?php if ($page['Featured']): ?>

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

<?php endif; ?>

    <?php if (!empty($site_slogan)): ?>

<?php print $site_slogan; ?>

    <?php endif; ?>

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

    <?php if (!empty($page['sidebar_first'])): ?>

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

    <?php endif; ?>

    <section<?php print $content_column_class; ?>>
      <?php if (!empty($page['highlighted'])): ?>

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

      <?php endif; ?>
      <?php if (!empty($breadcrumb)): print $breadcrumb; endif;?>

      <?php print render($title_prefix); ?>
      <?php if (!empty($title)): ?>

<?php print $title; ?>

      <?php endif; ?>
      <?php print render($title_suffix); ?>
      <?php print $messages; ?>
      <?php if (!empty($tabs)): ?>
        <?php print render($tabs); ?>
      <?php endif; ?>
      <?php if (!empty($page['help'])): ?>
        <?php print render($page['help']); ?>
      <?php endif; ?>
      <?php if (!empty($action_links)): ?>

<?php print render($action_links); ?>

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

    <?php if (!empty($page['sidebar_second'])): ?>

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

    <?php endif; ?>

  <?php print render($page['footer']); ?>
    /**
        Load Custom JS
    **/


Services Views not exposing thumbnail image url

It's a bit unclear what you have in your view, but here are some suggestions:

Make sure you have Formatter set to "Image URL", and the "Image Style" set to the specific style (ie thumbnail)
Ensure that you actually have some data for your filter. "No Results Behavior" may have "Hide if empty", which would omit this field in your response if it's not set.
Enable showing the query and results for the view to at least check that the return data contains the value that you expect (admin/structure/views/settings -> [] show performance statistics)
Check that your contextual filter is not obfuscating something - remove the args[0]=1
Ensure that the normal Page response for the view displays a value for the thumbnail field, by going to the "path" that you've defined for the view.


Programmatically added block doesn't appear in block admin page

The problem was me creating a document block above the class, creating an interference between the class and annotation. Another lesson learned the hard way.


How to print taxonomy term field in node.html.twig?

To get the field value from a field in a taxonomy term that is referenced in the node:

{{ node.field_example.entity.field_desired_field.value }}

If you want to render a formatted output, use either the ui to configure a custom view mode or use the module Twig Tweak:

{% set tid = node.field_example.target_id %}
{% if tid %}
  {{ drupal_field('field_desired_field', 'taxonomy_term', tid) }}
{% endif %}


Why isn't my programmaticlly created field showing up to be added to a content type

You also need field instance to add that field to a content type.

  field_create_instance() : Creates an instance of a field, binding it
  to a bundle.

  // Create field.
  $field_name = 'field_rsvp';
  if (!field_info_field($field_name)) {
    $field = array(
      "field_name" => $field_name,
      'cardinality' => 1,
      'entity_type' => 'node',
      'type' => 'list_boolean',
      'description' => 'Enable RSVP for this event?',
      'label' => 'Enable RSVP',
      'widget' => array(
        'type' => 'options_onoff',
      ),
      'settings' => array(
        'allowed_values' => array(
          '0' => 'No',
          '1' => 'Yes',
        ),
      ),
    );
    field_create_field($field);

    // Create the instance.
    $instance = array(
      'field_name' => $field_name,
      'entity_type' => 'node',
      'bundle' => 'article',
      'label' => 'Enable RSVP',
      'description' => 'Enable RSVP for this event?',
      'required' => TRUE,
    );

    field_create_instance($instance);
  }

If you created a new field say for article content type, then you can see that field for other content types in the Add existing field field as mentioned in the comment by tenken


User relationship module - error strict warning: Only variables should be passed by reference

IMHO, this is a bug in the User Relationships module, and should be reported to that module's issue queue.

If you look at the documentation, you see that the template  for drupal_render is:

drupal_render(&$elements)

Passing a function call by reference not good coding practice (but it will not have adverse effects if you never use the return value passed by reference).

The following will do the same thing and not produce the warning:

$_shift1 = array_shift($elements);
$_shift2 = array_shift($elements);
$_shift3 = array_shift($elements);
$rows[$rtid] = array(
  drupal_render($_shift1),
  drupal_render($_shift2),
  drupal_render($_shift3),
);

The module author probably doesn't have PHP-warnings enabled, and never saw the warning.


file_field_widget_form error when programatically creating nodes

Looks like this is actually a problem in Drupal itself. In modules/file/file.field.inc the function field_form_get_state has a line like this near the bottom (just before the return statement):

$elements['#file_upload_description'] = theme('file_upload_help', array('description' => '', 'upload_validators' => $elements[0]['#upload_validators']));

The issue is a small if condition a few lines back which looks like this:

if (($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta < $field['cardinality']) && empty($form_state['programmed'])) {
    $elements[$delta] = $element;
    ...
    some more stuff
}

Since I am submitting the form programmatically with drupal_form_submit(), it adds in $form_state['programmed']; thus, the control statement's condition fails, and $elements[0] does not exist.


how to set the source connection in drupal d2d migrate

The migrate module provides basic migrate functionality while the migrate_d2d module extends on that functionality providing interfaces for reading and importing into Drupal 5, 6 and 7. Migrate comes with Drush integration and supports rolling back migrations which is very handy during development.

Add the following code into your settings.php file or you can specify database connection details within your migration scripts:

<?php
// Our Drupal 7 database configuration.
$databases = array (
'default' =>
  array (
    'default' =>
    array (
      'database' => 'db_drupal7',
      'username' => 'drupal7_user',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  // Here we add in the connection to our Drupal 6 database.
  'legacy' =>;
  array (
    'default' =>;
    array (
      'database' => 'db_drupal6',
      'username' => 'drupal6_user',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

If you want to create the script for migrating the content than please have look at this useful tutorials:

http://devblog.com.au/migrating-drupal-6-to-drupal-7-with-the-migration-framework
https://drupal.org/node/1813498

Personal suggestion:
Now the migrate_d2d module is providing a stable UI for migration the contents and that is very easy to do as well, have a look at it documentation here: https://drupal.org/node/1813498

Also if you have a larger database than you can use the drush commands to migrate the contents after setting up the database connections, the list of drush commands for migrating the content: https://drupal.org/node/1561820


Possible to make image styles (thumbnails) public while original images are kept private in D7?

What about creating 2 fields ? One for storing the thumbnail and let it "public". The other one for storing the original image, mark it as "private" and define a permission for it using field permissions module ?

Edit Oct, 26: let's add some code :)
So if your confortable with creating a module, here are the instructions.
Create 2 fields: field_img_public and field_img_private, one will be on the public filesystem, the other on the private.

Then create a module to store this hook_node_presave():

function MYMODULE_node_presave($node) {
  //Retrieve the file object from the public image.
  $fid_items = field_get_items('node', $node, 'field_img_public');
  $fid = $fid_items[0]['fid'];
  $img_public = file_load($fid);

  //Create the private path.
  $img_private_path = str_replace('public://', 'private://', $img_public->uri);
  $private_dir = pathinfo($img_private_path,  PATHINFO_DIRNAME);

  //Verify if the private folder exists.
  file_prepare_directory($private_dir, FILE_CREATE_DIRECTORY);

  //Copy the image
  $img_private = file_copy($img_public, $img_private_path, FILE_EXISTS_RENAME);

  //Save the resulting file object.
  $node->field_img_private['und'][0] = (array)$img_private;
}

Then you just upload the public image and the private get populated.


Reference View in Entity Reference field

Views are config entities so you can target them to be referenced (see screenshots) and check this post.

The caveat is you can only point to a given entity type when using ER fields so you cannot have an ER field targeting content and config alike.

On the other hand almost any market solution referencing views aim to render it not just displaying a link pointing the view.

As you suggest using a link field can work around with your use case but the link form element only autocompletes content entities, you cannot type your views' display title and wait for it to get the proper URL for you. For that I'm afraid you need to provide your own widget/form element (and controller). Check this and this about how to build your own autocomplete widget/form element for a text field and this post from Drupal.org docs on how to build your own field formatter.

Also worth noticing that Views URL's are used on limited display types (Page, Feeds, possibly 2 more but I'm not quite sure) and is considered a route, not a path or link like when building a menu link item.

Hope this points you in the right direction.


I had same problem, and I solved it after reading this article:

Source : https://www.drupal.org/node/2844755

you can do it step by step :

Change the default language to English.
Delete the other language.
Clear the cache.
Change the site name.
Add the other language and set it back to default.

It works after adding new language again


How to add padding/margin for sidebar-right in Adaptive Theme?

What Geoff said is basically true, but there is a way to change the margins and the paddings without messing up your basic page layout.

The way to do it is the following:

Take a look at the structure of the HTML in the sidebar region. There should be a div that has a class .region-sidebar-second or .region-sidebar-first. If you try to change the padding/margin of this div, your structure will be messed up.
You can, however, change the margin and padding of the div with the region-inner class by using a selector like ".region-sidebar-first .region-inner" or ".region-sidebar-second .region-inner".
You can even go deeper if you want to change the margin/padding of a specific block and not the whole region's by using something like ".region-sidebar-second #blockID" as your css selector.


How can I filter the apachesolr_autocomplete results on a custom search block

This seems to be the D.O issue for this:

https://www.drupal.org/node/1444038 (enables per-search-page support for autocomplete)

along with this...

https://www.drupal.org/node/326375 (enables having a search form block per each page)


How do I insert HTML just before the body closing tag?

The equivalent of hook_footer() that was used in Drupal 6 is to implement hook_page_build(), and alter the content of $page['page_bottom'], using code similar to the following one:

function mymodule_page_build(&$page) {
  $page['page_bottom']['devel'] = array(
    '#weight' => 25,
    '#markup' => '
' . devel_query_table() . '
',
  );
}

The content of $page['page_bottom'] is output from html.tpl.php, using the following code:

  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>

The value of $page_bottom is initialized from template_process_html() using the following code:

  // Render page_top and page_bottom into top level variables.
  $variables['page_top'] = drupal_render($variables['page']['page_top']);
  $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
  // Place the rendered HTML for the page body into a top level variable.
  $variables['page'] = $variables['page']['#children'];
  $variables['page_bottom'] .= drupal_get_js('footer');

The difference between hook_page_alter() and hook_page_build() is that hook_page_alter() is executed after hook_page_build() and should be used to alter, or remove content added by another module, while hook_page_build() should be used to add new content to the page.


How to embed a view (with contextual filters) into a node or another view?

Using panels module you can create a "pane view" for your view and easily pass any argument as view contextual filter .

here is a tutorial about views content panes


Module-heavy site quits without error on W7 dev machine

Okay. I do not understand why but it seems the answer here actually is the answer in the other question. Here's what you do:

In Apache's httpd.conf find the line

# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf

And un-comment it so the httpd-mpm.conf file is run. Then load up that file and go to the bottom where you'll see this:

# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum  number of requests a server process serves
<IfModule mpm_winnt_module>
    ThreadStackSize      8388608
    ThreadsPerChild      150
    MaxRequestsPerChild    0
</IfModule>

Not including the ThreadStackSize - add that line with the nice big number. And the crash stops. Essentially I was right in my diagnosis - the data structure being built is too big but it's too big for the thread, not the overall memory allocation.

The reason I'm confused is that, as far as I can see, that module is not loaded and run in Apache, but maybe it's not configurable and always runs.

Anyway this works.


You'll have to use custom GD methods I think.

Have a look at this module : https://drupal.org/project/imagecache_actions

With the embed "Custom Actions" module you'll be able to use any gd method you want.

Add a custom filter to an image filter, and find the gd function to use.

In example, to get a B&W picture, the php code to use is :

return imagefilter($image->resource, IMG_FILTER_GRAYSCALE);


How do I point to a particular installation of simplesamlphp with the simplesamlphp_auth module?

You can just create a symlink to your temporary SAML folder

ln -s /foo/bar/simplesamlphp ./simplesaml

In settings.php add next line:

$settings['simplesamlphp_dir'] = '/foo/bar/simplesamlphp';

In config.php file in your /simplesamlphp/config library add following settings:

// Load necessary environmental data
$ps = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
$host = $_SERVER['HTTP_HOST'];
$db = $ps['databases']['default']['default'];

// Define basic variables
$config = array (
   'baseurlpath' => 'https://'. $host .':443/simplesaml/', // SAML should always connect via 443
   'certdir' => 'cert/',
   'loggingdir' => '/files/private/log/',
   'datadir' => 'data/',
   'tempdir' => '/tmp/simplesaml',
   'store.type' => 'sql',
   'store.sql.dsn' => 'mysql:host='. $db['host'] .';port='. $db['port'] .';dbname='. $db['database'],
   'store.sql.username' => $db['username'],
   'store.sql.password' => $db['password'],
);

Now if you open your-site.com/simplesaml url in the browser, /foo/bar/simplesamlphp library will be used instead of vendor folder.


How to hide a user profile based on custom field?

This way is absolutely okay.
There is definitely the possibility to achieve the same result with the preprocess hook, but doing it in the template file is also a common "drupalish" way and has (as far as i know) no disadvantages.

One thing:
Do you have already existing users? if so you should check if the variable exists before comparing it with a value... otherwise you could get a php-warning.


How to set up Authcache module with Varnish and ESI?

When using this file I had to scroll down to line 142 and change this:

  if (req.restarts == 0 && server.identity !~ "^/tmp/vtc.") {
    unset req.http.X-Authcache-Do-ESI;
    unset req.http.X-Authcache-Get-Key;
    unset req.http.X-Authcache-Key-CID;
    unset req.http.X-Authcache-Key;
  }

into this:

  if (req.restarts == 0 && server.identity !~ "^/tmp/vtc.") {
    unset req.http.X-Authcache-Do-ESI;
    unset req.http.X-Authcache-Get-Key;
    unset req.http.X-Authcache-Key-CID;
    unset req.http.X-Authcache-Key;
  }

  set req.http.X-Authcache = 1; // Added by me
  set req.http.X-Authcache-Do-ESI = 1; // Added by me

I'm not sure why those headers are not added but instead removed in the default version, since the module seems to require them to be present in the first incoming request. However, given the nature of those headers, they seem to make more sense when returned from the backend to Varnish than the opposite. znerol might have a good answer for you (and for me) why they are required in the first request.

I also wanna say thank you znerol for this amazing module and for the ongoing documentation work.


What is your recommended Banner/Slider module for D7?

I have used Views Slideshow a couple of times and it was quite easy to use. It's based on the jQuery Cycle Plugin. The port to D7 is in alpha, so you might want to give it a go and contribute back to help the module reach a stable state.

That said, a module is not strictly necessary to do things like this. It's surprisingly easy to implement the (well documented) jQuery Cycle Plugin yourself, directly from your theme. Just add the plugin and write about 10 lines of jQuery in a custom .js file.


Have you tried Menu Icons? It is useful.
If you want to add some custom image to every term, add the field into your entity and upload default image. But I think, this module works better.


Acsessing field data for a views template

Use the Theme: Information in the Advanced part of the view configuration (you need to click the Advanced link to expand it).

Here you can explore all the possible templates for that specific view and specific display. But additionally you can click the specific template and see the default code (in your case you will use Row template I guess). There you can see the available variables.

To print out the specific values, I would recommend Devel module and then the kpr() or dpm() functions, like this: dpm($fields); in your template.

Alternatively, you can use debug($fields); without using the Devel module.

Important: Do not forget to delete these debug functions before deployment.


Revision tab is not listing any revision

A core issue related to languages was just fixed today: NodeController::revisionOverview() shows no revisions if node has no translation for current language

However, since you use diff, which replaces that patch and does its own thing, it might be the same or a similar bug there. Create an issue, possibly reference to the core issue.


Links displaying as plain text, and html tags not applying, no matter which text format is selected

It's hard to suggest a solution without examples, but I'd suggest you check the order of your text format filters (/admin/config/content/formats/full_html) and see if:

Convert URLs into links is still turned on
There are no additional filters acting on links or <a> tags that would cause them to be killed or hidden
Make sure your links look like links! Obscure ones like bit.ly/4321 or even google.com won't get picked up. If they aren't getting picked up, adding http:// to the front of it normally triggers the auto URL filter.

If that doesn't work, see if you can post some example code. If we can see how they are being hidden, we might be able to assist better.


Unable to view Taxonomy term page: Access denied

Check out the Access Denied Backtrace module.


These operations should be running automatically so there's nothing for you to do; this is clearly a bug.  Let's continue the discussion in the bug report at Aegir migration did not update database.  Hopefully we can track down the problem over there.


The error is generated by the following code in the module

  if (file_munge_filename($sanitized_url, 'css less') != $sanitized_url) {
    echo drupal_json_encode(array(
      'result' => 'failure',
      'filename' => $href,
      'msg' => 'The url used contains a sub-filextension which poses a security threat. Saving not allowed.'
    ));

This checks passes the sanitized url through the file_munge_filename function. The function checks for all the extensions in the file adds an underscore after the extension to make it secure. you can read the link for more information.

So I presume that there is some issue with the css file you are uploading. there might be more than 1 extension in the file name such as style.abc.css.


How to override single function of theme's template.php using sub-theme?

It really depends on the type of function:

If it's a theme function (theme_username()) you could simply re-declare the function with your sub-themes name (SUBTHEME_username()).
If it's a preprocess function, you can have your own version of the preprocess in your sub-theme, but IIRC the parent theme preprocess will still be invoked.
If it's a your own function (not a standard HOOK based function), then you would have to put some of your own logic to allow other themes to overwrite it.

Maybe provide some more information on the function in question so that someone can give you a more specific answer.


How do I include a class in a link inserted in an entitiy's link area?

You can add the html attributes using the attributes key which accepts an array of attributes, and add classes using the class key, which also accepts an array of classes.

/**
 * Implements hook_entity_view_alter().
 */
function mymodule_entity_view_alter(&$build) {
  // Set up ctools etc. to use modal omitted for brevity.
  $build['links']['popup']['#links']['mylink'] = array(
    'title' => 'show popup',
    'href' => 'mymodule/nojs/modals',
    'html' => TRUE,
    'attributes' => array(
      'class' => array(
        'ctools-use-modal',
        'ctools-modal-mymodule-style',
      ),
    ),
  );
}

More information about available keys, refer to theme_links() function in Drupal API.


How to switch language on login based on user profile?

In "Configuration -> Regional and language -> Languages -> Detection and Selection" enable detection method "User -> Follow the user's language preference." and drag it to the top of the list. Do same in both sections: User interface & Content language detection.

UPDATE:
As an alternative to GUI method you can add the code pasted below in your theme's template.php file (but first, disable detection of user language in Language settings).

The code below uses hook_user_login which runs when the user successfully logs in and passes the user object as an argument. User language is then used for a redirect (drupal_goto).

function yourthemename_user_login(&$edit, $account)
    {
      // get current user's language from the user account
      $user_language = $account->language;

      // if account has no preferred language set - do nothing
      if (!$user_language) {
          return;
      }
      // if the language is set - do additional checks and then redirect
      else {
        // get a list of installed languages
        $languages = language_list();
        // check if language retrieved from user account exists
        if (!isset($languages[$user_language])) {
            return;
        }
        else {
          // verify if language is enabled
          if (!$languages[$user_language]->enabled) {
              return;
          }
          else {
            // if enabled - redirect to user profile in preferred language
            $user_profile_url = drupal_get_path_alias('user/' . $account->uid);
            drupal_goto($user_profile_url, array(
                'language' => $languages[$user_language],
            ));
          }
        }
      }
    }


Create a custom module and alter the fields value using hook_form_alter()

<?php

function pahcom_form_edit_module_form_alter(&$form, &$form_state, $form_id) {
    if($form_id =='formid) {
        $new_value = rand(100000,10000000);
        $form['submitted']['vendor_id']['#default_value']=$new_value;
        //$form['submitted']['vendor_id']['<h</h4>default_value']=$new_value;
    }
}

?>


How to create a product display view showing all users who purchased a product through a specific display

Your view needs to have this relationship setup, with multiple relationships added so you can relate your entities in this way.

Product Display > Product > Order > User

I should be able to provide a stronger answer if you can provide a little more detail, but have struggled with a similar view I had to create about 2 years ago and remember it taking a few days for me to resolve :)

Good luck!


How to add more fields after submission?

You need to add a submit handler to the button that updates some specific variable in $form_state so you can determine the "step" of the form.
Plus, a $form_state['rebuild'] = TRUE; to rebuild the form.

Assuming you are using Drupal 7, a hook_menu or hook_block_view (or any other function) is calling drupal_get_form function with "my_form" as argument.

function my_form(&$form, &$form_state) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
  );
  $form['city'] = array(
    '#type' => 'select',
    '#title' => t('City'),
    '#options' => array(
      1 => t('Kandy'), 2 => t('Anuradhapura'),
    ),
  );
  if (isset($form_state['next_step']) && $form_state['next_step']) {
    $form['gender'] = array(
      '#type' => 'select',
      '#title' => t('Gender'),
      '#options' => array(
        'm' => t('Male'), 'f' => t('Female'),
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Find'),
  );
  return $form;
}

function my_form_submit($form, &$form_state) {
  $form_state['next_step'] = TRUE; // You can also change this to FALSE in validate function to prevent the gender from appearing.
  $form_state['rebuild'] = TRUE; // Don't forget this!

  // Do other stuff here.
}

Note how I conditionally added the gender form element, and how the submit handler sets that value.

When the form is loaded for the first time (with empty $form_state), the condition to add the gender element will be FALSE, so no element added.
Then, the form submit handler adds the values so in the next form rebuild, element gets included.
Tricky part is the $form_state['rebuild'] = TRUE; part.

Good luck!


I've added FILTER CRITERIA: my_field (NOT NULL)... it was so simple...


You can add page--front.tpl.php in your enabled theme folder and clear the cache


Rooby is right, this views happen because of the server not providing enough memory limit to run it and that happens, so I solve it when I asked the server guy to add more memory limit to the site and all good, thank you!


What is the relationship between hook_cron() and hook_cron_queue_info()?

The relationship is they are 2 independent hooks that can be used in conjunction with one another depending on what the task is.

hook_cron(): Provides a means to supply a custom function to respond to a cron event.
hook_cron_queue_info(): Provide a means to supply queue metadata for a cron event that will need a queue (i.e. any task that can't be fully processed in the limited time during a cron event).

In your example above:

Yes revision_scheduler_cron is adding to the queue.
But no, revision_scheduler_cron_queue_info is not processing the queue, it's providing the function (revision_scheduler_operation_process) to call for processing and how long (revision_scheduler_cron_time) it should be allowed to execute for processing.


How do I redirect the "No Result" search page to Add node?

I was really hoping that _preprocess_search_results(&$vars) would work, but it only gets called when there are results, so, here are two really really I can't believe I am suggesting these but they should work ways:

Drupal 6:

In your theme's template.php file, you can retheme box, which is how drupal 6 creates the 'no results found' info:

function YOURTHEMENAME_box($title, $content, $region = 'main') {

  if ($title==t('Your search yielded no results')) {
    drupal_goto('node/add');
  } else {
    $output = '
'. $title .'

'. $content .'
';
    return $output;
  }
}

If Drupal 7:

Copy search-results.tpl.php from the search module's directory to your theme directory and change it:

<?php if ($search_results): ?>

<?php print t('Search results');?>

  <ol class="search-results <?php print $module; ?>-results">
    <?php print $search_results; ?>

  <?php print $pager; ?>
<?php else: ?>
  <?php drupal_goto('node/add'); ?>
<?php endif; ?>


Setting menu weight for "Edit" and "View" items in a node

I believe you can do this with hook_menu_alter().

Another option would be to leave the edit at 0 and change the weights of the items you can adjust to work around the edit.


How do I get the Commerce order type programmatically?

The order type is the bundle so you can use EntityInterface::bundle() to get that info:

$type = $entity->bundle();


How to attach a date field from another entity to a new form

Unsurprisingly, it was my error.

Further up in my function I was building $form_state with form_state_defaults().  Once I provided a proper form_state everything worked as expected.


How to pass custom variables into drush site-install?

You can add any additional settings you wish to pass to the profile in the following format (the key is in the form [form name].[parameter name]):

drush site-install my_profile install_configure_form.site_default_country=FR my_profile_form.my_settings.key=value
drush site-install my_profile install_configure_form.date_default_timezone="Europe/London" update_notifications.update_status_module=1
drush site-install my_profile variables.file_public_path="sites/default/files" variables.file_private_path="sites/default/private/files"

Then you can handle the variables in your profile code by either implementing hook_install_tasks or hook_install_tasks_alter where you can access $install_state array which have information about the current installation state of your profile and your variables which can be accessed in $install_state['forms'].

In example (when set from drush via variables.X="Y"):

foreach ($install_state['forms']['variables'] as $name => $value) {
  variable_set($name, $value);
}

For file_public_path and file_private_path, it's not enough only to pass the variables, but you should prepare the directories as part of the installation script, e.g.:

file_prepare_directory($install_state['forms']['variables']['file_public_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($install_state['forms']['variables']['file_private_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($install_state['forms']['variables']['file_temporary_path'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
drupal_static_reset('file_get_stream_wrappers'); // clear static cache for stream wrappers

This was implemented in drush as part of Site Install: allow passing additional form parameters feature request.

Please note that above feature it's only supported on Drupal 7 and above.


Displaying another entity's form on a node

\Drupal::formBuilder()->getForm() already returns a render array, see the FormBuilder::getForm() documentation.
To render the form, you just need to pass the results of getForm() to your $build array, then render it in your template.
In hook_ENTITY_TYPE_view():
function MYMODULE_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  // ...
  $build['my_flagging_form'] = $form_obtained;
}

Then in your twig template:
{{ content.my_flagging_form }}

Or, if you're already rendering content in its entirety, you may not need to update your twig template at all.
As @4k4 noted in the comments, you can also add the appropriate meta data in hook_entity_extra_field_info to make your flagging form addition configurable (reorderable, etc) on your node's Manage Display screen. See Creating pseudo-fields in Drupal 8 for an example.


hook_breadcrumb() doesn't show breadcrumb

I finally figured out how to alter the breadcrumb. The function needed to return a string

  function MYFUNCTION_breadcrumb($variables) {
    // On récupère les items de la page s'ils existent
    if (drupal_is_front_page ()) {
      return '';
    }
    if ($item = menu_get_item ()) {
      $title = (isset ( $item ['title'] ) ? $item ['title'] : false);
      $last = '
';
      $separator = '' . $variables ['crumbs_separator'] . ' ';
      $first_crumb = '
Accueil' . $separator;
      $key = count ( $variables ['breadcrumb'] ) - 2;
      $final_temp = ($variables ['breadcrumb'] [$key]);
      $final_crumb = ((isset ( $title ) && $title != "") ? ('' . $title . '') : ($final_temp));
      if (isset ( $item ['page_arguments'] )) {
        foreach ( $item ['page_arguments'] as $argument ) {
          // Keeping the name of the taxonomy in $field_name
          if (isset ( $argument->field_article_type )) {
            $field_name = "field_article_type";
          } elseif (isset ( $argument->field_type_remontee_document )) {
            $field_name = "field_type_remontee_document";
          } elseif (isset ( $argument->field_lien_type )) {
            $field_name = "field_lien_type";
          } elseif (isset ( $argument->field_type_de_contenu )) {
            $field_name = "field_type_de_contenu";
          } else {
            $middle_crumb = "";
          }
          // retrieving the field and then the link to the taxoomy in the form term/taxonomy/%
          if (isset ( $field_name ) && $field = field_get_items ( 'node', $argument, $field_name )) {
            foreach ( $field as $taxonomy ) {
              $taxo = taxonomy_term_load ( $taxonomy ['tid'] );
              $nom_taxo = $taxo->name;
              foreach ( $taxo->field_taxo_list as $taxo_link ) {
                foreach ( $taxo_link as $link ) {
                  $lien_taxo = $link ['value'];
                  $lien_taxo = (substr ( $lien_taxo, 0, 1 ) == "/") ? substr ( $lien_taxo, 1 ) : $lien_taxo;
                  $middle_crumb = '' . $nom_taxo . '' . $separator;
                }
              }
            }
          }

          $crumbs = isset ( $final_crumb ) ? $first_crumb . $middle_crumb . $final_crumb . $last : '';
          // And here is returned a string
          return $crumbs;
        }
      }
    }
  }


Where is the the full tokens list for a site?

I see its one of those things that you once you know.

Enable modules:

Token
Help (core)

Navigate to the page: /admin/help/token.


Edit button on the top right menu disappeared, how can I get it back?

The issue was caused because of an unclosed div tag in multiple blocks on my site. If you have this issue check all related twig templates, blocks and content for unclosed HTML tags.


Lost access to permissions checkboxes at admin/config/group/permissions/node/

I think I found a corresponding bug: http://drupal.org/node/1649186


The good thing for you is this is completely doable within the Views UI alone. No PHP is needed here. A full explanation is too lengthy here (and asking for tutorials is off topic). If you're a novice to Drupal, watching some tutorials on Views would be a good time investment since it's a core part of Drupal now.

Here's some additional info to navigate you 90% there. See the image of the Views UI to yourself started with your page & block view:

If you have a view of full content nodes, Drupal, by default, wraps a node display in a div with an id of node-<NID>. (if you have a custom theme it might differ, but it should be pretty easy check that out). As such, a default Views page of full blog posts should already be linkable with a #node-nid anchor.

As for the block, Views allows you to have multiple displays based off the same query. When you create your view, you can also create a block. You'll just to make a few alterations to the block so that links are presented as anchor links for the page they'll appear on:

Add a Content: Nid field to the Block display, making sure to set For selectbox to This block (override) (i.e. only add it to the block display).
Tick the Exclude from Display checkbox so that the Nid field doesn't appear on the block.
Rearrange the Content: Nid field (via the down triangle next to the Fields Add button) so that appears first.
Click on Content: Title to reconfigure its display, you'll want to  untick Link this field to the original piece of content to remove the hyperlink to the blog and tick Output this field as a link under Rewrite Results, you'll be placing #node-[nid] in Link Path, which if you did all the above correctly, should rewrite the block links to an anchor link for each post display.

That should get you most of the way there. Views UI is pretty complex so it's going to take a bit of experimentation to understand it all. The above should navigate you mostly through it.


How to create wrapping menu tabs with CSS in Omega

It appears that the default system.menus.css in Drupal sets the white-space property to:

white-space: nowrap;

The default value for white-space is normal.  So, if you set the white-space property on your menu's UL to white-space:normal they will wrap when your screen size gets smaller.

I placed the following in my global.css.

ul.primary {white-space: normal; }


Drupal 8 upload and embed a video to WYSIWYG

For simple solution Just get video_embed_field which includes module  Video Embed WYSIWYG Enable both of them. You will get options to configure your WYSIWYG here admin/config/content/formats/manage/full_html. Just add the Video button in toolbar and checked the option Video Embed WYSIWYG. I hope you get what you want.
Thanks


What's the best way to spell-check a complete Drupal site?

I considered CheckDog but then hacked a quick perl script using curl & aspell:

#!perl

use constant SITEMAP => "http://www.example.com/sitemap.xml";
use constant MAX_PAGES => 10;

$npages = 0;
for (qx{curl --silent @{[SITEMAP]}}) {
  m{<loc>(.*?)</loc>} or next;
  $page = $1;
  ++$npages > MAX_PAGES and last;
  print "$page\t"; # here so if aspell crashes, we know which page
  $typos = qx{curl --silent $page | aspell --mode=html --home-dir=. --personal=dict.txt list};
  $typos =~ tr{\n}{ };
  print "$typos\n"
}

Add valid words to dict.txt, where the first line is:

personal_ws-1.1 en 500

As per @Berdir and @kiamlaluno suggestion, we'll also try TextReview. The following use cases would be of interest to us:

Differences: hopefully better than a module that displays raw html side by side
Spell check: showing misspellings in context will be wonderful!
Similarity percentage: maybe we can use this to warn on duplicate pages?
Manually configured blacklists and whitelists: eg to avoid UK spellings "customise" in favor of US spellings "customize"


building a query with the database api and groupby multiple fields in drupal 7

Turns out you you can 'stack' the groupby methods like so:

$query->groupBy('DATE(FROM_UNIXTIME(p.timestamp))')->groupBy('nid')->groupBy('hostname');

Which generates the following query string under the hood:

GROUP BY DATE(FROM_UNIXTIME(p.timestamp)), nid, hostname

resulting in the following drupal query for this question:

$query = db_select('pop_links_stats','p');
$query->fields('p', array('cid','nid','timestamp'));
$query->groupBy('DATE(FROM_UNIXTIME(p.timestamp))')->groupBy('nid')->groupBy('hostname');
$results = $query->execute()->fetchAll();


Yes if you're trying that in a theme then it won't work and will need to be done in a module (Obviously changing the "bare" to whatever your module name is)


how do I create multiple modules that both add to the output of a node?

If you're using $node->content['form'] for both modules, that would be why. Instead do $node->content['module1_form'] and $node->content['module2_form'].

This is because each function is getting passed the same node object and $node->content['form'] is being overwritten between the two modules.


Provide unique values from a user profile field in a content type field (How to use DISTINCT in ER View)?

Try using aggregation. Set this value in your View under Advanced > Use aggregation. The Group Results Together aggregation type should be the default and should provide the behavior you're looking for.

If this isn't quite what you're looking for, please export a copy of your view configuration, from Configuration > Development > Configuration synchonization > Export, then select Single and find your view under the Views dropdown and update your question with this export.


Rule to remove two specific items from commerce cart

You remove a product from the cart by deleting the line-item entity for that product.
But first you must expose the line-item data to your Rule so you can check whether it should be deleted. Line-item data including sku is not available to Rules Actions unless you do this.
Note that you can access some properties about the line-item, such as commerce-line-item:type, in your Rule Condition, but this is for the line-item referenced in the event, not for the other line-items in the cart. You cannot access other line-items' data, such as sku, in your Rule Action.
You force the other line items' sku and other data to become available to your Rule Actions by checking a property of each line item in the Action, even if you don't otherwise need to do the check. In this example I check the type of each line-item to be evaluated for deletion.
Much of the documentation available as of today is a couple of years old and calls for use of Rules components ... nowadays Rules Conditional is the way to go as it allows you to bring conditional logic right into your Action (so you can choose which line items to delete, for example). You may choose to put this Rule in a component if you have many varied situations in which you want to call it. If you only have one or two situations, using conditional logic within the Rule Action, via Rules Conditional, is much simpler.

In the example below, the Rule is evaluated on the event "After removing a product from the cart" because I have an add-on product that should be removed after the "mother" product is removed by the customer. But you can use any Commerce event.

The Condition here is to check whether the product removed from the cart by the customer was a "mother" product ... you may not need any conditions for your Rule.

The Action first does the aforementioned check of the line-item type to bring the line-item properties into scope for the Action data selector, then loops through the list of line-items, and tests each one for the skus you want to delete. Then deletes the line-item if there is a match. You could of course delete based on price, quantity, or anything else in the line-item data.

Note that once you start to loop through a list, the data you are after will be accessed through the variable list-item: which represents whatever you are looping through; in this case, the line-items. Note that list-item and line-item are syntactically very close, watch for typos!

{ "rules_delete_products_from_cart_by_sku" : {
    "LABEL" : "Delete Products from Cart by SKU",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce Cart" ],
    "REQUIRES" : [ "rules", "rules_conditional", "commerce_cart" ],
    "ON" : { "commerce_cart_product_remove" : [] },
    "IF" : [
      { "data_is" : {
          "data" : [ "commerce-line-item:type" ],
          "value" : "my_product_type"
          }
       }
     ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "CONDITIONAL" : [
                {
                  "IF" : { "data_is" : { "data" : [ "list-item:type" ], "value" : "product" } },
                  "DO" : [
                    { "CONDITIONAL" : [
                        {
                          "IF" : { "data_is" : {
                              "data" : [ "list-item:commerce-product:sku" ],
                              "op" : "IN",
                              "value" : { "value" : [ "SKU-01", "SKU-03" ] }
                            }
                          },
                          "DO" : [ { "entity_delete" : { "data" : [ "list-item" ] } } ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

Hope this helps someone on the same journey I am!


Yes, the Main page content block is where your content will render. Yes those visibility settings control on what page/content type/role will show that block content area. Typically, you want to leave this block alone since it's the main presentation of your content (what's the point of having a page if it doesn't have any content?).

It looks like the CorkedScrewer's default home page is more a demo template to demonstrate its block regions; you can't replace the images without overwriting the existing ones in its images folder.  It can vary based on the theme developer, but usually you can control a theme's slideshow images from its settings page in /admin/appearance.


Adding a non-link element to the end of the breadcrumb

You can do almost like in your suggestion. You just need to use '<none>' instead of 'nothing!'.

$b->addLink(Link::createFromRoute($this->t('Recipe'), '<none>'));


Commerce Products Display Page Using Views

You can use this module "https://www.drupal.org/project/commerce_auto_product_display". then you can use Views to show the product display nodes.


Use the unformatted style, instead of the table style. Then use CSS in your theme and you can style it any way you want. Should you want to change the html (I hardly ever need it), try rearranging the view or using the suggested templates.


file_save_data() will take the contents of a file and place into a location specified by a file URI. In your example, you can take your downloaded test.jpg, retrieve its contents, and have file_save_data() do the rest.

// Assuming same cwd where curl & fopen was executed.
$image_file = file_save_data(file_get_contents('test.jpg'), 'public://test.jpg', FILE_EXISTS_REPLACE);

// test.jpg will be placed/overwritten into your managed file system.
// $image_file contains the Drupal file object.


Possible to join different entity type on using EntityFieldQuery?

No.

An EntityFieldQuery allows you to run queries based on field and property conditions, but it has no way to query the fields or properties of a referenced entity.

Such a thing would involve some pretty full on logic, and it probably wouldn't even be possible to provide a programmatic interface to it that made sense.


different "no content" message based on taxonomy vocabulary/term

Drupal 7 has a default Taxonomy Views display you can use to override the default pages.  Here are the steps:

Install Views, if you haven't already.
Go to Structure -> Views and look for the Taxonomy term view.
In the little button that says "Enable", drop it down and select
"Clone", and create a new name for the view (it defaults to "Clone
of Taxonomy term").  This will make a copy of the Taxonomy view.
Edit the view, and drop down the Advanced tab.  Add a NO RESULTS
BEHAVIOR.
Select Global: Text area.
Enter the text you want to display for no results.

Let me know if you need help beyond this.


How to create views with date field of a content type?

You should be able to do something along these lines in a custom module if the out of the box Date and Views modules don't do it:

First off, create all your Views as Block Displays (eg, not Page Displays with a path defined by Views) with the various arguments in place.  For ease of discussion later on, let's say the View is called photo_gallery with displays of year, month and day.

Then, in your module, define the paths you want, eg:

function YOURMODULE_menu() {

  $items=array();

  $items['photo-gallery/%'] = array(
    'title' => 'Photos By Year',
    'page arguments' => array(1),
    'page callback' => 'YOURMODULE_photos_by_year',
    'access callback' => TRUE,
  );

  $items['photo-gallery/%/%'] = array(
    'title' => 'Photos By Year/Month',
    'page arguments' => array(1, 2),
    'page callback' => 'YOURMODULE_photos_by_year_month',
    'access callback' => TRUE,
  );

  $items['photo-gallery/%/%/%'] = array(
    'title' => 'Photos By Year/Month/Day',
    'page arguments' => array(1, 2, 3),
    'page callback' => 'YOURMODULE_photos_by_year_month_day',
    'access callback' => TRUE,
  );

  return $items;

}

And then for your callbacks, you embed the view you want using the argument styles it wants, which would probably be something like this:

function YOURMODULE_photos_by_year($year) {

  return views_embed_view('photo_gallery', 'year', $year); // eg 2014

}

function YOURMODULE_photos_by_year_month($year, $month) {

  return views_embed_view('photo_gallery', 'month', $year . '-' . $month); // eg 2014-01

}

function YOURMODULE_photos_by_year_month_day($year, $month, $day) {

  return views_embed_view('photo_gallery', 'day', $year . '-' . $month . '-' . $day); // eg 2014-01-04

}

Now the above is all pretty broad strokes typed in directly (typos may abound) and not actually tested (I don't really know the exact format of the dates your Views arguments should be in) but should get you on your way. Things to keep in mind are argument validation (eg photo-gallery/notayear/notamonth/notaday) and paging of results.


Use the following code for the load operation of existing forms

hook_form_alter(&$form, &$form_state, $form_id) {

  if(empty($form_state['post'])) {
    //do you load operation
  }

}


Add as a particular role while creating an account in Drupal 7?

Adding my comment as answer. If every user is a blogger then the easiest way I see is not to have it as a separate role at all; instead assign similar permissions to authenticated user.

Or you could change the role of the user by implementing hook_user_insert():

function MODULE_user_insert(&$edit, $account, $category) {
  $account->role = 'blogger';
  user_save($account, $edit = array(), $category = 'account');
}


How to output variables from a multi-value field into html on a node tpl overrride

What you can do is to overwrite the field template.

To do that go and copy the field.tpl.php from core and rename it to field--features-ticked.tpl.php, and put it in your theme.

Then you can remove all the useless div's and classes.

EDIT : How to output the list items individually.

Let's say you have the array $content['field_features_ticked'], you can do like this.

  <?php foreach($content['field_features_ticked'] as $item) ?>

<?php print $item; ?>

  <?php endforeach; ?>

This will create an unordered list, then loop through all the list items and print them out one by one.

NOTE: If you can't print out $item, you might do like this.

<?php print $item[LANGUAGE_NONE][0]['value']; ?>

Hope that is helps you out.


I want to override the template of the contact page

The contact page is a form, so you can theme it like any usual form:

Implement hook_theme in your theme to tell drupal you want to theme the form.
Create the template file

Example

/**
 * Implements hook_theme().
 */
function <your theme>_theme($existing, $type, $theme, $path) {
  return [
    '<your form id here>' => [
      'render element' => 'form',
    ],
    '<another form id, if you have multiple contact forms>' => [
      'render element' => 'form',
    ],
  ];
}

The form id depends on the machine name of your contact form. For example, if your contact form is named 'feedback', the form id will be

contact_message_feedback_form

Now drupal will by default look for the template file

contact-message-feedback-form.html.twig

Place the twig file in where Drupal can find it, i.e. under the templates folder in your theme.

At the minimum, what you need in that twig template file is

{{ form }}

But you can control what is printed by doing so:

  {{ form.mail }}

  {{ form.message }}

  {{ form.actions }}

{# Renders the rest of the form #}
{{ form|without('mail','message','actions') }}


How can I add an extra button & submit handler to an exposed view form?

The submit handler is not called by default on a form api element type "button". If you want to execute a submit handler on a button you will need to add

$form['my_button']['#executes_submit_callback'] = TRUE;

As a side note this will not be the case if the #type was 'submit' because the executes_submit_callback is by default equal to true on that element type.

Hope this helps.


how to implement facet search api on content types feilds?

Just follow the steps here and you will be done. https://beautiful7mind.wordpress.com/2013/03/10/step-by-step-how-to-implement-facet-search-on-data-in-drupal-7/


Create dependent dropdown in views exposed filter

I haven't check but

{
  $form['computer_stats']['os'] = array(
    '#title' => t('Operating system'),
    '#type' => 'select',
    '#options' => drupal_map_assoc(array('', t('OSX'), t('Linux'), t('Windows'))),
    '#ajax' => array(
      'callback' => 'input_os_verify_ajax_callback',
      'wrapper' => 'input_os_verify_wrapper',
     ),
  );

  // Setting an empty element with a wrapper to be populated.
  $form['computer_stats']['os_verify'] = array(
    '#type' => 'markup',
    '#prefix' => '
',
    '#suffix' => '
',
  );

  // When submitted, check for value of OS, and populate os_verify.
  if (isset($form_state['values']['os'])) { // Fixed this line, was throwing an error in the original video code.
    $form['computer_stats']['os_verify']['#type'] = 'checkbox';
    $form['computer_stats']['os_verify']['#title'] = t('Are you sure you are using @os?', array('@os' => $form_state['values']['os']));
  }

  ...
}

function input_os_verify_ajax_callback($form, $form_state) {
  return $form['computer_stats']['os_verify'];
}

from How to Build Beautiful Forms in Drupal 7 (Video Presentation) might help


I recommend you to do the following and I hope it will fix your issue

Clear drupal cache then check CKeditor field
If nothing changed then try to open your site on different browser
If nothing changed then try to look if you have any javascript errors when you edit any content/node/settings; use firefox with firebug add-on
If nothing changed then try to uninstall the module then install it again
Also try to disable javascript optimization under performance menu


It's important to understand that a 'hook' is literally a function that's named in a certain way.

If you have a function

function my_module_abc() { }

That is, by the nature of the hook system, my_module's implementation of hook_abc().

Whether hook_abc() was ever intended to be a hook is a completely different matter. The fact that the hook system works entirely on a naming convention means that it's inevitable. In fact it's working exactly as designed.

Hooks are very loose, they are not structured; they don't have meta data, beyond what the module author may choose to document in MODULE.api.php. The 'information' you're looking for doesn't exist, and until someone changes the way Drupal's hook system works, it can't and won't.


The source template file you are looking for should be called ds-1col.tpl.php. It is in the mentioned folder.

Copy the file to the templates folder within your theme.
Then rename the file to ds-1col--ds-views-account-wins-page.tpl.php
Make the adjustments you desire.
Flush your caches and you should see the changes.

Read more about views template files here which function really similarly.


How to populate field X with value of field Y in Organic Groups?

Here is a rule (in Rules export format) that should be close to what your question is about:

{ "rules_og_populate_fields" : {
    "LABEL" : "OG populate fields",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "og" ],
    "ON" : { "og_user_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_x" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_y" } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "node:field-y" ],
          "value" : "[node:title-x]"
        }
      }
    ]
  }
}

You didn't specify which Rules Event you want to use. In my sample, I used "User has become a group member" (adapt the event to fit your own needs).

Notice the "entity has field" conditions, for both fields. Those conditions will make the fields available in the Rules Action ... (so that you can reference field X and set the value of field Y).

If you have the Rules UI enabled, and if the machine names of your fields are indeed "field_x" (for field X) and "field_y" (for field Y), you should be able to just import this rule in your own site. If you're using other machine names, just adapt the machine names prior to importing this rule (and apply similar changes in the fields mentioned in the Rules Action).


In the end it was ideed as expected a convention: If you enable the commerce shipping module a system level weight field will be added automatically to the Product Variation Entity, not the product.
This weight field is the only field, used for order weight calculations and other custom fields are ignored. All in all very logical ;)
If you want to use the weight in templates, it can be done via {{ product.variation_weight }}


Add "Request new Password" link to user logIn page

This should be already there as a link.
if it is a custom login page, you can add a link with "/user/password" href


Can not unset rows of a view programmatically

It should work on template.php too. Module implementation does not look mandatory here.
I have noticed a few issues in the code sample that you have pasted.

There is a typo. It should be $view not $views.
Instead of

for($i = 0 ; $i < sizeof($view->result) ; $i++){
}

Do

$sizeof_result = sizeof($view->result);
for($i = 0 ; $i < $sizeof_result ; $i++)

The following code works for me:

function MYTHEME_views_pre_render(&$view){
  if($view->name == 'MY_VIEW'){
    $sizeof_result = sizeof($view->result);
    for($i = 0 ; $i < $sizeof_result ; $i++){
      //IF Condition
        unset($view->result[$i]);
    }
  }
}

The reason for using variable $sizeof_result instead of sizeof($view->result) in for loop is:

For each execution of the loop, the value of sizeof($view->result) changes(decreases by 1). Due to this, the for loops does not work as expected.


The structure of what you submit through the API should generally be the same as the structure of the data you submit through the ordinary node form as the resource methods for creating and updating nodes are simply thin wrappers around a form submit. Even the validation and most errors come from the form handlers.

So my suggestion is that you look at how the form submits stuff as that's where you will likely always find the answer.


Sounds to me like you have the 'Only listed pages' setting wrong.
I tend to use pathauto, so always have nice 'friendly' URL's, but I suspect you want "node/1" rather than simply "1" in the "only listed pages" field of the block config.

WRT your initial issue - are you using Delta? Regions may not be enabled for all delta's of the subtheme which could cause the initial problem.


You can set the translations for each specified language in the strings settings part of the internationalization module: /admin/config/regional/i18n_translation

To show it in a template file you simply use the t() function to wrap your text - which translates text for you and automatically adds new text defined in the t() function to the strings page.

See http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7

If you are hardcoding links with your text you can use l(), so if you have say a text link and want the text to be translated you would use l() and in it define your text using t() - something like this:  http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7

See http://api.drupal.org/api/drupal/includes--common.inc/function/l/7 for its usage.


Place two text fields within a single  class

Hope this will help you,

In Drupal 7 you can achieve it by using the #prefix and #suffix properties in hook_form_alter().

   /**
    * Implements hook_form_alter().
    */
    function hook_form_alter(&$form, &$form_state, $form_id) {
      switch ($form_id) {
        case 'user_login':
        case 'user_login_block':
          $form['name']['#prefix'] = '&#60;div class="username-password-wrapper"&#62;';
          $form['pass']['#suffix'] = '&#60;/div&#62;';
          break;
      }
    }