You are using the global variable $user which represents the logged-in user.

  An object representing the user currently visiting the site.

  Contains preferences and other account information for logged-in
  users. When a user is not logged-in, the $user->uid property is set to
  0.

You could use the user id from the URL on the user profile page by calling arg(1).
Here is the possible fix for your code:

<?php
 $uid = arg(1);

 $user_fields = user_load($uid);

 $customfield = $user_fields->field_navnn['und']['0']['value'];

 print  t("Custom field value is " . $customfield. ' ') ;
?>

I do not concern with your user profile template. This is just for your code fix.


Editing own content for content type giving me access denied

The "input format" on the body field might be set to one that you don't have access to, example  "Full HTML",  "PHP", etc.

Check that you (your role) has that access. Look here: "admin/settings/filters"

If you don't have access to the "input format" used on the body field then you can't edit that content.

I recently ran in to something close to this, I was surprised to find this as the solution. Hope this works for you.


How can I add classes to rows depending on the loop index?

And as it so often happens:
Just after fighting a pair of hours with this and then finally asking the question here, I found out the solution myself. I had to make the code in views-view-unformatted--latest-articles.html.twig (i.e. had to add the -unformatted to my question part).


date field missing when use date popup with date & time

Yep, I found it in $form_state['input'].

I am actually using this with Ajax. so In callback function you can get the form values from $form_state array. All form values are present in $form_state['values'] and input type values are also can be found in $form_state['input'].


share field template between node display and views

Might have to do this: CCK Formatters, hoping there may be an easier way. Here is a quote about CCK Formatters (from the module's project page):

This package is a collection of add-on formatters for various CCK fields. Each provided sub-module in this package should be a self-contained single formatter.
CCK fields support an arbitrary number of "formatters", swappable code that renders a field. In Drupal 6 these are essentially theme functions, although in Drupal 5 they are not always. It is possible for any module to define new formatters for field types it doesn't define itself, which creates a very powerful way to extend and theme a field in any of the myriad ways that a field can appear.
This module is an "incubator" for new field formatters. Because each formatter may have its own development cycle, there will probably not be stable releases of the entire suite. If a specific formatter gets particularly popular or requires a more full-featured release cycle, it should likely be spun off to its own project.


How to apply authentication to rest endpoint URL?

Since rest callbacks run through Drupal's normal roles/permissions layer, you can just disable the View published content permission for anonymous users, then they won't be able to fetch the JSON for the View.

If you need finer grained control, you'll have to use hook_node_grants().


How to execute custom code at Drupal startup

First of all, User module's user.private_tempstore and user.shared_tempstore services moved to core. So we want to use the tempstore.private.

The code below will get your started. you will want to read more about how getSubscribedEvents() works, as here is where you tweak the where and when of your event.

Don't forget an .info.yml file!

/mymodule/mymodule.services.yml

services:
  mymodule.mymodule_subscriber:
    class: Drupal\mymodule\MyModuleSubscriber
    arguments:
      - '@tempstore.private'
    tags:
      - { name: 'event_subscriber' }

/mymodule/src/MyModuleSubscriber.php

<?php

/**
 * @file
 * Contains \Drupal\mymodule\MyModuleSubscriber.
 */
namespace Drupal\mymodule;

use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\TempStore\PrivateTempStore;

/**
 * Provides a MyModuleSubscriber.
 */
class MyModuleSubscriber implements EventSubscriberInterface {

   /**
   * The PrivateTempStore Service
   *
   * @var PrivateTempStore
   */
   protected $privateTempStore;

   /**
   * MyModuleSubscriber constructor.
   *
   * @param PrivateTempStore $privateTempStore
   */
   public function __construct(PrivateTempStore $privateTempStore)
   {
     $this->privateTempStore = $privateTempStore;
   }

   /**
   * // only if KernelEvents::REQUEST !!!
   * @see Symfony\Component\HttpKernel\KernelEvents for details
   *
   * @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The Event to process.
   */
  public function MyModuleLoad(GetResponseEvent $event) {
    // @todo remove this debug code
    drupal_set_message('MyModule: subscribed');
    // Interact with the tempstore
    $value = $this->privateTempStore->doSomething();
  }

/**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('MyModuleLoad', 20); // Like hook_init (Cached)
    // Priority greater than 200 alow to skip caching, like functionality of hook_boot.
    //$events[KernelEvents::REQUEST][] = array('MyModuleLoad', 300); // Like hook_boot (not Cached)
    return $events;
  }
}


How can I get pathauto to generate language-inspecific rules?

This is currently not possible.

Pathauto always uses the language of the entity, just like the node edit form does.

This is a pretty common scenario and there are feature requests for it, for example: https://www.drupal.org/node/2775275.

There is also a related core issue, about allowing that for manual aliases as well: https://www.drupal.org/node/2689459.

What it needs now is someone to work on those. If you have a budget, you could offer a bounty for someone to work on it. The core issue has a needs review patch, so you could help to test that, that would also help if forward.

I'm considering to implement it in pathauto following the same rules as the core issue suggests, based on whether the path field is translatable or not. That shouldn't be too hard to implement, but it will also need tests.

Disclaimer: I am a (the) pathauto maintainer, you can also contact us (my company) to work on it.


How can i display a environment indicator notice on my dev and staging when browsing the site?

You can't output HTML (or text) directly from settings.php without throwing an error, since settings.php is interpreted during bootstrap.

Provided you have a clean install, on your staging site, have the following line in settings.php:

$conf['site_name'] = 'This is a staging site';

All assignments to the $conf array you do in settings.php will override whatever value you set the in the administrative GUI for the site.

An alternative solution, if you don't have a clean install and the site's name is no longer displayed by default, is to add your own conf variable to settings.php:

$conf['is_staging_p'] = TRUE;

and modify your theme to output some indicator if this predicate is TRUE;


I found the answer myself. Use $file->fid.


How to get value from {{ item.content }}

You are comparing an array with a number:

item.content > 5

Try the field value instead:

element['#items'][key].value > 5

Full code example:

{% for key, item in items %}
  {% if element['#items'][key].value  > 5 %}

{{ item.content }}

  {% endif %}
{% endfor %}


Drush and what version(s) of Drupal are supported per version of Drush are clearly explained here:

http://docs.drush.org/en/master/install/


Create 2 or more exposed filters for the same view

One way is that you can expose the fitler block by configuring (EXPOSED FORM option in views) the "Exposed form in block" to "Yes" for  as I have done below:

This way you will have the exposed filter available as a block at "/admin/structure/block".

Now as you want to create expose filter with 3 fields and 7 fields for the same view so than you do the following for that:

Create view of block type and add the required fields (if you want it to be of fields type).
Add the fields in "FILTER CRITERIA" section and this will be your expose filter fields. (Right now add the 3 fields).
Add another block for the same view, and now the view be same and you have all the fields available you have added in the previous block.
In the new block, add only new expose filter fields (just make sure you select "This page (Override)" while adding the fields for second block.

Hope this will work as you want.


How to create multiple blocks for blog teasers from a single view automatically

If I understand the question correctly - In views, create a new block for each instance of the block you want by clicking on +Add:

You could also create a completely new view, but this keeps things organized.

Where you put in the number of items to display, you can change the offset of the item:

In this way you can set the second block to have an offset of 1, the third 2, and so on. You can then create 4 blocks that each contain one of the most recent 4 items.


How to track down possible module conflict?

After much beating my head against the wall, I found a solution:

https://drupal.org/node/1593684

Turns out, it was SELinux snuffing out the SMTP attempt before it could even reach the server!  Doh!


Is Drupal internationalization development effort embracing the new "Entity Translation" method? Is it ready for use?

Let me start by stating that I am not on the i18n team, nor very involved in the development of Drupal. But I have been working with Drupal multilingual sites for over several years, where we switched to entity translation about 2 years ago. I have done the same search as you are doing now and these are my findings.

The article you've found already covers the main things, and entity translation in my opinion is more the Drupal way. The whole translation system already went into the D7 Fields API where a value is accessed like this:

$field[LANGUAGE_NONE][0]['value'];

Most examples will use 'und' (the value of the constant LANGUAGE_NONE) for the undefined index, but it can also contain a language code. Thus fields in D7 are already multilingual.

In my opinion the entity translation module uses this in a more effective way, where one piece of content, one node with one id is being linked to one field, which is used to serve content in several languages. Rather then having several nodes, each being in another language and linked to the others.

For us this solved problems when fetching certain nodes by id in an external system and finding out it had the wrong language etc.

I know entity translation is still in Beta, but over 2 years I never had an issue with it. Also note that at the bottom of the entity translation project page it states that it is in D8 Core now (although under the name of content translation). I've just tested this on a local machine and there is indeed one node for several languages, so it at least looks like entity translation is in place. Those things made me assume this is the Drupal way.

Hope this helps somewhat in making a decision.


Save boolean data types in serialized array

This would be much easier to do on the client side. Assuming val is your boolean value, you can just add a single line to handle this:

val = +val;

That will coerce your boolean to an integer (1 or 0). No need to check all of the json data on the server side.


You can disable the search block in "Structure -> Blocks" in the admin panel. On the same page you can create a new block and add some links to it. Then add the block to the side bar.


Can menuTree load a menu's items including children

Within the typical route context ($menu_tree->getCurrentRouteMenuTreeParameters($menu_name)), subtree elements are loaded only, if the menu item is flagged as "Show as expanded" within the menu item settings.

To load the entire tree, you have to pass in a plain MenuTreeParameters object without the current route context:

use Drupal\Core\Menu\MenuTreeParameters;

$parameters = new MenuTreeParameters();

// Optionally limit to enabled items.
$parameters->onlyEnabledLinks();

// Optionally set active trail.
$menu_active_trail = \Drupal::service('menu.active_trail')->getActiveTrailIds($menu_name);
$parameters->setActiveTrail($menu_active_trail);

// Load the tree.
$tree = \Drupal::menuTree()->load($menu_name, $parameters);


How can I add a Twig template to a programatically created custom content type?

Nodes

  Pattern: node--[type|nodeid]--[viewmode].html.twig

  Base template: node.html.twig (base location:
  core/modules/node/templates/node.html.twig)

  Theme hook suggestions are made based on these factors, listed from
  the most specific template to the least. Drupal will use the most
  specific template it finds:

  node--nodeid--viewmode.html.twig
  node--nodeid.html.twig
  node--type--viewmode.html.twig
  node--type.html.twig
  node--viewmode.html.twig
  node.html.twig

  Note that underscores in a content type's machine name are replaced by
  hyphens.

Source: Twig Template naming conventions

In your case this is number 3.

Example:

node--article--teaser.html.twig

If you want to place the template inside the module see: Template for custom content type

In your case this would look like this:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return [
    'node__my_content__teaser' => [
      'base hook' => 'node',
    ],
    'node__my_content__full' => [
      'base hook' => 'node',
    ],
  ];

In my experience you only need base hook. Drupal will discover the correct template name and path on its own. You have to be careful with the underscores (_) in the theme hook, they should match exactly the hyphens (-) of the template name.


Product image is not shown in View Mode Node:Product List

Could it be that your file folders are not setup correctly? Checkout drupal.org/node/15368 Also check your database log if there are any file related errors reported, more info at drupal.org/documentation/modules/dblog


Is there a recommended method to construct a form on a grid (2-dimensional array) with Form API?

If you need a table and put checkboxes on the left you could use http://heine.familiedeelstra.com/new-tableselect-form-element-in-core

Alternative you could theme your form. Therefore you have to write a theme_form_id which
drupal_render the elements and put them together with theme('table').

PS: This will perhaps land in drupal8: http://drupal.org/node/80855


Sounds like a job for Views Calc.

  This module adds simple calculations to a views table. Requires the
  Views module.

  You can SUM, AVERAGE, COUNT, MIN, MAX, or AVG selected columns. A plug
  in theme makes the view look more spreadsheet-like (right justifies
  numeric fields, shades calculated columns and rows, and underlines
  calculated rows).


How to use a set of global and per subsite permissions in a multisite installation?

For now I solved this by creating a seperate global role which stays in the default shared config. I added the editor role to the conditional (graylist) section (configured per subsite) using config_split. So that way I am able to have seperate permissions for that role.

That global role can be automatically assigned to a subsite user during a new subsite install via a bash script/drush command for example.


Can uploaded files be renamed in the server to avoid name collision?

You don't need to worry about the renaming of the images; Drupal does that for you by default :)
Lets say if you upload image1.jpg, and again someone else does the same the second file will be renamed image1_0.jpg.


Hook form alter not firing on a custom form that does exist

Before Drupal 8, the form ID is also the name of the PHP function that builds the form itself (or an ID contained in the array Drupal gets from a hook_forms() implementation).
As such, it can only contains those characters a PHP function name can contain. Underscores are allowed, but not so dashes; dashes are used in HTML. The correct form ID is the one with underscores.


You can use:

module_load_include('inc', 'node', 'node.pages');
$form = node_add('nodetype');
print drupal_render($form);


How to render the same field twice but with different name/id attribute?

The select element don't have #name atribute (Form API Reference). You can implement the hook_form_alter() in a custom module.

/**
  * Implements hook_form_alter().
 */
function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'YOUR_FORM_ID') {
    //here you can make the copy
    $form['field_add_option_copy'] = $form['field_add_option'];
  }
}

You can read this: Creating modules - a tutorial: Drupal 7.x


Did you accidentally enable random ordering as well? In a randomly ordered list, the second item will always be random as well.

If this is not the case, please provide more information about the configuration of your view. Two ways of doing this are to make a screen shot of the edit form, and to upload the exported view to http://pastebin.com.


View will not display taxonomy location information

It's not a great answer, but I do have an answer.

For some reason, Views isn't pulling this data. I've been unable to get a clean install of Drupal 7, views, location to pull this info when entered in the Location fieldgroup on a taxonomy term.

I HAVE been able to create a custom field for the location via 'manage fields', and THAT will appear in Views.

I hope that helps you (and anyone else looking at this!)


How State is specific to the specific environment, when its actually pushed to all environments with DB sync?

When you copy your development/testing database to your production
database, you're effectively replacing your production site's state
with your development site's state. Therefore if you put your
production site in maintenance mode, then import a database that says
the site is not in maintenance mode, then your site will stop being in
maintenance mode.
Conceptually, state is specific to an environment, so long as you
aren't copying your database when you push changes from development to
production.
Your solution may be to avoid doing these database imports altogether.
If you are just making configuration changes on your local development
site and just need to push those, you can export the site's
configuration to code, commit it to version control, push that config
to production and then import it. (See
https://www.drupal.org/docs/configuration-management for info.)
If you are creating content in the local development environment that
you need to push to production, then you may want to look at using the
Migrate API.
If you absolutely must push these database updates but want the
production site to remain in maintenance mode when you do it, then
you'll need to put your development site into maintenance mode before
copying its database to production.


Have a look at the Node Convert module.

Node Convert adds a menu tab "Convert" on the node view page, i.e. node/1/convert, which gives the ability of converting the node from its current node type to another node type. Also it gives the ability of transfering all the custom CCK field values of the current node type to the destination CCK fields, or discard them. As of 5.x-1.4 you can bulk convert many nodes of the same type, to another one that can be accesed in Administer → Content → Convert Nodes.
The module has been tested on converting node types with the following CCK fields:

Text
Number
Image
Node reference
User reference
Link
Date
Datestamp
Email
Audio
Video

Here is the documentation for the module: https://drupal.org/node/291564


I just tested installing panopoly distribution and a series of module needed to build same functionality on standard drupal profile installation

Here are my findings

The functionality you are asking does not seem to achieve with one contrib module instead its a result of lots of modules
Check this
link. This links lists the feature list or the main modules
list.
lets take panopoly_pages contrib module, this module
allows user to add content or landing page
but again this module
depends on several other modules to work in desired way
Here is
the link for complete list of all required modules.

My findings
Installing all required modules I found it almost become the complete panopoly profile,so in my views it will be better to use panopoly distribution instead of separately installing the modules

How you can add this to existing site ?

https://drupal.org/node/1717728

Check out more on panopoly here.


This is easily accomplished using the Rules module and setting up the "event" and "action" to behave the way you want it to behave.

I set it up so that "after saving a new user" I "added a user role" of the type that I wanted to have. That should do the trick.


There's a template hook for this: template_preprocess_block

Use $variables['classes_array'] to add classes to the block.


The flag service module (and probably the others you've listed in your comments) define their resources as actions, so you access them at a URL like:

http://server/[endpoint]/[module]/[action].json.

So for the flag action provided by the flag module that would be something like:

http://server/endpoint/flag/flag.json

This little snippet works well for me, based on a REST server with no authentication turned on and an endpoint with the path 'api':

$url = 'http://server-name/api/flag/flag.json';

$args = array(
  'flag_name' => 'bookmarks',
  'content_id' => 8,
  'action' => 'flag',
  'uid' => 1,

  // You wouldn't normally want this, the flag module provides it as an override
  // but it's a security risk. With proper authentication you can safely remove it.
  // I'm just using it for testing.
  'skip_permission_check' => 1
);

// Perform the curl
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$response = curl_exec($curl);

$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

curl_close($curl);

if ($http_code == 200) {
  // Success
}

Answering the original question (What is the proper format for the flag service calls?), it's simply a matter of calling the correct URL and POSTing the required arguments to it, from whatever programming language you might be using.


Do something conditinally on node.tpl.php depending on if the node is tagged with certain taxonomy vocabulary

Each taxonomy term in a node also gives you the vocabulary id that it belongs to.  So you could look through the terms to see if one matches the vocabulary id of your "Color" vocabulary and then display "It has color" when found.

An easy way to do this would be to use a loop:

<?php foreach ($node->taxonomy as $key => $term): ?>
  // Say the vocabulary id of "Color" is 10.
  <?php if ($term->vid == 10): ?>
    <div>
      <?php print views_embed_view('my-views', 'default', $args); ?>
    </div>
    // etc
    <?php break; ?>
  <?php endif; ?>
<?php endforeach; ?>

For reference, to access the vocabulary id of a single term:

$node->taxonomy[TERM_ID]->vid;

Where TERM_ID is the id of the taxonomy term.


To enable a module, you just need a line in core.extension.yml. However, you also need all the configuration the module provides. You could copy that over yourself from the config install and optional folder.

But the usual workflow is that at you enable the module manually at some point, using drush or the UI, then optionall customize the configuration and then export the config and deploy that.


how to fetch webform records from table by using drupal db_select

Just as it says, the error is in the line

$val = $submission->data[15][0];

so the variable $submission->data[15] does not contain a value [0]. Most likely the array is empty.

Of course, it's probably a bad idea to go to the database yourself, rather than using Webforms API functions. A little searching can get you started.


If I print some text within hook_init(), it is being printed only one time. This will not reduce the performance. Also hook_init() is called only once, from Drupal core.


It sounds like you want to load the user object from the email address, set some field values, and save it again.

In code that would look something like this:

if ( ($account = user_load_by_mail($customer_email) ) {
  $account->field_foo[LANGUAGE_NONE][0]['value'] = $event_json->foo;
  $account->field_bar[LANGUAGE_NONE][0]['value'] = $event_json->bar;

  user_save($account);
}


Passing arguments to a node with an alias url

Iv'e not tested with more than 8 args, but I enabled path_alias_xt when passing args to a node Alias with /mynode/term-name/tid and the 404s magically went away.

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

Further more using
print_r(arg(2));
in the node template prints "term-name"


Why are comments enabled on my content types in Simpletests?

module_disable(array('comment')); inside setup() does the trick.


Yes, there are 2 templates files that handle this in your theme:

maintenance-page.tpl.php: The theming template used for when your site is in maintenance mode.
maintenance-page--offline.tpl.php: The theming template used for when your site doesn't have database connectivity.

Read Theming the Drupal maintenance page on d.o for more information.


A possible solution that might help to simplify the challenge in your question, is the fairly new Math Field module (for D7). Some more details about this module (from its project page):

  The Math Field module defines a new field type to dynamically calculate values on entity forms. This is an alternative to Computed Field
  that does not require the use of PHP Filter.

  Math expression fields are dynamically updated via ajax on the entity form as soon as all necessary fields are populated. If JavaScript is disabled, the field will be evaluated when the form is submitted. The result is stored in the database when the form is submitted.

By creating some auxiliary field(s) (calculated via the Math field), you may be able to complete your puzzle via some additional logic implemented via the Rules module, to actually verify "18 Years or Older" (which I believe is the actual validation you want to implement).

For more details (step-by-step instructions), refer to either of these links:

the (amazing!) Community documentation about the Math Field module.
the interesting article about Introducing the Math Field module, which also includes some screenprints to see it at work (such as the the add/edit form example).


Why doesn't skip_on_empty work when migrating from a text field?

I now believe this to be caused by Get process plugin sets multiple for empty array.


Can blocks being exist and displayed without being stored in blocks table?

Homeblock is actually not storing the data in block, it is actually inserting the data in its own custom table, like homeblock_users.

  $data = new stdClass();
  $data->uid = $user->uid;
  $data->name = $page->name;
  $data->settings = $blocks;
  drupal_write_record('homebox_users', $data);

It is saving block data in hoemblock_users table. It is creating only one Block i.e. Homebox custom block.

homebox_prepare_block

Above is the function through which dynamic block is created for a page, and all the variables are assigned to it.


In a recent project I needed content editors to insert a special div wherever they needed that would float right and have custom styling.

The best solution I came up with was a custom ckeditor plugin. Basically editors just click on the appropriate icon and the necessary html is inserted into the editor. All they have to do is add the content.

Example:

Create a folder inside ckeditors plugin dir and name it
"doublecolumn".
Create a plugin.js file inside that dir.
Add an icon to use for the button inside that dir i.e. "myimage.png.

Then, add the following code in plugin.js:

(function ($) {
CKEDITOR.plugins.add( 'doublecolumn',
{
    init: function( editor )
    {
        editor.addCommand( 'insertDoubleColumn',
            {
                exec : function( editor )
                {
                    editor.insertHtml('

');
                }
            });
        editor.ui.addButton( 'doublecolumn',
        {
            label: 'Double Columns',
            command: 'insertDoubleColumn',
            icon: this.path + 'myimage.png'
        } );
    }
} );
})(jQuery);

I haven't actually tested this but it's similar to what I had used and it should work.

You could also expand the html for each column to something like:

Add Title

add image

add text

In your case it might be better to put the two columns inside a wrapper div - just to be safe.

Don't forget to enable the plugin and add it to your toolbar from admin/config/content/ckeditor.

Hope this helps.


Forena Reports, does not appear in the Drupal menu Structure

This is, pretty sure, a permission issue. So go check if the user has the relevant permissions granted. If not that's why the link is not shown either.
Some more debugging hints:

just enter relative URL /reports and see what happens next (it may be available, even though the menu item is still missing for some reason).
temporary logon with user/1 (to bypass any potential permission issues).

BTW, the GUI version of the Forena report writer is just a user interface to facilitate the design (construction) of Forena report specifications (saved in so called FRX files). So for sure that is not related in any way to your missing menu item, which if shown lists the available reports that you can execute, e.g. the sample reports.
Documentation and examples are included in the module you installed / enabled. For an illustration of that, still D7, refer to this online demo, which also includes:

Some report samples.
Forena Documentation, such as a Setup Guide (with more details about things such as Permissions to be configured) and more details about the WYSIWYG Report editor.

Disclosure: I'm a co-maintainer of (the D7 version of) this module.


Replace/alter/rename form labels in theme

Solved!

Put this code to your theme's template.php, where's THEME replace it with your theme's dir name. So then where's #title = t() you put in your own custom title for the field. So what it does it alters given forms field, in this case it's simplenews_block_form inlcuded in between THEME_form_simplenews_block_form_alter

function THEME_form_simplenews_block_form_alter(&$form, &$form_state) {
  $form['mail']['#title'] = t('Join Our Mailing List:');
}

Clear cache!


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

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

Get Locations,
Geofield,
Geolocation Field
Location.

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

Head over to its (impressive) project page for even more information about it (it would be way too long to include a quote of it all here). That project page also includes various screenshots.
Note: Uploading custom markers should be possible also, similar to what you can see in the screenprint in the feature request about Custom markers.


I've never seen this problem. That default value should work. I would say try making the key a string and set #default_value as a string. The #options array may be being passed through array_merge  somewhere, thus rekeying integer keys. If keys are strings then that shouldn't happen.
Currently, your array looks like this:

$options = array(
  0 => '0',
  500 => '500',
  1000 => '1000',
);

But passing that array through array_merge can reorganize those integer keys to be in sequential order:

$options = array(
  0 => '0',
  1 => '500',
  2 => '1000',
);

If that happens then the 500 key simply doesn't exist. This is because array_merge does not like to preserve integer keys, but you can use strings to prevent it.
So, I think your array should look more like this:

$options = array(
  '0' => '0',
  '500' => '500',
  '1000' => '1000',
);

Then you can set your #default_value:

$form['price']['min']['#default_value'] = '500';

Otherwise, is there anywhere else where the default_value may be being overridden?


PDOException: SQLSTATE[42000] Implicit conversion from data type nvarchar to varbinary(max) is not allowed

I've figured out the main problem, when I was using the SQL migration tool to migrate, it was creating a database, so I devided to create mine to check. The one created by the tool was Latin1_general_CL_AS and mine was SQL_Latin1_General_CP1_CI_AS instead. That seems to have fixed the problem


How to return a missing field as null with db_select union?

I used the addField function to explicitely declare the NULL aliased columns for the UNION. It worked!
Check the following snippet:

$table_one = db_select('users', 't_o');
$table_one->addField('t_o', 'uid', 'id');
$table_one->addField('t_o', 'name');
$table_one->addField(NULL, 'null', 'weight');
$table_one->addField('t_o','mail');

$table_two = db_select('taxonomy_term_data"', 'tw');
$table_two->addfield('tw', 'tid', 'id');
$table_two->addfield('tw', 'name');
$table_two->addfield('tw', 'weight');
$table_two->addField(NULL, 'null', 'mail');

$s_query = db_select($table_one->union($table_two), 't')
    ->fields('t', array('id', 'name', 'weight', 'mail'));

And this generates this kind of SQL:

SELECT t.id AS id, t.name AS name, t.weight AS weight, t.mail AS mail
FROM
  (SELECT t_o.uid AS id, t_o.name AS name, null AS weight, t_o.mail AS mail
   FROM {users} t_o
   UNION
   SELECT tw.tid AS id, tw.name AS name, tw.weight AS weight, null AS mail
   FROM {taxonomy_term_data} tw)

Hope this solves your problem!


You're on the right track, the only thing you need to do is call your theme function in your page callback, blob_stuff(). There are two ways to do this, the preferable way is using a render array:

function blob_stuff(){
  $page = array
  (
    '#theme' => 'blob_stuff',
  );

  return $page;
}

You could also directly call your theme function, but this is not the preferable way to do it:

function blob_stuff(){
  return theme('blob_stuff');
}

But to go further with this, you've hard-coded the name Bob into your code. Usually you'll want something dynamic, pulled from the path in the URL. You can define a dynamic path with a wildcard in hook_menu()

function blob_menu() {
  $items['blob1/%'] = array(
    'title' => 'Blob1',
    'page callback' => 'blob_stuff',
    // Pass the 1st index of the path (the wildcard) to your page callback
    'page arguments' => array(1),
    'access arguments' => array('access content'),
  );
  return $items;
}

In hook_theme(), you'll add a variable:

function blob_theme() {
  return array(
    'blob_stuff'  => array(
       'variables' => array(
         'name' => FALSE,
       ),
       'template' => 'blob-stuff',
     ),
  );
}

Now in your page callback, you can pass the wild card to your theme function, which will output it in your template:

// $name comes from the wildcard in the URL
function blob_stuff($name){
  $page = array
  (
    '#theme' => 'blob_stuff',
    '#name' => $name,
  );
  return $page;
}

Your template will now look like this:

<div class="container-inline">
  Hi <?php  print $name; ?>
</div>


How to assign drupal webform to drupal node/block?

I suggest using the Webform Block module. It is stable and compatible with Drupal 6.

  Allows embedding a webform node into a block which can be positioned in any block region (theme space permitting).

  Handles redirecting back to the current page on validation errors.

  A good use for this is to add a site wide contact form inline on your pages, such as in the footer or sidebar.


Change display of teaser based on content type of page in which it is displayed

Have you tray display suit?

Display suit let you configure how you want to print the teaser and the full content type with a great UI

Oskar


How do I enable a custom JS file in my Drupal site?

There are several ways to add JS files to Drupal, depending on the requirements.

If the JS is related to your theme and used on every page, perhaps easiest to add the file to your theme's .info file

create the JS file in mytheme/custom-js.js and configure it for the theme in mytheme.info

scripts[] = js/custom-js.js
Flush all caches to register the new JS file.

More info: https://www.drupal.org/node/756722


How do I build a search form with filter options / checkboxes?

Take a look at this module, it may be what you need: http://drupal.org/project/custom_search.
It extends drupal built-in search module.
You can add filters for content types, taxonomies etc in drop-down triggered when searching.


How to disable a troublesome module that causes admin/modules to not list all modules?

I was lucky enough to have Drush available. So by simply using drush dis multilang, the module got disabled. And Eureca ... the link at admin/modules started to work again.
Even though I have not had to use another approach, this would have been my plan-b: disable the Multilang module manually in the database, via an SQL command like so:

UPDATE system SET status='0' WHERE name='multilang';

or as a variation, using PhpMyAdmin (if that's available).
If for whatever reason plan-b would not have worked either, you could consider deleting the entire module folder (for module Multilang) in the modules directory where that module got installed. That would, pretty sure, have "killed" the trouble module also. Though it would have left the module's row in the system table in some bad shape (to be repaired afterwards, probably with something like the "Registry Rebuild" module.

However, as pointed out by Molot also (merci! aka thanks!), deleting files is problematic. Because it prevents you from ever running uninstall on a module. And Registry Rebuild will probably not fix that. So think twice before using this plan-c ...


I added this code. Not sure if it does the trick. I need to set a hide based on permissions correct?

/**
 * Implementation of hook_menu_alter().
 * Remember to clear the menu cache after adding/editing this function.
 */
function MODULENAME_menu_alter(&$items) {
  // Removing certain local navigation tabs that are either undesired or need to be custom relocated.

  // Set these tabs to MENU_CALLBACK, so they still register the path, but just don't show the tab:
  $items['node/%node/track']['type'] = MENU_CALLBACK;
  $items['user/%user/track']['type'] = MENU_CALLBACK;
  $items['search/user/%menu_tail']['type'] = MENU_CALLBACK;

  // Fully unset these tabs and their paths, don't want them at all. This breaks the path as well:
  unset($items['user/%user/example']);
}


How to get page visit count from access log

1. Module Visitors

You may want to consider the Visitors module. As mentioned on its project page, it provides a block containing:

Total Visitors.
Unique Visitor.
Registered Users.
Last Registered User.
Published Nodes.
Your IP.

At this time there is no integration with the Views module ... yet. All reports created today use the theme function. Such views integration is being considered though, i.e. in the format of some out-of-the-box example, similar to the view delivered with the charts module.

2. Module Forena

If you'd want to "roll your own cookies" (i.e. some report that perfectly fits your custom requirements), then you might want to consider the Views integration of the Forena module. Here is a relevant excerpt about that from its project page:

  Use Views with Forena to create additional more complicated layouts than can typically be created using views. Forena provides a views rowstyle plugin that lets you use a Forena report to format the output of a view.

For an example of such custom report, created with Forena, start from the statistics (summary info) of the Watchdog Statistics, as in this Watchdog Statistics sample. Note the red numbers to the right of the table, which are actually hyperlinks that can be used as drill-down reports. I.e. if you click on any of them (like the "2" for "Page not found"), you get a details report about (in this case) the 2 specific records related to the "Page not found"). More details about this specific case can be found in comment #2 of issue 2337327. Obvious, I didn't really do any effort to beef up the look-and-feel of that report, like background, etc.

3. Other modules

Modules related to Visitors contains some other modules available, which might be considered as a possible alternative (or maybe 'addition'?), such as the Views Watchdog module.

Disclosure: I'm maintainer of the Visitors module, and co-maintainer of Charts and Forena,
I hope this does not violate the site's policy on self-promotion.


Trouble with session ID and Drupal cookies when trying to establish a connection with Service Module and http-post

All of the cookie information is set and returned in the response header of the login call.

This might also be of some help which explains how to make authenticated calls via a remote client.
http://drupal.org/node/910598

Also note that if you use a Firefox plugin, it will be able to access the cookie set in Firefox. Thus if you use a different application that cookie will be different, so you will not be able to auth via your custom app and simultaneously see yourself as logged in in Firefox.


How can I have a page title different from the name of its menu link?

You can set the page title with drupal_set_title() in your page callback.


How to change the teaser for the front page articles

You need to Edit and Save again the articles to take effect.

I know can be painful if you have hundreds of nodes. If you google about it you will find scripts to do it like this
http://befused.com/drupal/script-update-drupal-teasers

Or use the module retease http://drupal.org/project/retease

I advice you to take a database dump before testing these solutions, just in case.


Group node from OG membership doesn't work

Solved it. The panel needed the relationship. This can be added on the contexts-page of the panel. The relation I added was:
 Node from Node (on Node: Groups audience [og_group_ref])

When this is added it can be chosen instead of "This node" when Views panes are added to a page-layout.

This works with the default OG Content-view with the relation OG membership: Group Node from OG membership added to it. (on groups without content this gives No content in this group however.)


I am not too sure what this error would be caused by but I would recommend instead of putting the footer into the html.tpl.php put a wrapper div around the other elements within the page.tpl.php excluding the footer and styling that wrapper with a specific width.

eg.

      //all content in here

      //footer here


Most popular content content modules in Drupal 7?

Almost all functionality of this module you can implement using Views + Radioactivity module as it is described here drupal.stackexchange.com/a/21075/7313


First I'm going to assume that you have enabled/installed Taxonomy translation module.

Second you need to filter taxonomy_term_data by the current language.

So your code should look like the following:

Translation mode: Translate

function manufacturer_country_options() {
  $query = db_select('taxonomy_term_data', 't')
    ->fields('t', array('name', 'tid'))
    ->condition('t.vid', '35');

  if(module_exists('i18n_taxonomy') && i18n_select_mode('taxonomy')) {
    $table_alias = i18n_select_check_table($query, 'taxonomy_term_data', 'tid');
    $query->condition($table_alias . '.language', i18n_select_langcodes());
    $query->addTag('i18n_select');
  }

  $options = $query->execute();

  $rows[''] = t('-- Any --');
  foreach ($options as $row) {
    $rows[$row->tid] = $row->name;
  }
  return $rows;
}

Translation mode: Localize

function manufacturer_country_options() {
  $query = db_select('taxonomy_term_data', 't')
    ->fields('t', array('name', 'tid'))
    ->condition('t.vid', '35');
  $options = $query->execute();

  $rows[''] = t('-- Any --');

  foreach ($options as $row) {
    $term = taxonomy_term_load($row->tid);

    if(module_exists('i18n_taxonomy')){
      $term = i18n_taxonomy_localize_terms($term);
    }

    $rows[$term->tid] = $term->name;
  }
  return $rows;
}


What could cause the Wysiwyg module / CKEditor randomly disappearing and coming back?

go to modules and find jQuery Update module, and put it to version 1.8
That should fix the issue.


I don't want ajax submit / callback validate form '#required' => TRUE,

'#limit_validation_errors' => array();

$form['actions']['previous'] = array(
    '#type' => 'submit',
    '#value' => t('Previous'),
    '#limit_validation_errors' => array(
      // Validate $form_state->getValue('step1').
      array('step1'),
      // Validate $form_state->getValue(array('foo', 'bar')).
      array('foo', 'bar'),
    ),
    '#submit' => array('some_submit_function'), // #submit required.
  );


Is it possible to use search api indexs together?

Yes, you need to used the Search API multi-index searches module.

  This module is an addition to the Search API module which allows users
  to search on several indexes at once.

  When the module is enabled, you'll get a new Views base table where
  you can search all enabled Search API indexes at once. Performance
  might suffer, though, if not all indexes lie on the same Solr server
  (or other backend server that supports this feature).

  Please note that, since multi-index searches aren't supported
  explicitly by the Search API, most other Search API add-on
  functionality (facets, autocomplete, saved searches, search pages,
  etc.) won't work with searches created with this module.

There is also a sanbox project that allows you to combine Search Multi Index and Facets.


How to loop through fields from the Field Collection?

I'm current "fighting" width this module, too. I don't know if it is the correct/easiest way, but it works (for me).

First you have to load the ids of the field collection fields of the node:

$fc_fields = field_get_items('node', $node, 'field_image_teaser');

// Extract the field collection item ids
$ids = array();
foreach ($fc_fields as $fc_field) {
    $ids[] = $fc_field['value'];
}

I found the code above at Accessing a field collection (a related question).

To iterate over all fields you can use the following code:

//Get the entities
$collections = field_collection_item_load_multiple($ids);

//Loop over the array - if you have more than one entity
for ($i = 1; $i <= sizeof($collections); $i++) {
    $collection = $collections [$i];

    //Iterate over all member vars of the FieldCollectionItemEntity object
    foreach($collection as $key => $value) {
        //Look for fields - there are some other class vars, too.
        if (strpos ($key, 'field') !== false) {
            //Search for textfields
            if (isset($value['und']) && is_array($value ['und']) && isset($value['und'][0]['value'])) {
                print "Field ".$key." ".$value['und'][0]['value'];
            }
        }
    }
}


To migrate your existing site into Platform.sh, there are 3 components you need to import: code base, database and files.

Import code base

If your project already uses Git you've to go to your Git project folder and add platform as a remote and push your local branch to your platform remote.

$ cd ~/Sites/platform
$ git remote add platform [PROJECT-ID]@git.[CLUSTER].platform.sh:[PROJECT-ID].git
$ git push platform HEAD:master

Import your database

Create drush alias for your platform.sh, e.g.

$ cd ~/.drush
$ sudo vi platform.aliases.drushrc.php

In your new alias file, you can create aliases for your various Platform.sh projects. For example:

<?php
// Platform environment
$aliases['master'] = array(
  'uri' => 'master-[project-id].eu.platform.sh',
  'root' => '/app/public',
  'remote-host' => 'ssh.eu.platform.sh',
  'remote-user' => '[project-id]-master',
);
// Platform branch environment
$aliases['BRANCHNAME'] = array(
  'uri' => 'BRANCHNAME-[project-id].eu.platform.sh',
  'root' => '/app/public',
  'remote-host' => 'ssh.eu.platform.sh',
  'remote-user' => '[project-id]-BRANCHNAME',
);
// Platform local environment
$aliases['local'] = array(
  'site' => 'platform',
  'env' => 'local',
  'uri' => 'platform',
  'root' => '~/Sites/platform',
);

Backup your database.

$ drush @platform.local sql-dump > backup_database.sql
Export your local database and then import it into your remote Platform environment.

$ drush @platform.local sql-dump > local_database.sql
$ drush @platform.master sql-cli < local_database.sql

When the process completes, you can visit the URL of your development environment and test that the database has been properly imported.

Import your files

Use drush alias to import your existing local files:

$ drush rsync @platform.local:%files @platform.master:%files

The above steps assume that you're using drush and Git scm (which is the easiest way).

More details information can be found at: Migrate an existing site to Platform.sh


Why does Drupal use strange file extension for PHP code?

Because it's easier for the core to know about special files that way.

As a developer you're free to name your module or theme whatever you like, so that means that Drupal core needs another way to find and identify certain important files.  Doing this using the file extension is an easy way.


NodeBlock has been replaced by EntityBlock in Drupal 8.


Drupal Commerce - ability to close shop (restaurant/takeaway)

To do some flip-flopping with the Add to Cart buttons, take a look into the Commerce Stock module(s).  I'd imagine it's in the commerce simple stock.  When a product goes out of stock, it disables the Add to Cart button on the relevant product displays.  Though if even one product is available on that display, it won't disable it.  So, I would recommend checking out the commerce_stock.module and commerce_stock.rules.inc to see how they are doing that.

I envision a simple admin form page with a Close Store and Open Store buttons, and in their submit handlers, just running through and disabling the Add to Cart(s).  I'm sure there's a good way to do the "Restaurant Closed", "Restaurant Open" text, it's escaping me at the moment.


This answer is probably not timely to pal4life, but for anyone else still looking for answers.... this view doesn't show up via the Views module per say.  It is best used in conjunction with other modules or code.

For example, I wanted to get filtering functionality on my Webform views and using the Webform MySQL View module seemed to be the recommended way to go.  However, you will most likely need to install the Data and Schema modules as well.  A great walk through on how to use all three together to create filterable, sortable webform data via Views can be found here:

http://knackforge.com/blog/sivaji/displaying-webform-submission-data-drupal-views#comment-1085


Are custom content types a good way to model the classic entity relationship model?

In Drupal 7, you'll want the Entity module as it extends the core Entity API to do lots of useful things, and a lot of contributed modules depend on it.

To create relationships between entities (a "node reference" relationship, if you will) you'll want the Entity Reference module. Another more radical approach is the Relation module which provides two-way relationships – this is in early development stages and is a bit more complicated. I would recommend the Entity Reference module, as even though the initial relationship is 1-way, it's simple enough to find the referencing-entity on a referenced-entity when needed.

Regarding your question about tuning the database – the relationships are not setup as foreign keys or anything like that, as Drupal handles your database constraints in code and not within the database schema itself. That's a whole other conversation. The tables that contain fields for a specific node type, including the table that includes a reference to another node ID, are just joined with the node table on "entity_id". There are pros and cons to this – if you're a traditional database admin type, this may seem problematic, but it's the job of the CMS to maintain integrity in this model. I don't think you'll find ways to tune the database via new indexes, although you could certainly try. Thousands of nodes is not a lot of data and you should see Drupal 7 – in a properly tuned environment, with queries and views that do not contain extraneous joins – performs quite speedily.

My 2 cents.


Way to integrate a latex-based wiki into a drupal 6 site

A solution would be to have a Drupal based wiki on your website and then to allow the usage of LaTeX markup for the wiki content. DruTeX]1 may allow the later, while Wikitools should provide the former. They will both need to be properly configured.


I want to use this font family: PTSansRegular

You have two options, doing it using a module such as @font-your-face or just simply doing it without a module.

Download the font from the site you specified above.
Open the CSS from the folder and check the different styles of fonts.
Copy the font folder to the CSS folder in your theme's directory.
Open .info file of your Drupal theme and add the stylesheet link from
the font folder.
Use the font-family of the currenlyt downloaded font in your
stylesheet.
Clear your cache.


How can I make a page with only blocks but without node content ?

You can use the the Empty Page module to allow you to have pages solely for placing blocks.

  The Empty Page module is a simple empty page solution. It provides an interface that assists in managing "empty" menu callbacks, mostly used for pages that only consist of blocks.


Drupal 8's last minor release = Drupal 9?

Yes, upgrading from Drupal 8 to 9 is scheduled to be an incremental update from the last minor version of Drupal 8.

It seems the main thing to consider is to remove any usage of deprecated functions to ensure a smooth upgrade.

  Contributed project developers, as well as those maintaining custom integrations, should follow the deprecations when possible and use the latest APIs available. This means that when Drupal 9 is released they will have to make fewer changes to be compatible

https://www.drupal.org/core/deprecation


Steps to show the view in this ways is

Create an Unformatted view showing Title and Terms.

Term field should be excluded from the display.
Do a grouping of the term field.(Unformatted Format -> Settings)

Save the view and check the result of the view.

Hope that this helps.


First thing I would look at is creating indices for your tables.  Look at the queries you are making and see if you can't optimize them with an SQL index. E.g. if you are querying against node id and user id with joins, try creating three indices, one for nid, one for id, one for nid and id.

Having the right indices can make a long running query fly.


Your regex is incorrect. You placed the second and third \ after the . instead of before.

$settings['trusted_host_patterns'] = array(
  '^172\.20\.0\.3$',
  '^localhost$',
);


Receiving Access Denied with altered CRUD paths in ECK

It would be helpful to see an example of an original ECK path (for a single entity), and then your updated one. If you re-arranged the arguments, or changed their quantity, the access arguments passed to the access callback will not be correct.

You will almost certainly need to implement hook_menu_alter to update the access arguments property of ECK paths.


"Switch on node type" is like a switch($case){} statement in PHP (and other languages).

After selecting "Switch on node type" in Hansel, you will need to provide the *machine_name* of the node-type in the "Name" field that Hansel presents.  For instance, you can enter one of the following in the "Name" field:

article -- will target Article nodes
blog_entry -- will target Blog Entry nodes
webform -- will target Webform nodes
<default> (for remaining node types)

If it were in code, it would look something like:

switch($node->type) {
  case 'article':
    // Make an article crumb
    break;
  case 'blog_entry':
    // Make a blog-entry crumb
    break;
  case 'webform':
    // Make a webform crumb
    break;
  case '<default>':
    // Do something for everything else...
    break;
}

"Switch on path argument" works the same way... but, instead of providing a node-type in the "Name" field, you should enter the path-argument you're targeting, such as:

node (to control breadcrumb on pages with a path like node/*)
taxonomy (i.e. for taxonomy/term/* pages)
admin (i.e. admin/* pages)
blogs (i.e. blogs/* pages)

$path_arg_1 = arg(0);

switch($path_arg_1) {
  case 'node':
    // Make a crumb for node/* pages
    break;
  case 'taxonomy':
    // Make a crumb for taxonomy/* pages
    break;
  case 'admin':
    // Make a crumb for admin/* pages
    break;
  case 'blogs':
    // Make a crumb for blogs/* pages
    break;
}

It seems Hansel can only target the first path-argument.  Also note that <default> seems to only work for "Switch on node type".

To create Home->Bussiness->Faq->How To Tie a Tie (assuming Business is a tax-term and Faq is node-type):

First Rule (for the breadcrumb's head, i.e. "Home" link)
Create a rule with the name start, and leave "Parent" set to <root>
Under "action with breadcrumb", select "add a single link"
Set "Action" to "switch", then click "next"
Enter "Home" as your link name, then set path to <front>
Select "switch on url argument" and click "save"
Second Rule (for the breadcrumb's tail, i.e. node-title: "How To Tie a Tie")
Create a rule with the name finish, and leave "Parent" set to <root>
Under "action with breadcrumb", select "add link to current page"
Set "Action" to "leave", then click "next" and "save"
So far, these two rules will get you: Home->How To Tie a Tie
Third Rule (for the second crumb, i.e. taxonomy term "Business")
Create a rule with the name node, and set "Parent" to -start
Under "action with breadcrumb", select "add term path"
Set "Action" to "switch", then click "next"
On the next page, select the vocab containing the "Business" term
Set "Switch on" to "node type"  then click "save"
Fourth Rule (for the third crumb, i.e. node-type "Faq")
Create a rule with the name faq (for node type "FAQ"), and set "Parent" to --node
Under "action with breadcrumb", select "add link to nodetype"
Set "Action" to "Goto rule", then click "next"
On the next page, configure the "Path" as desired
Set the "Goto Destination" to -finish then click "save"


What is the difference between a Drupal session variable and a cookie?

Seeing this has two votes, I'll try to explain it.

Drupal uses the built-in PHP session mechanism, which as you rightly suspect is based on a cookie. The cookie name is SESS followed by a long string of characters, and its value is another long string of characters. PHP detects this cookie and makes it available to Drupal's session implementation, which by default uses the database table sessions for storage, with the value of the cookie as the key sid.

The session entry also records the user ID: early in the Drupal bootstrap sequence the session is loaded and then the corresponding user object, which is subsequently used to govern access to resources, based on the user's roles and other attributes.

Data stored in the PHP global array $_SESSION is automatically saved to the current session's database entry by Drupal at the end of a page request. This is typically used to store relatively transient data such as items in a shopping cart.

Other cookies can be saved and retrieved in code (including JavaScript) and they will not be affected by logout unless you specifically write code to delete them when that happens. Confusingly, cookies with an expiry time of 0 are also often termed "session cookies" - these are deleted when you shut down your browser.

There's a lot more that could be said and I'll add some good references when I have a chance.


There's one additional trick additionally to the options that you already listed. If you look at search_menu(), you can see that it uses a named placeholder called %menu_tail and this: 'load arguments' => array('%map', '%index'),.

This does exactly what the name suggests. It calls menu_tail_load() (and passed it's own index/position to it as a load argument), which doesn't actually load anything but takes all additional path elements including it's own position,  and returns them as a single argument.

Obviously, this only works for the last argument. If you have multiple arguments like this, use GET/POST variables or escape them.


Why am I getting a PDO Exception error when I try to run Drupal Console inside the root directory?

Try to update below in your php.ini. You need to define php for correct location for .sock file.

mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

OR

If you will not getting result then try to replace below in your settings.php file.

Replace 'host' => 'localhost',

With 'host' => '127.0.0.1',


How to change the target of a file for a multiple file field in drupal 8?

You can do this in a hook, but also in a custom file-link template in your theme. Check if the file link has a class specific to a pdf file and then set the target attribute:

file-link.html.twig

{% if attributes.hasclass('file--application-pdf') %}
  {{ link }}
{% else %}
  {{ link }}
{% endif %}


Image Gallery not loading random thumbnails

I just checked out your site and all images showed up. It took some time, but all images did show up. Looking at it further, it appears that you have your file system set to private. Go to admin/settings/file-system/settings and change the Download method to public. If this is not an option, then I would look at implementing xsend in apache and installing the drupal module http://drupal.org/project/xsend

Unless you have some VERY good reasons to set your file system to private, I highly recommend using a public file system.


How to reduce the speed of rotation in view ticker module

If you are using FADE effect, look in the folder xxxx of the module the views.ticker.fade.js file, and rise the value of the:

b = b || 4000;

to something like 10000 or 12000.

Good luck.


How to make Drupal Commerce send email notification to the author of products sold?

In short; you should loop over all commerce order line items, obtain the product owner and add it to a list. Then in a new loop, go through the created list to send all product owners a main.

First you need a rules component that checks if a provided line item contains a product field and pushes the author to a given list (enforcing uniqueness makes sure every product owner is only added once). You can import below code on the components tab:

{ "rules_product_on_line_item" : {
    "LABEL" : "get product owner from line item",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "line_item" : { "label" : "Line item", "type" : "commerce_line_item" },
      "owners" : { "label" : "Product owners", "type" : "list\u003Cuser\u003E" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "line-item" ], "field" : "commerce_product" } }
    ],
    "DO" : [
      { "list_add" : {
          "list" : [ "owners" ],
          "item" : [ "line-item:commerce-product:creator" ],
          "unique" : "1"
        }
      }
    ]
  }
}

Now for the main rule, create a new variable of type list of users. This is where we will store all product owners in.

Create a loop over commerce-order:commerce-line-items. In this loop, use the component that was created above. This will fill the list of product owners.

Finally, loop over the list of product owners, and send each of them a mail. The complete rule would look something like this:

{ "rules_mail_all_product_owners" : {
    "LABEL" : "Mail all product owners on an order",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "5",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "mimemail", "commerce_checkout" ],
    "ON" : { "commerce_checkout_complete" : [] },
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "list\u003Cuser\u003E" },
          "PROVIDE" : { "variable_added" : { "product_owner_list" : "Product owner list" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "component_rules_product_on_line_item" : { "line_item" : [ "list-item" ], "owners" : [ "product-owner-list" ] } }
          ]
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "product-owner-list" ] },
          "ITEM" : { "productowner" : "Current product owner" },
          "DO" : [
            { "mimemail" : {
                "key" : "mailkey",
                "to" : [ "productowner:mail" ],
                "from_mail" : [ "site:mail" ],
                "subject" : "",
                "body" : ""
              }
            }
          ]
        }
      }
    ]
  }
}


Moving drush installed directory to production site?

The answer is that you have to copy the html/ and vendor/ directory trees from your project under var/www, and in theory it works. Except for me that it doesn't, as it just steps onto the next error where the stylesheet doesn't load properly (error in MIME types)... but that's the next story!


By the way, all the hooks are listed here there doesn't appear one that fits the task tho.

You can always add a custom validation to the field add form.

/*
 * Implements hook_form_FORM_ID_alter()
 */
function mymodule_form_field_ui_field_storage_add_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form['#validate'][] = 'mymodule_custom_add_field_validation';
}

/*
 * Custom Validate Callback
 */
function mymodule_custom_add_field_validation(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  // the code that performs the check
  // if (......) {
  //   $form_state->setErrorByName('label',
  //     t('This field already exists in another entity'));
  // }
}


How to automatically uninstall a module before running a Nightwatch test?

I ended up using the Node exec command to call drush like this:

module.exports = {
  '@tags': ['picostat'],
  before: function(browser) {
    const { exec } = require("child_process");
    exec("drush pmu recaptcha")
  },
  'Check a dataset was likely created correctly.': (browser) => {
    browser
      .drupalRelativeURL('/node/add/dataset')
      .waitForElementVisible('body', 2000)
      .assert.containsText('body', 'Create Dataset')
      .setValue('#edit-title-0-value', 'Test Dataset')
      .click('#edit-field-dataset-input-method-file')
      .click('#edit-field-dataset-header-false')
      .setValue('input[name="body[0][value]"]', 'Test dataset body')
      .end();
  }
};


Eventually things got fixed, learned that you can just add a .js file into your module with the HOOK_init() since they get stored to use at a later stage.

What obviously was causing the problem, was the wrong declaration of the API key, this was fixed by adding the line:

drupal_add_js("https://maps.googleapis.com/maps/api/js?key=[MY API KEY]", "external");

to the document.
After that, I could call the .JS file with:

drupal_add_js(drupal_get_path('module', 'maps_markers') .'/maps_markers.js');

More information on how everything was fixed can be found here:
Module conflicting with JQuery


To list all nodes of the parent, i.e. siblings.

// Node ID to to search by
$nid = 1;

// Load Node
$node = node_load($nid);

// Get Node's Content Type
$type = $node->type;

// Search for siblings
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', $type)
  ->propertyCondition('status', TRUE); // Get only active nodes
$result = $query->execute();

// Load Sibling Nids
$nids = array();
if (isset($result['node'])) {
  foreach ($result['node'] as $node) {
    $nids[] = $node->nid;
  }
}

// Load Sibling Nodes
$nodes = node_load_multiple($nids);

Building relationships

In regards to structuring a 3 tier relationship, I personally use Entity API and simply reference Nodes to Terms. In cases where I need to create a relationship between Nodes only, I've used an Entity Reference module, or now, I just create a module, which attaches a field with an option to enter a referencing node.

You may also want to check out a Relation module, which has a more complex use to it.


Equivalent of created and modified properties for a taxonomy term

That data isn't stored for taxonomy terms, if you want to add it you'll need to write a small custom module to do so. You could look at implementing hook_entity_info_alter() or hook_field_extra_fields_alter() to actually add the extra property to the taxonomy term entity, but I haven't had much luck using that method before.

Instead I would define a table using hook_schema() in the .install file of your module:

function MYMODULE_schema() {
  $schema['taxonomy_term_extra'] = array(
    'fields' => array(
      'tid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'created' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'modified' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      )
    ),
    'primary key' => array('tid')
  );

  return $schema;
}

Then in your module file implement the taxonomy CRUD hooks:

function MYMODULE_taxonomy_term_insert($term) {
  db_insert('taxonomy_term_extra')->fields(array(
    'tid' => $term->tid,
    'created' => REQUEST_TIME,
    'modified' => REQUEST_TIME
  ))
  ->execute();
}

function MYMODULE_taxonomy_term_update($term) {
  db_update('taxonomy_term_extra')
    ->fields(array('modified' => REQUEST_TIME))
    ->condition('tid', $term->tid)
    ->execute();
}

function MYMODULE_taxonomy_term_load($terms) {
  $result = db_query('SELECT * FROM taxonomy_term_extra WHERE tid IN (:tids)', array(':tids' => array_keys($terms)));
  foreach ($result as $record) {
    $terms[$record->tid]->created = $record->created;
    $terms[$record->tid]->modified = $record->modified;
  }
}

function MYMODULE_taxonomy_term_delete($term) {
  db_delete('taxonomy_term_extra')->condition('tid', $term->tid)->execute();
}

Now whenever you have a loaded taxonomy term you'll have access to $term->created and $term->modified. You can also use a normal db_query(), which is much faster than an EntityFieldQuery to get your filtered terms:

$args = array(':time' => strtotime('-1 day'));
$tids = db_query('SELECT tid FROM {taxonomy_term_extra} WHERE modified >= :time', $args)->fetchCol();

$terms = taxonomy_term_load_multiple($tids);


You can use global $base_url; if you are using the PHP filter.


How to translate "New custom content" in a panel?

First of all, I would like to explain why this doesn't "just work", so that you have been given fair warning before I give you new problems. :)
Consider a custom content pane content like:

Welcome %user:name, you have %field_num_messages new messages waiting.

The text here would be substituted before passed to t(), meaning that for each variation of user and number of messages, you would get an entirely new string to translate. For such panes, go with having two separate panes.

A long term solution is slowly being worked on here: Translatable panel titles: Implement i18n_strings but focuses on the pane titles initially.

Generally speaking, the solution is to avoid custom content panes, but I also realize that using them can be very convenient at times.

Finally, here's a piece of code I've used to "force" pane titles to become translatable. I will attempt to later modify it better to your situation, but I figured having a useful answer quickly was better than not. :) You should be able to use $pane to figure out if this is a custom pane, and then pass the text through t().

/**
 * Implements hook_panels_pane_content_alter().
 */
function HOOK_panels_pane_content_alter($content, $pane, $args, $context) {
  if ($content->title) {
    $content->title = t($content->title);
  }
  return $content;
}


How do I render two links with a pipeline as separator?

What you see as displayed HTML is escaped by Twig. Only safe markup is not escaped.

l() produces safe markup, but if you add something to it, the complete string becomes unsafe.

You can use an inline template to get around this problem.

if ($edit) {
  $action = [
    '#type' => 'inline_template',
    '#template' => '{{ edit }} | {{ action }}',
    '#context' => [
      'edit' => $edit,
      'action' => $action,
    ],
  ];
}


unable to link my custom content type nodes to a menu I created

By default, Drupal 7 does not create a filtered list of content. You're going to want to use Views Page to create a list of content.

Delete the menu item you created, then install https://www.drupal.org/project/views and its dependency https://www.drupal.org/project/ctools

If you have Drush installed...

drush dl views
drush -y en views views_ui

In your browser, go to /admin/structure/views
Click "Add new view".

View Name: Photos
Show [Content] of type [Pics]
[X] Create a page

Page title: Photos
Path: pics
Display format: Table

Click "Continue & edit" to customize

For information on Views, see https://www.drupal.org/documentation/modules/views


Public URLs have web/ prefix while admins do not, how to remove 'web' prefix?

This appears to be fixed; the following steps for creating a drupal 8 site don't appear to have the issue: https://www.drupal.org/node/2471553.

(Original issue posted on https://www.drupal.org/node/2673164.)


Drupal load form with ajax callback in Bootstrap modal

I solved this issue differently by adding '#attribute' with event...

$form['share'] = array(
        '#type' => 'button',
        '#value' => " " . t('Record') . "",
        '#ajax' => array(
          'callback' => "modal_share_form_submit",
          'wrapper' => 'shareMessage',
          'effect' => 'fade',
          'method' => 'html'
        ),

        '#id' => 'modalsharebutton',
        '#attributes' => array('onclick' => "share_submit($fid);"),

);

Thank you.


In the view's contextual filter, you would need to select 'PHP Code' in the 'Provide a default value'. Then in code you can specify something like:

// get current path
$path = explode('/', current_path());
// make sure the path component exists (replace 1)
if (empty($path[1])) return;
// decode the component (use any function you fancy; replace 1)
return base64_decode($path[1]);

The encoding would happen wherever the link exists. If it is a view, you might need to use a module such as Views PHP in order to rewrite your link.


You could add a redirect in the .htaccess file if you're using Apache. Something like this:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_REFERER} .*abc.com  [NC]
  RewriteRule .* http://example.com/abc  [R]
</IfModule>


Problem with updating modules (check updates)

Problem solved through cleaning cache_update table (execute SQL query "delete from cache_update;" through phpmyadmin or mysql workbench)


Custom Entity API does not give individual fields in Views, only (sometimes information-less) rendered entities

If you've tried conventional approaches and they haven't worked (like me) then you might find that there are a few things that you need to do:

Firstly for me was truncating the cache table just to get rid of a whole heap of old data from previous iterations of my designs. Then it was simply defining hook_entity_property_info as suggested. To check if things are working you can debug and use hook_views_data_alter(&$info) and check out the variables. You'll probably see views has two varieties (unless I'm still doing something wrong):

entity_subscription and views_entity_subscription...

entity_subscription Array [3]
    table   Array [2]
        group   Subscription
        entity type subscription
    user_id Array [4]
        title   user id
        help    user id of registrant
        field   Array [2]
            handler entity_views_handler_field_entity
            type    user
        relationship    Array [5]
            handler entity_views_handler_relationship
            base    entity_user
            base field  uid
            relationship field  user_id
            label   user id
    magazine_id Array [4]
        title   magazine id
        help    magazine id of this subscription
        field   Array [2]
            handler entity_views_handler_field_entity
            type    magazine
        relationship    Array [5]
            handler entity_views_handler_relationship
            base    entity_magazine
            base field  mid
            relationship field  magazine_id
            label   magazine id
views_entity_subscription   Array [1]
    rendered_entity Array [3]
        title   Rendered Subscription
        help    The Subscription of the current relationship rendered using a view mode.
        field   Array [3]
            handler entity_views_handler_field_entity
            type    subscription
            real field  entity object

And then as is suggested a whole heap of different places, those fields will be available and if you go to "Relationships" in the Views config then you can also add other entities and their properties. For example 'user' as is the case with "entity_subscription" above, defined by specifying "type" as "user".

Oh, and also - the views_entity_subscription was just a rendered entity, I presume this is for a direct entity/views use, for example when creating a view just of that entity type.

One final thing: the entity api module itself actually has, in the folder within that module called 'modules' (i.e. sites/all/modules/entity/modules/...) a whole heap of hook_entity_property_info() for the main (core) Drupal entities. This means you can open user.info.inc for example and see how the module authors wrote the entity_property_info for the user entity.


I think your mixing up table names and module names in hook_update_dependencies().

First of all, you don't need hook_update_dependencies() to declare dependencies inside your own module. The updates will always be run sequentially, so that mymodule_update_7200() will always run before mymodule_update_7201().

Then, if you want to use hook_update_dependencies(), you would use it to declare inter-module depenencies like this:

function mymodule_update_dependencies(){
  $dependencies['mymodule'][7201] = array(
    'other_module' => 7203,
  );
  return $dependencies;
}

Now to your error. Can you check in the system table record for your module what the current schema version is? From the code and the error message I would suppose, that the database is already at schema 7200 (at least officially) but that somehow the renaming has not been done. Is it maybe possible that you have altered the database manually?

Edit: You are mixing up the arguments to db_add_field. It must be db_add_field('mymodule_field_mappings', 'fieldset_type', $spec);


How to add a menu under Webform Results?

Try to select Default menu tab instead of Menu tab.


How can I reference two field without nid or uid?

enable  entity reference module.
In the second CT , add an entity reference field.
In the field settings of the entity reference field select the first CT from a list of CT .
Create a view of second CT with all its related field.
Add relationship under the advanced options  ,  add an entity reference relationship referencing first CT.
Then add all the fields of first CT.
use the module link -
https://drupal.org/project/views_dependent_filters
for equating the serial text field.


https://www.drupal.org/project/apdqc is a pretty good solution for the issue you're describing. Install the module and go to the status report page (admin/reports/status); it will then run a gamut of tests and give you advice on things to change in your settings.php, php.ini, and my.cnf files.

The root cause of most of the cache deadlocks is that a truncate query and insert query are in conflict with each other.


Can drush accept piped commands for aliases?

It should be allowed to use piping in drush aliases as this feature was added recently by improving escaping options for core-exec.

So you have to upgrade your drush to the recent version (7.x).

See: Are pipes allowed in shell aliases?

If you prefer to use script, here is one which I'm usually using:

#!/bin/sh
# pull-db.sh
# Script to pull the database from remote to local environment.
[ -z "$1" ] && { echo "Usage: $0 @remote (args)"; exit 1; }
SRC="$1"
shift
drush $SRC sql-dump | drush $* sql-cli


block->subject set when using one theme, but not when using identical copy of the theme?

Looks to be a known issue. I see blocks display emptry string for $block->subject. in this thread someone mentions that they had to modify system.module for this to work. you can check it out in this thread here. Looks like a patch is out there for it.


How do I update configuration/database after a core update?

Updating Drupal 8 roughly goes like this. First in a local instance of your site:

Run composer update drupal/core --with-dependencies to update core. (Updating all dependencies including contrib would be composer update --with-dependencies.)
Now apply database updates by either drush -y updb or by visiting /update.php in your browser.
Next export the config that may have changed now by either drush -y cex or from your Drupal back-end in the browser.
Git commit and push the updated composer.lock file and the updated config files.

Next on your live site you roughly do the same, but now import the config at the end.

Git pull the updated composer.lock and config.
Run composer install --no-dev to update the files.
Run drush -y updb or visit /update.php to apply the database updates.
Run drush -y cim or visit your admin settings to import the updated config that now should match the one you exported locally earlier.

For a more advanced deployment flow, for example flushing cache and activating the maintenance mode, see my other answer on Order of drush commands for automated deployment?


Term page doesn't show nodes when terms are added in a field collection?

This is because the default term page implementation in Drupal 7 is querying node relationships, it has no awareness of relationships to Field Collections that are related to Nodes (or potentially, other entities).

You would have to solve this yourself by using a module like Taxonomy Views Integrator, which lets you create Views and set them as the term page view instead of the default Drupal page callback which won't ever work in this scenario.

You can follow why you aren't getting hits from Drupal core here. Hence, you need to override this presentation.

So, if you use TVI, you'd want to create a View that selects field collections with relationships to terms and nodes, and give it a contextual filter of taxonomy term id from URL (assuming taxonomy/term/%tid path). This should get you results, and let you link to the node. I don't have a sandbox setup to try this out, so you may need to experiment on the View formula.


Migrate Module: How to construct a map on a UNION query

Either do 2 migrations. Or create a derivative table of your term data to easily set the $query for the migration before running the migration task.

You can do this by writing a custom php script to be called by drush php-script or by using the preImport migrate hook to build/rebuild the derivative table.


Views 3, contextual filter on language - allow for multiple languages

I solved this task like so:

For "When the filter value is not available",  select option "Provide default value".
then use "PHP Code" as the value for "Type"
the actual PHP code I added is as shown in the screenshot below:


How to get "configure" icons next to each block back?

If you are referring to the gear icon that appears when you hover the mouse over a block, that is output from the Contextual links module that comes with Drupal core.

The same module adds contextual links to other parts of a page, such as a node.

It also handle the gear icon that you see in the page to edit a view.


What is the Internationalization Views module for?

Looking at the module code it seems to do the following:

Adds a Translate operation to the ctools export UI (see the i18nviews_ctools_plugin_post_alter() function in the module file).
Supports translation for views strings: title, header, footer (this is in the i18nviews_help() function).

The comment at the top of the module file is:

  This module translates some views strings on the fly using i18n string system

So I would guess the module is just providing internationalisation for some elements of the Views module that don't have it built in yet.


Programatically load title of a views page by its machine name

Any of these should work:

Load the View and get the display title:

$view = views_get_view('views_page');
print $view->display['page_1']->display_options['title'];

Note: Change 'page_1' to the name of your display.

You can also get the page title from the path:

$item = menu_get_item(drupal_get_normal_path('path/to/page'));
print $item['title'];


Remembering the address of the calling page of a form (Drupal 7)

I would do this like so:

Have your menu item URL generated with destination parameter, for example:

/?q=documentation_menu&destination=some/path/where/user/had/just/been

add a hidden field to your form and populate it with destination path

$form['destination'] = array(
  '#type' => 'hidden',
  '#value' => drupal_get_destination()
);

if you for some reasons can't add destination parameter to that URL, then you'll need to extract that URL from $_SERVER['HTTP_REFERRER'] and populate hidden field with it.

Then in your submit function just do a redirect to the path specified in that hidden field:

function documentation_menu_nameform_submit() {
  ...

  drupal_goto($_POST['destination']);
}


Redirecting anonymous user to specific page

you can set destination after login to which you want the user to redirect to.

So consider this example a login link like  www.sitename.com/login?destination=node/1 will take user to node/1 after login.

More detail:

https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_get_destination/7

one of you comment says you are using login redirect module, I have not used this module before the module page on drupal.org itself says it covers the functionality you are looking for.

  A simple module providing a method to redirect users according to an
  URL-defined parameter after logging in. Allows redirects toward
  non-Drupal location.

So the reason the that ?destination is not working, might be because of you a redirect rule triggered by login redirect module.

So solution can be set conditional redirection in login redirect module which can be checked using the parameters in url.


computed field with product variation and content type

To clarify from the comment thread:

This is a question that is tough to answer on SE because it's just something you'll have to feel out. If you're doing 1:1 content types to product displays, it doesn't really matter where you put it (though it'd probably be easier to do it on the CT) in general I tend to put more on PV because it's data related to the product. If you're doing 1:N then you'll definitely want to put it on the PV and if you're doing M:N then you're going to have to do some customization.
You can put the computed field on the PV but you'll need something like Entity Backreference so that the PV has a link back to the content type so you can load it and grab it's fields.


I can suggest you an alternative approach.
In your views filter area, create a new filter, based on the current user's language.

How to do it:

Views: add filter criteria -> Content: Translation language
Check the checkbox labeled "Interface text language selected for page"

Another thing, you can go to Views overview page, and then Views settings tab -> Show SQL query option.

How to do it:

Go to admin/structure/views/settings
Check this option

In this way this will always show the query that gets executed.
I suggest you copy it it here, so that the other people will have better time understanding what you want to achieve.

Notes:
The Drupal 7 site builders are used to "Currents user language" checkbox, however that checkbox has been renamed.
More information:
http://hojtsy.hu/comment/21596#comment-21596

Best regards,
Oleg


After some research and some helpful suggestions from another user, I ended up taking a look at the core modules user and node and got a pretty good understanding how to make base entities and attach fields to them. I suggest anybody who is stuck trying to figure out how to do it do the same as once you see it in live working code it's pretty easy to understand.


Review your selections and rate them in Webform within Drupal 7

Preview functionality is now part of the 7.x-4.x branch. There is an involved discussion about it here: Summary/review/preview page before final submission in multistep forms.

As for prioritizing, I think you would want to add a rating field for each field, and theme the form and the preview such that the initial form would not show the rating field, and the preview would.

Depending on what you want to do with those ratings, you may want to use a module like Star Rating (which is a simple module that doesn't have any other dependencies) or FiveStar (which is more complex and has more functionality).


You can choose to display the query; it's a checkbox called "Show the SQL query" on the Views settings page (admin/structure/views/settings).


How do I remove classless divs around my paragraphs?

In the theme stable the field twig has two div's, one overall and one for each item. This would match what you have provided as html markup.

So this should work, copy field.html.twig from stable to field--entity-reference-revisions.html.twig in your theme and remove the div's from there.

That the div's are useless is not correct for all circumstances, because there may be different configurations or modules, which use the attributes of the div's. So if you remove them, you might loose some of that functionality.


Drupal commerce order total ignore changed unit price

Try to downgrade rules to v 2.7. For more details look at https://www.drupal.org/node/2408705

  Important: Rules 2.8 has a critical regression that causes checkout
  rules to not work. Follow #2403851: Commerce pricing rule not working
  for more details, and downgrade to 2.7 for now.


Exclude taxonomy terms from search_excerpt in snippet

The search result is a node view and hence the hook_node_view_alter works for it.

So you would could create a custom module and write the following function

function custom_node_view_alter(&$build, $type)
{
    if (($build['#view_mode'] == 'search_result') && ($type = 'node'))
    {
        unset($build['field_tags']);
    }
}

change the field_tags to the name of your taxonomy field in the content type.

$build['#view_mode'] this variable defines the view we are on. In this case we are on the search_result view. And the $type defines the module in this case it is the node.

Use the following for Drupal 6

function custom_nodeapi(&$node, $op, $a3, $a4) {

  switch ($op) {
     case 'search result':
          $node = node_load($node->nid);
        $node->build_mode = NODE_BUILD_SEARCH_RESULT;
        $node = node_build_content($node, FALSE, FALSE);
        $node->body = drupal_render($node->content);
      break;
  }
}


CCK form to edit single field or set of fields

Is it for D6, if so this module will solve your problem: jEditable inline content editing.


Referring to an image file uploaded as `Image` type field without /sites/

You could create a symlink in the drupal root using:

ln -s sites/default/files images

and then set the src attribute to something like:

/images/myimage.jpg

Really not sure what you would gain by doing this.


receiving incorrect url from amazon s3 module

You need to create a group permission for Amazon S3 in Amazon IAM and indicate who can view the bucket.

Instructions on how to grant access to your bucket here: http://blogs.aws.amazon.com/security/post/Tx3VRSWZ6B3SHAV/Writing-IAM-Policies-How-to-grant-access-to-an-Amazon-S3-bucket

Hope this helps.


D8 | submitForm | Get the $_POST - vars via $form_state or via \Drupal::request()?

$request->request->all() != $form_state->getValues()

$request->request->all() === $_POST
$request->query->all() === $_GET

See in Drupal\Core\Form\FormBuilder::buildForm()

$input = $form_state->isMethodType('get') ? $request->query->all() : $request->request->all();
$form_state->setUserInput($input);

$form_state->getValues()  is already modified data that is formed on the basis of $form_state['input'] and #default_value

See in Drupal\Core\Form\FormBuilder::handleInputElement();

Pay attention to #value_callback it forms the value of the field


There are many ways you can do this.

Go to maps.google.com, type in the address, get the link, then click the customize and preview embedded view. A popup should appear. Select the map size you want. Copy the html code and go to structure -> blocks -> add block, paste your code and select full html filter. And add your block to where you want it
Download the gmaps module and use it. By default is has a block created called location map

  The GMap module provides an interface to the Google Maps API within
  Drupal. It integrates with the Location module to provide users a
  clickable map for entering latitude and longitude, as well as to
  display maps of Drupal nodes and users. GMap can be used to create
  interactive maps with various map markers and content in map bubbles,
  taking advantage of Drupal's other content management features. The
  module also provides a Views display plugin which allows users to
  display the results of a view on a Google map.


Simple test always failing for custom module

Try calling $this->setUp(); from the testCustomPageLoads() function.


I eventually wrote an entire module for this purpose. Basically, I have a 'feed' field for the group-type content type, and my module tracks that field and any changes through core hook_node_update, _delete, _insert, etc. hooks. Then I have a cron-based queue consumer that grabs the 5 feeds that were updated furthest in the past and checks for new content, then posts it into nodes under the feed's group.

I used SimplePie to help with the parsing, because even SimpleXML is somewhat of a pain. Anyways, I might try to make this functionality more formalized and port it to work with something like Organic Groups, but it's really purpose-built. If anyone would like some help doing something similar, give me a shout.


Remove field-collection-view and field-collection-container fromt field output

I managed to find the answer.

Through adding this function I replaced the containing
 with nothing "".

function jacob_d7_theme_field_attach_view_alter(&$output, $context) {

  // First check we're dealing with a field collection field.
  if(!empty($output['field_add_image'])) {
    // Now check for our specific field collection field.
    if ($output['field_add_image']['#field_name'] === 'field_add_image' ) {

      // Alter the prefix.
      $output['field_add_image']['#prefix'] = '';
    }
  }

}

then to remove the containing div for each field item I created a file called field-collection-view.tpl.php with only the following code. to remove the
.

<?php
  print $element['#children'];
?>


How to Collapse "Locale settings" (TimeZone) in User Profile with hook_form_FORM_ID_alter();

This is a bit of a hack but it worked for me.

My desired effect was to have the Locale Settings start out collapsed and be expandable, every other solution out there suggests just "turning it off".  I still need to use the Locale settings though.  Anyway!!! Execute this jquery on the edit user profile page ( I inserted it using a hook_form_alter):

(function($){
  $(document).ready(function(){
    $('#edit-timezone .fieldset-wrapper').toggle();
    $('#edit-timezone').addClass('collapsed');
  });
})(jQuery);


Try to use debug() to see the content of $vars. As far as I know, in views/themes/theme.inc there are many examples of preprocessing functions.


Drupal 7 Internationalization - why are my admin menus still in English?

If you swap from french to English the admin menu should also switch from french to English (Drupal 7).

In the tag "detection and selection" of Admin/Configuration/Regional and language/Languages" click the "Default" checkbox in order to use the default site language.

The "Localization update" module also helps you keep your interface translations for core and contributed modules up-to-date :

Enable the Locale (core) module
Download and enable the "Localization update" module
Go to the configuration page at admin/config/regional and language/translate interface/update
Wait as the module looks for translation updates
Click Refresh information button at the bottom of the page
Wait as the module gets all translations
Disable the Localization update module when finished to improve site performance.


How to determine which is the latest hook_update_N() function invoked in a Drupal 7 environment

It's in the system table. This query:

SELECT schema_version FROM system WHERE name='mymodule';

will let you know the last update hook successfully completed.

if you want to use drush, there's drush sql-query

drush sql-query "SELECT schema_version FROM system WHERE name='mymodule'"