How make surveys with many questions whose answers are very similar

I will suggest using Survey Builder module

Key Features

Create survey forms with a drag and drop interface
Re-use questions across surveys (can be disabled)
Respond to surveys
Aggregate responses to surveys with Views

There some other nice modules too, such us LimSurvey Sync or you can use webform together with webform builder which will save you a lot of time.


For the url_alias issue, I'd strongly recommend moving over to Pressflow which provides the path_alias_cache module along with support for it.

  Pressflow is a distribution of Drupal with integrated performance,
  scalability, availability, and testing enhancements.

I'd also recommend installing DB Tuner on your site to catch any missing indexes.


Have you tried using the Menu Block module (D7)?

Disable the main menu in the theme settings and create one or multiple menu blocks with a lot of options for the menus. The module can render submenu items with the main navigation and/or in a separate menu-block. The Menu block module can render a custom menu as well.

You can also add an extra region to your theme that renders a menu-block-menu inside a nav-tag:

yourtheme.info file add:

regions[nav_custom] = Nav Custom

In page.tpl.php add:

<?php if ($page['nav_custom']): ?>
    <nav id="nav-custom" role="navigation" class="navigation">
      <?php print render($page['nav_custom']); ?>
    </nav> <!-- /.section, /#nav-custom -->
<?php endif; ?>


drush qd still works fine with Drupal 8, provided that you are using the 8.x or master branch of Drush. In fact, I just used the latest Drush to download, install and open Drupal 8.1.1, and it worked like a charm.


Is it safe to use $_SESSION to store temporarily a user provided value under multi-step form processing

Drupal has an Ajax framework for this use case. Use $form_state to store values. The API page about the Ajax framework contains a use of $form_state.


Is there a module that displays a field only when a condition is met?

Have a look at the Field permissions module. It allows for role-based conditional display.


How to theme form elements in a custom field widget?

To add class to wrapper div of a form item you have to use the following theme function : theme_form_element

Copy and paste the entire theme_form_element function and rename the function with mytheme_form_element in your template.php and add your custom code like this (you may adjust to your own id) :

/* CUSTOM */
if (module_exists('mymodule')) {
  if (isset($element['#id']) && ($element['#id'] == 'phone' || $element['#id'] == 'ext' || $element['#id'] == 'primary')) {
    $attributes['class'][] = 'my-class';
  }
}
/* END CUSTOM */

It's always difficult to change the structure of forms because it's in theme function and for that you have to add conditions.


There are a few options you have when it comes to exporting data from Drupal 7. A few have been mentioned in this post. Hope this helps!

How to export/import all nodes of a specific content type?


EntityMalformedException in custom module. Can anyone see what I did wrong?

Please check Examples, specifically entity_example module to check how to define the bundle.

So for Drupal 7 it goes like:

/**
 * Implements hook_entity_info().
 *
 * This is the fundamental description of the entity.
 *
 * It provides a single entity with a single bundle and without revision
 * support.
 */
function entity_example_entity_info() {
  $info['entity_example_basic'] = array(
    // A human readable label to identify our entity.
    'label' => t('Example Basic Entity'),

    // The controller for our Entity, extending the Drupal core controller.
    'controller class' => 'EntityExampleBasicController',

    // The table for this entity defined in hook_schema()
    'base table' => 'entity_example_basic',

    // Returns the uri elements of an entity.
    'uri callback' => 'entity_example_basic_uri',

    // IF fieldable == FALSE, we can't attach fields.
    'fieldable' => TRUE,

    // entity_keys tells the controller what database fields are used for key
    // functions. It is not required if we don't have bundles or revisions.
    // Here we do not support a revision, so that entity key is omitted.
    'entity keys' => array(
      // The 'id' (basic_id here) is the unique id.
      'id' => 'basic_id' ,
      // Bundle will be determined by the 'bundle_type' field.
      'bundle' => 'bundle_type',
    ),
    'bundle keys' => array(
      'bundle' => 'bundle_type',
    ),

    // FALSE disables caching. Caching functionality is handled by Drupal core.
    'static cache' => TRUE,

    // Bundles are alternative groups of fields or configuration
    // associated with a base entity type.
    'bundles' => array(
      'first_example_bundle' => array(
        'label' => 'First example bundle',
        // 'admin' key is used by the Field UI to provide field and
        // display UI pages.
        'admin' => array(
          'path' => 'admin/structure/entity_example_basic/manage',
          'access arguments' => array('administer entity_example_basic entities'),
        ),
      ),
    ),
    // View modes allow entities to be displayed differently based on context.
    // As a demonstration we'll support "Tweaky", but we could have and support
    // multiple display modes.
    'view modes' => array(
      'tweaky' => array(
        'label' => t('Tweaky'),
        'custom settings' => FALSE,
      ),
    ),
  );

  return $info;
}

Or for simpler example, entity.api.php from Entity module which goes like:

function entity_crud_hook_entity_info() {
  $return = array(
    'entity_test' => array(
      'label' => t('Test Entity'),
      'entity class' => 'Entity',
      'controller class' => 'EntityAPIController',
      'base table' => 'entity_test',
      'module' => 'entity_test',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'pid',
        'name' => 'name',
        'bundle' => 'type',
      ),
      'bundles' => array(),
    ),
  );
  foreach (entity_test_get_types() as $name => $info) {
    $return['entity_test']['bundles'][$name] = array(
      'label' => $info['label'],
    );
  }
  return $return;
}

The error EntityMalformedException which you're having it's saying that your bundle property is malformed on save, so Drupal core can't identify what type (bundle) is that.

Troubleshooting:

Check what's the value of bundle in entity keys section of array defined in entity information array via:

drush eval 'print_r(entity_get_info("entity_type"));'

If it's type, then that means your entity which you're trying to save, it's missing type attribute.

The common mistake is usually to load the entity via entity_load() and trying to re-save it, but remember that return value is an array of entity objects indexed by their ids.

So the simple test to verify if your entity re-saving works correctly, it would be:

drush eval '$entity = entity_load("entity_type", array(1)); entity_get_controller("entity_type")->save(reset($entity))'

where entity_type is your entity_type and 1 is your entity id.


Why do functional tests require a running website?

You can theoretically run a functional test on a production website. (I am not saying you should though.)
In my experience the testing framework will install a new Drupal site for every individual test and in the end remove these sites. This is done by creating testing tables in your existing database, for which you need to provide the credentials in SIMPLETEST_DB.
As long as the tests do not error, all of this data will be cleaned up at the end of the test and you do not need to worry about anything.
If the test unexpectedly stops you might need to clean op some items manually (previously could be done with simepletest module, but I believe there are plans to remove that).
I have no idea if you can use a different site. You need to have database access to that site to install the testing tables. Modules should be available, etc. I do not think it would be reliable.


I can't install views module. Error Memory or infinite loop

There should not be any problem if there is 256M ram allocated. What i would suggest is clear your cache and install one module at a time. Like rather then installing the whole views list of module just install one by one. Another good option is to use drush to install modules but unfortunately you do not have ssh access.


Cache problem on entity view mode teaser

I ran into the same problem recently.
Adding a key to the ['#cache']['keys'] array as unique id solved my cache problem.
For your case it should be like this :

$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$vars['renderable_node'] = $view_builder->view($referenced_node, 'teaser');
$vars['renderable_node']['#cache']['keys'][] = "page_1";

On your second call to the teaser node then it should be like this :

$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$vars['renderable_node'] = $view_builder->view($referenced_node, 'teaser');
$vars['renderable_node']['#cache']['keys'][] = "page_2";


Delete the content of a field from all the node under a specific content type

Views Bulk Operations, using the "Modify entity values" action.


FacetAPI graph doesnt work with solrsearch it seems , I installed search api and was able to get all the options and fixed the problem .


CSS fix for stacked gear icons in Drupal Panels?

Here's the minified version of that same Javascript, from said coworker. :)

jQuery(function($){l=[];t=[];$('.contextual-links-wrapper').each(function(){h=$(this);o=h.offset();k=o.left;v=o.top;if($.inArray(k,l)>-1&&$.inArray(v,t)>-1){h.offset({top:v+=50})}l.push(k);t.push(v)})});


This requires that a node context get passed into the mini panel for it to know what node to pull the data from. Unfortunately there is no way to pass this context using blocks.

You can use page manager to create a node view page which has the correct node context and put the mini panel there.

You can create a view that has a default argument set to get the node id from the URL. Then create a pane display on this view. You can add this view to the mini panel and it will get the node info correctly so you can use blocks.


How do I change the default value for a filter?

you can try using hook_form_alter in your custom module.

     function yourmodule_name_form_alter(&$form,&$form_state,$form_id){
//print $form_id to get correct id of the exposed form
    if($form_id == 'views_exposed_form'){
      $form['field_program_tid']['#default_value'] = '44';
//you can unset "all" if you don't need it
      unset($form['field_width_value']['#options']['All']);

     }
    }


How to view "your own comments" without the permission view comments?

I think this kind of logic is better handled in a custom module instead of the theme layer. Something like this might work for you:

/**
 * Implements hook_permission().
 */
function mymodule_permission() {
  return array(
    'view own comments only' => array(
      'title' => t('View only own comments'),
      'description' => t('The user will not see comments made by other users.'),
      'warning' => t('Sometimes this might not work...'),
    ),
  );

}

/**
 * Implementation of hook_query_TAG_alter()
 */
function mymodule_query_comment_filter_alter(QueryAlterableInterface $query) {
  if (user_access('view own comments only') && !user_access('administer comments')) {
    $query->condition('c.uid', $GLOBALS['user']->uid);
  }
}

This defines a view own comments only permission. If this is set and the user does not have the administer comments permission, comments made by other users will be hidden on the node page.

There are a few problems with this solution (and you'll probably have the same problems if you are trying to do this in a template file):

comment count will not be modified
Recent comments block will not be modified


rules autotag module, bulk retagging existing nodes

According to this autotag issue on d.o, titled "How to re-tag all content":

  Use Views Bulk Operations (VBO).
  Create a bulk view with the 'Save post' operation
  In the view, select the nodes you want to re-autotag and execute (which will resave all the nodes)

Note the different autotag modules:

autotag uses your existing taxonomies, can be used with VBO.
rules autotag doesn't have the UI of autotag, it's possible to use this one with VBO as well.
autotagging uses 3rd party services


The 'React block'
module aims to add some more structure around React components and Redux state management in Drupal.

React blocks are defined by adding a simple YML file to your exising React component. This allows front end devlopers to create and manage React components as they normally would, and by including this YML file they can make the component available inside Drupal.


Sounds like the field collection module would fit your needs perfectly, however that doesn't have a Drupal 8 version yet so it's hard to know what the Drupal 8 site is using to do this.

For Drupal 8 there is a sandbox version of the field collection module however I'm not sure how stable it is.

Another possibility is that they have created a custom field for their site that is a combination of multiple elements.

If you want any sort of compatibility with the two sites' data the I would suggest asking them how they have implemented theirs and use that option for your Drupal 7 site.


When a node is created, automatically update data in a corresponding node

UPDATE:
The answer to this question is "Rules". I hadn't learned about them at the time. With a rule, you can choose to trigger on saving or updating new content and use conditions to limit it to the content type in question. For the action, choose "set a data value" and the relation between the two nodes should allow you to select the relevant field on the node you just created as the source, and the relevant field on the related node as the value to set.

Original answer:
I ended up writing a small custom module that implements hook_node_insert and hook_node_alter for visit nodes. It gets the nid of the related participant from the submission, gets it using node_load(), changes the relevant values, and saves it using node_save(). I still suspect there's a less kludgy solution, but this seems to work perfectly well.


HTTP Basic auth on specific Drupal paths?

I think you are looking for Sharing authentication with HTTP-Auth which describes using the Drupal user tables to supports Apaches http auth system. You will probably have to hard-code the paths in your menu, or within your page content. Then set up Apache to use http auth on the particular directories.

EDIT:

To use this technique in the Drupal environment, you would define http auth for individual directories in the apache Auth.conf file like:

<Directory /usr/local/webroot/d7.example.com/folder>
...Auth directives ...
</Directory>

where /usr/local/webroot/d7.example.com is your drupal root. This allows you to protect individual directories, while maintaining drupal authentication for your site.


Get custom block type image field in Display Suite twig field

{% set image_uri = block_content.field_feature_row_image['#items'].entity.uri.value %}

OR with a .0
{% set image_uri = block_content.field_feature_row_image.0['#items'].entity.uri.value %}

If not, try
{{ file_url(block_content.field_career_highlight_image.entity.fileuri) }}

If still no dice, then give this a shot. In /sites/default/settings.php add:
// Override default twig method whitelist.
$settings['twig_sandbox_whitelisted_methods'] = [
  // Defaults:
  'id',
  'label',
  'bundle',
  'get',
  '__toString',
  'toString',
  // Additions:
  'url',
];

and then in your field twig put
{{ block_content.field_career_highlight_image.url }}


What is the ideal way to restore a previous version of a site with Backup & Migrate files?

You can restore using backup & migrate itself.

If you've backup and downloaded the file, then you can use Restore tab (/admin/config/system/backup_migrate/restore) to upload the zipped file and restore.

If you've backed up to the Manual Backups Directory, then you can restore from the directory listing (/admin/config/system/backup_migrate/destination/list/files/manual).

There are Drush commands for the above as well, see drush help after you enabled backup & migrate module.


How to force Views (or whole Drupal) to lowercase page paths?

This is untested, but I believe you can use a hook_url_outbound_alter() for this, since I think Views URLs still get run through url() when they get generated:

function MYMODULE_url_outbound_alter(&$path, &$options, $original_path) {
  $path = drupal_strtolower($path);
}

(Updates to address some comments post acceptance.)

This should update URLs that get generated by Views, and will prevent the uppercased ones from getting out into the wild.

Drupal 7 is case-insensitive with regards to inbound URL routing.  However, I am not 100% sure this is always the case with Views arguments being pulled from the URL.  I suspect that the base part of the path w/o the argument is being matched by Drupal as case-insensitive, and the argument is matching case-insensitive because of database collation being case-insensive.


User registration with content profile + data manipulation on submit

I use hook_nodeapi() with the operation ID ($op) equal to "insert" (conditionally for the content profile content type) and then get at the user data with $account = user_load(array('uid' => $node->nid)).
Then, I do as I please with both the $node and $account data.


How can I import multiple taxonomy terms using Feeds and the Feeds XML Parser

Feeds Tamper will sort this out (I know this for a fact, as I've done this in the last week).

Set your query to hotel_facilities/facility which will return a comma separated list of facilities (you won't see this array as you'll be exploding it. Feel free to dpm() it though). Using Feeds Tamper, you can explode this array.

Go to your feed, and there will be a "Tamper" menu item at the top. If you click this, and then go down whatever xpathparser if importing these facilities. Then click Add plugin and find the explode plugin (you can find it under List)

Don't forget to set your Feeds mapping to Search taxonomy terms by: Term Name and check the "Auto create" checkbox.


What is wrong with this drupal 7 preprocess function to output a fields value into the body classes?

field_get_items return an array of field item so you need to do something like :

/**
 * Implements hook_preprocess_html().
 */
function cotyhouse_preprocess_html(&$vars){
  $node = menu_get_object('node');

  // Check if on an article node page
  if ($node->type == 'article') {

    // get field_title_color value
    $color = NULL;
    $field_items = field_get_items('node', $node, 'field_title_color');
    if ($field_items) {
      $first_item = reset($field_items);
      $color = $first_item['value'];
    }

    // Set class corresponding to color
    if ($color == 'black') {
      $vars['classes_array'][] = drupal_html_class('tblk');
    }
    if ($color == 'white') {
      $vars['classes_array'][] = drupal_html_class('twhi');
    }
    if ($color == 'white_shadow') {
      $vars['classes_array'][] = drupal_html_class('tsha');
    }
  }
}


Add html to wrap custom panels layout programaticly

The module suggested (in a comment) by Danny Englander helps me (thank you!).

I.e. module drupal.org/project/panels_extra_styles

Since Dany only posted it as a comment, I'm adding it as a "real" answer (so that I will also be abe to "mark it as accepted".


How to activate some flag field when create a content?

Consider using the Conditional Fields module. Excerpt from its project page:

Conditional Fields allows you to manage sets of dependencies between fields. When a field is “dependent”, it will only be available for editing and displayed if the state of the “dependee” field matches the right condition.
When editing a node (or any other entity type that supports fields, like users and categories), the dependent fields are dynamically modified with the States API.
You can, for example, define a custom “Article teaser" field that is shown only if a "Has teaser" checkbox is checked.


If you're using them in a form you could use this module to have much more control of your checkboxes tree and you will have different classes for parents and children:

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

Enable the Term Reference Tree module.
Go to the Manage Fields tab of any fieldable entity (such as a content type, taxonomy term, or user.
Add a new field with a type of Term Reference.
In the widget select box, select Term reference tree.


Allow user to completely delete account (and data), not just cancel it

I found it myself. It is under: Configuration-> Account Settings-> When cancelling a user account section.


How can I get a block to display only on node view in Drupal 6

In that case you need to to have node/*/view and node/* on separate lines.

Unless the node that users are customizing are a specific node type, then you should use the php code to check for a certain node type, regardless of node id or url.


How to make the name of an organic group unique

Assuming your og groups are based on node entities.

  You can have unique group titles with help of unique_field module.
  With help of this module you can set the title field as unique fields the content type generating groups on your site.


Given your description, the domain access module is the better way to go. Drupal multisites won't give you the capacity to have one main site and many smaller sub sites but that is the key feature of domain access:

  The Domain Access project is a suite of modules that provide tools for
  running a group of affiliated sites from one Drupal installation and a
  single shared database. The module allows you to share users, content,
  and configurations across a group of sites ...


Upgrading a site from Drupal 6 to 7 using Drush

You could use the Migrate module for this purpose.

  The migrate module provides a flexible framework for migrating content into Drupal from other sources (e.g., when converting a web site from another CMS to Drupal). Out-of-the-box, support for creating core Drupal objects such as nodes, users, files, terms, and comments are included - it can easily be extended for migrating other kinds of content. Content is imported and rolled back using a bundled web interface (Migrate UI module) or included Drush commands (strongly recommended).

For more details you could go through the README.txt of this module.


Interesting question. Here's how I'd do it.

Use Custom Tokens to create a custom token that runs the nid through md5();.
Use that custom token in Pathauto.


Save my link configuration with drush or else?

Block translation is difficult, as mentioned also in this interesting article about Successful multilingual sites in Drupal7.

Maybe you want to consider using the BEAN module combined with the Entity Translation module?

PS: How make your Drupal website multilingual is another related article.


if it's a form alter you should take a look at http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_form_alter/7

Also clear cache and look if you have enabled de módule.

Have you tray with a dpm('hello world') with devel module enabled?

oskar


How to use titles instead of IDs in urls for nodes?

You should check to see if the pathauto module is installed. If not, I highly recommend downloading, installing and enabling it... It should make very short work of this.

Here's the link for d6

https://www.drupal.org/node/17345/release?api_version%5B%5D=87

If it is already enabled... then you may have more trouble as the d6 version is no longer maintained... so you may need to do some troubleshooting of this module.


No need to modify template files. Instead create a view of Article content type and then follow the below steps.

Into view Header part add field Global: Result summary
Now into above field configuration, inside Display text area add @total token.


If you put the hierarchical structure into the path you could use a contextual filter to show the related programs in a view. The path would look like: programs/humanities/English

The contextual filter would look at the taxonomy term in position 2 and show related programs (other humanities programs in this example)


Is there a way to determine what styles can be used for a nice menu?

On the HTML tab of firebug there is a "break no mutate" button that will stop whatever javascript adds/changes HTML. This can be used to trap something that is a result of a nice menus change. It can be a little tricky as each hover initiates some javascript and then when you continue execution the break on mutate is turned off, but it gets easier with practice :)


How to change default query plugin for views?

Firstly you will need to have defined your query plugin to Views using hook_views_plugins():

function MYMODULE_views_plugins() {
  return array(
    'query' => array(
      'myplugin' => array(
        'title' => 'My custom plugin',
        'handler' => 'MyCustomQueryClass',
      ),
    ),
  );
}

Then, you should be able to override the query class used for any of the built-in tables using hook_views_data_alter() and setting the query class key in the table base property:

function MYMODULE_views_data_alter(&$data) {
    $data['node']['table']['base']['query class'] = 'myplugin';
}


The variables were being cached at some point in the hook_theme() function, so after reading the documentation on hook_theme(), I moved the logic to conditionally use different variables in to my hook_block_view() implementation, passing them in to the call to theme() at that point. So that function looks like the following:

function daily_hours_block_view($delta = '') {
  if (daily_hours_is_summer()) {
    $variables = daily_hours_get_summer_vars();
  } else {
    $variables = daily_hours_get_regular_vars();
  }
  switch ($delta) {
    case 'hours_table':
      $block['content'] = theme('todays_hours_table', $variables);
      break;
  }
  return $block;
}

And my hook_theme() function:

function daily_hours_theme() {
   $items =  array(
     'todays_hours_table' => array(
       'template' => 'hours_table',
       'variables' => array(
          // set default variables here
       )
     )
   );
   return $items;
 }

The cache setting in my hook_block_info() implementation did not seem to have an impact once I set up the logic in the hook_block_view() function.


Enabling aggregate and compress CSS files caused error on site access

I found this from http://drupal.org/node/782510

In your settings.php file, add

$conf['preprocess_css'] = CACHE_DISABLED;

Seemed to work for me on a quick test


Views renders the node entity using the default view mode (machine name 'full'). Drupal uses the node.tpl.php template to output the node. That template contains a condition to check for the $page variable. If that is false than it prints the title of the node as a link.

The are various solutions (such as using a different view mode or tinkering with node.tpl.php) but you can also clear the title using hook_node_view.

You can check if the node is the same as the one returned by menu_get_object. If that is not the case than the node is somehow embedded in another node or in a view (as is your case).

function MYMODULE_node_view($node, $view_mode, $langcode) {
  $page_node = menu_get_object();
  if ($node->nid != $page_node->nid) {
    $node->title = NULL;
  }
}

I havent experienced any bad side effects, yet.

See drupal.org for more info.


A form submission handler never returns a RedirectResponse object to redirect users. (It actually doesn't return any value.)

A form submission handler calls FormState::setRedirect(), or FormState::setRedirectUrl() which accepts a Url object, for example the value returned from Url::fromUri('//my_node_url_alias').


TLDR

Look for session.gc_maxlifetime and session.cookie_lifetime.

Inspect your session cookies with browser developer tools

To debug this, one can use browser developer tools to inspect cookie expire date.

The cookie that is relevant for login has a key = "SESS...".

An "Expire" of "Session" means that the cookie expires when the browser is closed. Most of the time this is not what you want!

You can open other Drupal sites (e.g. drupal.org) and compare the cookies. It can also be interesting to compare with other Drupal sites installed on the same server (e.g. your localhost), and with different browsers. This can give you clues whether this is a problem with your global server config or with your specific site.

Check current PHP config in Drupal

Open admin/reports/status/php for current phpinfo.
Look for session.cookie_lifetime and session.gc_maxlifetime.

A value of session.cookie_lifetime === 0 causes the Expire === Session for the session cookie. This means that closing the browser causes a logout. Otherwise, the number specifies seconds of login duration.

See http://php.net/manual/en/session.security.ini.php for more information.

Inspect your code and server config

ini_set() statements in your Drupal's sites/*/settings.php
Your .htaccess file.
Your server settings, e.g. in /etc/apache2/apache2.conf, or /etc/apache2/sites-enabled/... grep is your friend.

Also look for modules that modify login duration, such as https://www.drupal.org/project/autologout or https://www.drupal.org/project/autologout.

Fix.

Decide on suitable values for session.gc_maxlifetime and session.cookie_lifetime, and use one of the places mentioned above to set these values.

For the project I am working on, I decided to set both values to 1209600 === two weeks.
(2 * 7 * 24 * 60 * 60 seconds === 1209600 seconds)

About the values

For more information on these values, see

https://blogs.oracle.com/oswald/php:-sessiongcmaxlifetime-vs-sessioncookielifetime (note: the article says 60 = 1h, which afaik is wrong. 60 would be 60 seconds = one minute. For one hour it would have to be 60 * 60 = 3600.
http://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime
https://stackoverflow.com/questions/5511794/the-question-between-session-gc-maxlifetime-and-session-cookie-lifetime

From the information I found, and my understanding of it:

session.gc_maxlifetime is a server-side limit, but session.cookie_lifetime is a client-side limit.
Even when session.gc_maxlifetime has run out, there is a chance for the session to stay alive for a bit longer, because the garbage collection only happens every once in a while (depending on session.gc_probability and session.gc_divisor).
A browser or other client could ignore or override the cookie lifetime, and keep the session alive longer than intended. I assume the expire date is also stored on server side, so I assume this won't help. See https://superuser.com/questions/442218/automatically-override-cookie-expiration-on-chrome where this is being discussed.


ACL, Node, and User exists in DB, but still no access

The issue that I was having was that my module didn't correctly implement one of ACL's hooks, [module_name]_enabled().

Prior to returning the grants, acl_node_access_records() checks to see if the module is enabled by firing off that hook, and does nothing if it doesn't exist.


Modal Popup for Vimeo when clicking on Vimeo Thumbnail Link

You want to have a look at the video_embed_field module and the colorbox module.
They combine well to achieve what you want.

Create a contenttype with the new field provided by video_embed_field.
Then for the thumbs you could make a view and select the video_embed_field.
Go into settings of this video field and in the selectbox labeled Formatting tool, select thumbnails/w colorbox
This should give you a nice grid with thumbnails all linking to a colorbox overlay with player embedded.


Correct Syntax for $conf to populate Varnish Control Terminal

So, turns out, the list of hosts is not an array; this works:

$conf['varnish_control_terminal'] = '11.22.33.44:6082 22.33.44.55:6082';

Hopefully, it helps someone else.


How to redirect url in index.php?title=plip to a specific url like /my-page?

You should be able to make this work using the Rules module, as detailed below.
Looking at your path (= /index.php?title=plip) I would try to make the value (= plip) of the URL argument (= title) available as a new variable to the Rules module. To do so, you can use the Rules URL Argument module. Here is a quote about it (from its project page):

... provides two rules conditions based on URL arguments:

check if a URL argument is present.
compare the value of an URL argument.

It also provides an action that makes the value of an URL argument available as new variable to Rules.

The newly provided Rules actions and conditions can be found under the "URL Argument" conditions and actions groups in the rule configuration interface.
For an example of how to use it, refer to Comment # 3 in issue # 1686360 which is about "Pass an amount to the url, ie; site/content/node-title?amount=10 or /node-title?=amount:10". Here is the relevant part of it:

add a "Check if URL argument exist" condition to your rule and set the "ARGUMENT" value to "amount".
add "Provide URL argument value" action to the rule and set "URL ARGUMENT NAME" value to "amount" and in the "Provided variables" section "ARGUMENT FROM URL - Variable name" to e.g. "amount_from_url".

You will now be able to use the amount value as a variable "amount-from-url" for other actions in this rule.


Create a Rules link to update a field in a submitted webform

Have a look at what's asked for in the feature request "Expose submission data to rules", status is "Needs review". Here is a summary of it:

  Right now, submission data is not exposed to rules except by way of token replacement or custom php actions. This patch exposes submission data in a "first-class" way.

So if submission data are not even exposed yet (in the current version of Rules), then it might not be obvious (if possible at all) to update such data.

Possible alternative

I'd rather try to come up with some kind of alternative for such hidden field to "record the clicking of such link" (also using the Rules Link module). A possible alternative is to use the Message module to create a message like so:

Date = date the link was clicked.
User target = the user who clicked the link.
Message type = something like "Webform processed via Rules link").
message text = whatever you want and possibly using "Replacement tokens" to have any of the available webform tokens available in your rule included in your message text also.

Since messages are entities, you could add any additional fields you may need to complete such custom logging.


How do I move a group of nodes to another Drupal instance?

What would suit you is the Deploy module: https://www.drupal.org/project/deploy

The README.txt states:

The Deploy module is used to deploy Drupal content to other Drupal sites or arbitrary systems. Two concrete use cases are:

using it as a content staging solution
using it to push content downstream from a main site to several sub sites.

Here's a demo:
https://www.youtube.com/watch?v=7PjwT0HWHxw


Use 2 different font sizes on combobox form elements

If it's possible in HTML & CSS flavour you are using, it is. There are two ways:

Purely CSS one, described at w3schools and not really belonging to this site as it's Drupal independent.
Class way - to get more flexibility and compatibility, add classes to your <option> tags inside your <select>. You can do this implementing theme_select() in your theme. You would need to replace form_select_options() with your own function providing similar functionality, or parse original one's output to add your classes.


Which kind of views style to use JS image effect?

Try using Views Fluid Grid - jQuery Masonry module.


FAPI 'radios' don't respect '#default_value'?

Your code works fine at my end, I always get "first" selected on repeated page refresh. Can you copy paste your actual code that is showing different value for comment settings? Maybe something else is interfering. Can you paste your code at one of the pastebins - http://pastebin.com/ ?

Below is a screenshot at my end.


What is the access record "content_access: all"? This is overriding my taxonomy access module

The access record you are seeing could be the default access that Drupal uses and that, as far as I can say looking at the code, is only used when no module implements node access rights.
node_access_rebuild() and node_access_acquire_grants() both add that access record if no module implements any node access hook, or no module returns any access record.

function node_access_rebuild($batch_mode = FALSE) {
  db_query("DELETE FROM {node_access}");
  // Only recalculate if the site is using a node_access module.
  if (count(module_implements('node_grants'))) {
    // …
  else {
    // Not using any node_access modules. Add the default grant.
    db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)");
  }

  if (!isset($batch)) {
    drupal_set_message(t('Content permissions have been rebuilt.'));
    node_access_needs_rebuild(FALSE);
    cache_clear_all();
  }
}

I would not suggest to remove that access record from the node access table, otherwise users without specific permissions would not be able to view any node for which a module doesn't have a node access record. In Drupal, it is default to deny the access to a node; in fact, the node module writes in the node access table only the records that allow to access a node.

Update: As you reported that you are using also Content Access, you could be interested in this issue report: Do not hijack the 'all' realm.
The access record you are noticing is probably the record added by Content Access; the short name of the module is content_access, and it is probable the module is using that as grant realm.

  I think that I have to give people access to see pages by default and then take it away if taxonomy is assigned.

As Drupal node access works, the access is denied by default, and it is granted for nodes for which a module grants it; it is exactly the opposite of what you are doing.
Access is still allowed for users who have specific permissions, which in Drupal 6 means users with the administer nodes permission, and is not allowed for users without a specific permission, which in Drupal 6 means users without the access content permission.


How can I create a panel/page/view that shows a list of nodes, and on the other side of the screen details about that node?

I don't know of any Drupal Contrib Master-Detail views modules. Views Megarow comes close, so check it out.

You can use Panels and Page Manager (part of CTools) if you don't mind a page reload to update the detail view.

To start, install Panels, Page Manager (part of CTools), and Views content panes (part of CTools).
Select a path that you want your master-detail view on: I choose detail-view for this example.
Create a view that lists your content titles (master display only). Add field nid to this view, set its display to none, and move it to above title field. Alter title field settings by removing 'link this field to the original piece of content', and rewrite results on this title field by selecting 'Output this field as a link', and enter detail-display/[nid]

Create a second view similar to first (view of nodes, master display). Add a 'Content Pane' display to this view. As this view will display fields for a single node only, add the fields you want to display. Then add a contextual filter of nid, and hide the content when the filter is not available. Now comes the important part. Click on 'Edit' next to 'Argument input' in the middle pane of the views UI.  Select 'From Panel Argument' for the list box 'Content: Nid Source', then select 'First' from Panel argument.

Add a custom page (admin/structure/pages/add). Add your desired path (ie detail-display). Select Panel as the variant. Next screen of wizard choose a two-column layout.
When you get to the UI page where you select the content for the left and right side, do this.

a. For left panel, select 'Add content'. Select 'View Panes', and select the view pane that you created first (ie the one that lists all the titles).

b. For the right panel, select 'Add content', then select 'View Panes', and select the view pane that you created second (ie the one that lists detail for one node only).

Update and save the panel, and you are good to go.


Getting Drupal 8 to use an external index?

What you could do is use the Migrate module to migrate content from one site to the other. What you need to do is:

Build a custom source plugin for it so that it fetches its data from an external source (i.e. the other site) and map it to a content type in your Drupal install.
Then set up a cron job to run the migration periodically to update the data on your end. Make sure you set the migration to "update" since by default, migrations won't happen on already-migrated content.
Create your search however you want in your site (Views, Search API, etc.) using that content type.

In D7, this was a job for the Feeds module but they don't appear to have a D8 version yet.


Preventing frequently updated nodes from keeping them on the top of View

Not possible using views out of the box! Because updated date is stored as a single value in the database. If a user updates again the new value overrides old value.

So, there is no way views can track within one week after their last update even if they update it again .

You need to use hook_nodeapi either to track all updates in separate table and query that table to list users.


Correct way to render fields from query in tpl?

Personally, I would create an Entity View Mode for the content type with the fields arranged and formatted how I want them, then you can simply do:

$node = node_load($nid);
$node_view = node_view($node);
print drupal_render($node_view);

In your case, you need multiple nodes, so:

$views = node_view_multiple($nids, "name of entity view mode");
print drupal_render($views);

Now that you are using an entity view mode, you can give the markup you want in the node--node_type--view_mode.tpl.php file, and it will use that.

As for the query and dynamic code, it should go in a preprocess hook, and not the tpl itself. You can return it as a $variable to the template being rendered, usually this is a page callback.

Again, I don't know much about your module or where this code is. You could enable Entity View Modes and just shift this code and get rid of it, and leverage Views instead for the same exact result.


How to delete true orphaned taxonomy terms

I wouldn't advise doing that - taxonomy terms are entities and need to be cleaned up with taxonomy_term_delete(). Otherwise you'll potentially leave a lot of orphaned data in field tables/contrib module tables/etc.

However, if you know your DELETE query will get you the correct terms, just convert it to a SELECT and you can do things the proper way:

$tids = db_query('SELECT tid FROM taxonomy_term_hierarchy WHERE parent NOT IN (SELECT tid FROM taxonomy_term_hierarchy)')->fetchCol();

foreach ($tids as $tid) {
  taxonomy_term_delete($tid);
}

Be wary that you don't delete top-level terms that have a parent of 0, since that record will not appear in your sub-query. It'll probably need a bit more thought, but the above code won't be too far off what you end up using.


How do I display a modal dialog on page load, with working title and dialog options, using OpenModalDialogCommand?

It turns out the code above was working fine -- the problem was that the site was using a Bootstrap subtheme, and Bootstrap was configured to override the standard dialog behavior. Turning off Bootstrap's dialogs solved the problem, enabling both width and title settings.


How exactly do I create a variation of a .tpl file?

If you are trying to override panel page template then I am afraid you are using the wrong hook, hook_preprocess_node works for node pages only.

However panel page goes through hook_preprocess_page, so you can add custom template suggestion in following way.

/**
 * Implements template_preprocess_page().
 */
 function MODULEORTHEMENAME_preprocess_page(&$variables) {
    if (module_exists('page_manager') && count(page_manager_get_current_page())) {
        $variables['theme_hook_suggestions'][] = 'custom__panel';
    }
 }

Then create custom-panel.tpl.php

Reference:
page.tpl.php override for Panels Pages?


How to theme multiple entities on the same page?

After a bit more fiddling, this worked for me. I've tried a similar approach earlier, but I guess there was something wrong. I've commented out the field functions, but these are the places in case you need them.

$entities = // Array of entities keyed by id;

// Prepare all entities at once. Attach fields if desired.
//field_attach_prepare_view('entity_type', $entities, 'full');
entity_prepare_view('entity_type', $entities);

// Expose all entities individual to hook_theme.
foreach($entities as $key => $entity) {
  $entity->content = array();
  //$entity->content += field_attach_view('entity_type', $entity, 'full');
  $entity->content += array(
    '#theme'     => 'entity_type',
    '#element'   => $entity,
    '#view_mode' => 'full',
    '#language'  => LANGUAGE_NONE,
  );
  $entities[$key] = $entity->content;
}

return $entities;


I'd suggest an approach which is not a solid, but you can get an idea;

Create modal with Ctools (may be this and this links can
help you to create it);
On form submission store the submitted data as array into $_SESSION;
reload the page with ctools_ajax_command_reload();

example:

// This is must be in ctools modal callback. Read modal.html file in ctools/help directory
if (!empty($form_state['executed'])) {
  $commands = array();
  $commands[] = ctools_ajax_command_reload();
}

Alter the content add form;
add #default_value to the fields, e.g.: '#default_value' => isset($_SESSION['modal_data']['field_1_value']) ? $_SESSION['modal_data']['field_1_value'] : '';
at the end of the content add form just unset the $_SESSION data, e.g.: unset($_SESSION['modal_data']);


Rendering a nested Paragraph's field using Twig

For nested / referenced paragraph rendering, it's probably best to use a separate template as you theorized above by stating "Do we need to (as a guess) create a separate template for the nested paragraph template?"
A general rule of thumb for Twig rendering is, if you are starting to dig that far down in a render array in a given template, best to use the next template inline in the chain.
in addition, In Drupal 8 Paragraphs, there is a nice API function for referenced paragraphs called getParentEntity().
  public function getParentEntity();

  /**
   * Set the parent entity of the paragraph.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $parent
   *   The parent entity.
   * @param string $parent_field_name
   *   The parent field name.
   *
   * @return $this
   */

I wrote a blog post dedicated to that here: https://www.dannyenglander.com/blog/drupal-8-architecture-how-to-get-a-value-from-a-paragraphs-parent-entity/
The bottom line is, you will look at Twig template debugging and see the referenced paragraph template suggestion in the output. Then you can use that template with some preprocessing to pull any data you need from the parent paragraph entity. A common use case for this might be some kind of setting like a boolean in the parent entity that you need to pass to the referenced paragraph entity / template.


Use Condition in Computed Field with Field Collections

Try the following and let me know how you go.

if($collection->field_type->value() == 'Z') {
  $sum += $collection->field_amount->value();
}


Enable module Path. it is provided in Drupal core.
If you want automatically generate url aliases for new nodes - install Pathauto

  The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.


Apply only database updates for a single module

Drush allows you to just update a module you specify:

drush up module_machine_name

If you just want to apply pending database updates, for the modules that have already been updated:

drush updatedb

This case is relevant when updating the code base through git, or for multisite installations.
In your specific case, this might be what you were looking for - just apply database updates (using this command: for all modules that require database updates), but don't update any additional codebase.

If you want to just apply the updates for a certain module, you can do this also manually. The updates can be found in the module.install file:

function modulename_update_prioritynumber
(e.g. devel_update_7000)

The priority number determines the order of the updates to be applied.
You can manually execute the code for the updates using drush:

drush eval "the update code"

for example:

drush eval "variable_del('dev_query');
drush @yoursite eval "variable_del('dev_query');

(@yoursite added if bootstrapping is needed for multisite installations)

This example will delete the variable dev_query from the variable database table (from the function devel_update_7002).

For more discussion on this, see: drush updatedb for a single module - especially the answer from moshe weitzman, the drush maintainer, about applying individual updates. I'd recommend applying the updates of the module you are concerned about over uncommenting the updatedb statements in other modules - as the other answer suggests.


I want download window appear instead of showing my mp4 file

You can do this using htaccess, Open your .htaccess file and add the following...

<FilesMatch "\.(mp4)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

This should force the browser to do a left click download, rather than play the content. You can do it for multiple files types as well. After the mp4 just add |mp3, so it would look like <FilesMatch “.(?i:(mp4|mp3|pdf))$”>


How do I programmatically change a system message?

I was seeking a similar solution and found this great post describing using a hook_preprocess_HOOK(), in this case, hook_preprocess_status_messages() - https://stackoverflow.com/questions/38788080/remove-default-message-in-drupal-8

For my purpose to override a message, I use a simple strpos in the logic:

/**
 * Implements hook_preprocess_HOOK().
 *
 * @param $variables
 */
function mymodule_preprocess_status_messages(&$variables) {
  if(isset($variables['message_list']['status'])){
    $status_messages = $variables['message_list']['status'];
    foreach($status_messages as $delta => $message) {
      if (strpos((string) $message, 'The message that I am expecting') !== FALSE) {
        $variables['message_list']['status'][$delta] = "Some different message text";
      }
    }
  }
}


Difference between APC & Memcached and how both can be used for cache bins

APCu
Does not share the cache with other servers but is faster.

Memcached
Can be shared with other servers and is slower.

If you have 2 or more web servers (apache/nginx) for the same Drupal site you'll want Memcached. If you are running on a single machine then APCu will be the quickest. You'll want OPcache turned on no matter what.

LCache is a module designed to fix the issues with using APCu in a 2 or more web server environment.


This problem arises because the Ubercart Catalog takes over the display of the taxonomy term pages for the Catalog vocabulary, as well as creating its own set of URL aliases for the Catalog terms.

I solved this problem quite simply, by disabling Ubercart's Catalog module and deleting all the aliases for the Catalog terms (as opposed to the Catalog taxonomy terms).

To achieve this, I had to:

create a new view that mimicked the the Catalog
ensure that the Catalog term pages used my new view. There are various ways to do this in Drupal including overriding the taxonomy default view, enabling a module like TVI, and Panels. I prefer Panels, so that's the route I took.
Optional - replace the Catalog block (which is useful as a sidebar menu for your Ubercart store). I did this using Taxonomy Menu and Menu Block.
Deleting all the aliases for the Catalog and Catalog Taxonomy, and bulk regenerating the Catalog Taxonomy aliases.

In the end, my site looked the same as it did before, but I no longer have the duplicate URL problem, and I'm no longer tied to the rather awkward Catalog module in Ubercart.


Add class to top-level ul using menu_block

Here's the trick: theme_menu_tree__MENU_NAME() and theme_menu_link().

<?php
/**
 * Implements theme_menu_tree().
 */
function THEMENAME_menu_tree__MENU_NAME(&$variables) {
  return '
' . $variables['tree'] . '
';
}

/**
 * Implements theme_menu_link().
 */
function THEMENAME_menu_link__MENU_NAME(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    // Wrap in dropdown-menu.
    unset($element['#below']['#theme_wrappers']);
    $sub_menu = '
' . drupal_render($element['#below']) . '
';
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '
' . $output . $sub_menu . "
\n";
}
?>


How do I include JavaScript with assets (libraries.yml)?

Most times it's about blanks. The yml files are very picky about this. Looks like your effects.js has 6 blanks instead of four.

And make sure, that you have your global-styling listed in the libraries section of your theme.info.yml.


Looking at the code of the PHP filter:

class Php extends FilterBase {

  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode) {
    $result = new FilterProcessResult(php_eval($text));
    $result->setCacheMaxAge(0);
    return $result;
  }

https://git.drupalcode.org/project/php/blob/8.x-1.x/src/Plugin/Filter/Php.php

it sets already a cache max age of 0, so you only need to remove the page cache for anonymous users by uninstalling the module "Internal Page Cache".


How to disallow one domain path in robots.txt without any modules?

I don't have enough reputation to comment, so I'll just throw this out:

You can test the user agent and the URL in settings.php. Then, if it matches the crawler bot and the /path1/* criteria, you  could do a 301 Permanent Redirect for that URL within your settings.php file. Here is how:

  header('HTTP/1.0 301 Moved Permanently');
  header('Location: ' . $base_url . $redirect_path );
  exit();

where $base_url is "Twodomain" and $redirect_path is "/path1/URLfromtest"


How to check if a node has a photo/video to use as an exposed filter in views?

You should be able to add the photo field or fields as filters and set their criteria to "not empty". Then, only those records with a photo should be visible. The same applies for the video field.


Advaced forum area going off-page in firefox browser?

The issue that a contextual link is causing your page to break. Please note that this issue only occurs for users that have permissions to modify panels, so your end users (visitors) should not see this.

The solution could be to disable the contextual link on the panel. Or disable the contextual links module entirely (what would remove the gear icon everywhere).

To disable contextual links only on some pages you might want to look at this question for how to disable a specific link: Is it possible to remove the contextual link for deleting a node?

Or you could try the Hide Contextual Links module.

UPDATE:

The main cause of this issue is a firefox bug, where outlines are drawn around descendant elements: https://bugzilla.mozilla.org/show_bug.cgi?id=687311

You can see it asked here on stackoverflow: https://stackoverflow.com/questions/10662902/css-outline-different-behavior-behavior-on-webkit-gecko, where the recommended action is to replace the outline with a box-shadow (no dashes), or the alternative to append overflow: hidden to the element. I tried with overflow: hidden and that worked so I'd try that first to keep the dashed line.

In Drupal, in you theme's css add:

.contextual-links-region-active {
  /* Override the old outline */
  outline: none !important;

  box-shadow: 0px 0px 0px 1px #FFF;
  /* OR */
  overflow: hidden;
}

But once again, this is a firefox bug that is likely to influence only administrators who have permissions to modify panels (I have no idea about the company you are building this for, but that cannot be many users). So ask yourself if it is worth putting effort into this.

UPDATE-2: by@codenext,

As @Neograph734 has provided the very nice research on this issue in above UPDATE(basically it is FIREFOX BUG). Please follow the following comments and question details to understand the issue. I am just providing the final solution as final solution is just the extension of this answer.

SOLUTION: The main issue is, the outline(left part) of the contextual-link-region goes off the page as shown in the second image above(a dashed line area), and along with that it takes the page-border/outline css off the page too. Hence we can put the overflow:hidden; in the #page/#content-column selector(as in my case, I have put border: and outline: css in these selectors) instead of putting it in .contextual-links-region. Hence, this way you can prevent the displacement of page-border and outline which caused the .contextua-links-region(originally the firefox bug).


In Drupal 8, private file permissions by default are given according to the entity to which they are attached. If the user has permission to view the entity, they will have permission to view the file.

If you are not attaching the file to an entity, then you will need to implement hook_file_download(), where you will determine whether or not the user has permission to access the file, and return a value accordingly. Currently, because you have no implemented this, access is denied by default.

Note that this hook can be implemented even when the file is attached to an entity to provide additional access checks and/or additional headers.


Use webform submission id in custom content type

You're right - you can't use references with the webform submissions, because webform submissions are stored in their own special way - they're not actually proper Drupal entities, so they are not properly exposed to other modules expecting to interact with entities.

One thing you can try if you're not too far along in your project is to use the alternative Entityform project.  That should expose form submissions to be referenced.

Let us know if it works!  I haven't used the module myself, I've just heard of it.


I've never had any problems just replacing images.

If there are any images that have image styles applied then don't forget to clear the image styles caches/files so they get regenerated as well.  You can do them all at once with Image style flush

tl;dr:

Should be fine so long as the filenames match.


Avoid reattaching javascript when a form is rebuilt by ajax callback

As Clive mentioned, the usual way to solve this is to use once() when attaching behaviors:

Drupal.behaviors.myBehavior = {
  attach: function (context, serverSettings) {
    $('elementSelector', context).once('myId', function () {
      // The code that will be executed only once.
    });
  }
};

Also, check the official docs on Managing JavaScript in Drupal 7.


Commerce module: Why this commerce_order_ui_form_commerce_order_ui_order_form_alter won't work?

I'm guessing by your rep that you already know most of the following but it pays to check:

Hooks can only exist once per module
Hooks must begin with the module name

So this means commerce_order_ui_form_commerce_order_ui_order_form_alter(&$form, &$form_state) won't work inside username_check.module

If you really want to put the code inside the username_check module call it:

username_check_form_commerce_order_ui_order_form_alter(&$form, &$form_state)

[edit:]

Of course, you shouldn't put test code inside an existing module.  The best way to test code is to make your own custom module, which is pretty easy once you get the hang of it.


How do I construct a thin controller with a dependent service?

ContainerInjectionInterface is used as a part of a static factory method pattern.

This way, a class's constructor can specify all of the services it needs, and its factory method, in this case create(), can satisfy the constructor by retrieving services from the container.

The instantiated controller should never have its own copy of the container, if at all avoidable.

A brief example:

<?php

namespace Drupal\book\Controller;

use Drupal\book\BookManager;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class BookController extends ControllerBase implements ContainerInjectionInterface {
  protected $bookManager;

  public function __construct(BookManager $bookManager) {
    $this->bookManager = $bookManager;
  }

  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('book.manager')
    );
  }

  public function bookRender() {
    $book_list = array();
    foreach ($this->bookManager->getAllBooks() as $book) {
      $book_list[] = l($book['title'], $book['href'], $book['options']);
    }
    return array(
      '#theme' => 'item_list',
      '#items' => $book_list,
    );
  }
}

This would be declared as a controller in a routing file like this:

_content: \Drupal\book\Controller\BookController::bookRender


Is there something equivalent to template_preprocess_search_results()?

You can create a new module and inside your YOUR_MODULE.module file put this code:

function YOUR_MODULE_preprocess_item_list__search_results(&$variables) {
  //to use dpm() you nedd the devel module
  dpm($variables['items']);
}

Install your module and you will see the output in the search result


Moved one site to another site files are refering old site

First clear all caches. If that does not resolve the issue check your settings.php file(s) for references to the old address.

If you have images in content you can search the database tables for those fields to look for references (but fix them through Drupal's interface). Unless you have a huge number your better off fixing those one by one. Generally in D7 and before you want site or page relative image references not absolute references.


Message - Item already in cart (commerce)

<?php
/**
 * Implements hook_form_FORMID_alter().
 */
function mymodule_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {
  $product_ids = mymodule_get_products_in_cart();

  $line_item = $form_state['line_item'];
  $product = commerce_product_load($line_item->commerce_product[LANGUAGE_NONE][0]['product_id']);
  if ($product->type == 'program') {
    if (in_array($product->product_id, $product_ids)) {
      // Product is already in cart! We only want to allow a quantity of 1,
      // so disable the submit button and change its text accordingly
      $form['submit']['#disabled'] = TRUE;
      $form['submit']['#value'] = t('Already in cart');
    }
  }
}

/**
 * Return the product_id values for all products in the cart
 *
 * @return
 *  An array of product ids
 */
function mymodule_get_products_in_cart() {
  $product_ids = &drupal_static(__FUNCTION__);

  if (!isset($product_ids)) {
    global $user;
    $product_ids = array();
    $order = commerce_cart_order_load($user->uid);
    if ($order) {
      $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
      foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
        $product_wrapper = $line_item_wrapper->commerce_product;
        $product_ids[] = $product_wrapper->product_id->value();
      }
    }
  }

  return array_unique($product_ids);
}
?>


Changing default file permissions for group?

I don't believe Drupal or Omega will be setting the default permissions to 754, more likely it's a default that your webhost has configured.  Things I would check would be:

If you upload a file as ftpuser, does it default to 754?  If so, then they have a default permission set to 754.  You could contact the host to see if they are able to change that.
If you manually create a file using PHP, does the file get created at 754? If so, same as above.
If they're created at something other than 754, then it's likely Omega or Drupal that is doing that, but again I don't believe that's the case.

In any event, I've successfully gotten around this problem for many users by integrating a web-based file manager like IMCE, which allows you to manage files without using FTP.


Can I use a contextual filter to remove content?

Regular Filter
You can add the regular Filter for the Taxonomy term Entity Reference field, select the Is none of under Operator, and then click to select "talk" from the terms list.
Contextual filter
You can also use the Exclude option in the Contextual filter for the ER field. I would use this option only if I needed the filter to be Contextual for some reason, if I needed options that come with it, otherwise just use the regular filter.

Add the Contextual filter for your Taxonomy term Entity Reference field, and configure it with these options:
When the filter value is NOT available
Provide default value
Fixed
[Taxonomy term ID for "talk"]
When the filter value IS available or a default is provided
Specify validation criteria
Taxonomy term ID
[Your Vocabulary]
More
Exclude

Check your results to see if the content tagged with "talk" is removed.
Enter all into Views Preview field to bypass the Contextual and check if the "talk" nodes come back (be careful if you have more than one Contextual filter, you may need to provide more than one argument for Views to show results).


Converting seconds to date with Facet API

So it sounds like the issue is you need to convert a UNIX timestamp to a human-readable datetime?  PHP comes with the date() function which can handle this.

The first argument is the 'format' which you can find here: http://php.net/manual/en/function.date.php.

The second argument is the UNIX timestamp--just simply pass in the timestamp variable (the # of seconds) as the second argument.


Allowing role permissions to a content type based on the date

You can implement hook_node_access() (This is now a real hook in Drupal 7) and implement whatever you want.


Loop through the myValues (only use the foreach if you are not already in a for loop) and use the appropriate array element:

foreach($myValues as $index => $name) {
  $form['names_fieldset']['name'][$index] = array( // Already using $i here. Are you in a for loop?
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $name, // Or $myValues[$i]['name'] if you are already in a for loop (it looks like you might be).
  );
}

Depending on the structure of the array you may have to change this a little. If these don't work and you can't figure it out, add a print out of one of your smaller arrays using print_r to your question and we can help.


This is your current query as it's executed:

SELECT
FROM
{pricepackages} pricepackages

Which is obviously wrong; an SQL SELECT query needs one or more fields. To SELECT *:

$query = db_select('pricepackages')->fields('pricepackages')->execute();

Or specific fields:

$fields = array('foo', 'bar');
$query = db_select('pricepackages')->fields('pricepackages', $fields)->execute();


You could do this easier in your .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteRule $ / [R=302,L]

Put this at the bottom of your .htaccess file and you're set.


Site re-directs to login page even after a successfull login

This behavior is normal

The default front page of Drupal is this one. It displays the latest published and promoted nodes. If you want to put another node as a front page you can do it in configuration>site information

Also drupal assumes that your site is in the top level directory (e.g. yourserver:port/)
If you want to change it to yourserver:port/custompath/ then set the $base_url to custompath in your settings.php file


Views all data export included image name/path

You can achieve that using the Views data export  module.

  This module is designed to provide a way to export large amounts of
  data from views. It provides a display plugin that can rendered
  progressively in a batch. Style plugins are included that support
  exporting in the following types:

  CSV
  Microsoft
  XLS
  Microsoft DOC
  Basic TXT
  XML.


Can I autopopulate between different users' forms with Rules and Webforms or EntityForms?

If I were to approach the problem, each project would be a node.

First install the Field Collection (documentation) and Field Permission modules.
Create a new Content Type (admin/structure/types/add) and call it Project.
Assign the fields you want filled in (admin/structure/types/manage/project/fields).
Add an additional field called Project Status of type "Field Collection" and choose "Embedded" as the widget type. Click save, leave Hide blank items checked on the next page, then click save again.
Go to the Field Collections page (admin/structure/field-collections). You'll see your new Project Status field listed. Click "Manage fields" and add your subform fields here.
At this point, your manager should be able to create new Project nodes, and the Project Status field will hold the additional information. You'll need to set up the field permissions so that the staffer role can only edit the Project Status field.

Back on your node fields page (admin/structure/types/manage/project/fields) edit each field. Near the bottom of each field's settings, look for the Field visibility and permissions section. Choose the Custom permissions radio button and look at the settings available. For your project, you want to allow your staffer role the ability to edit anyone's value for the Project Status field, but none of the other fields.
Remember to also set permissions to allow the manager role to create Project nodes, and the staffer role to edit Project nodes (admin/people/permissions#module-node).

As an added bonus, you can set the field settings for the Project Status field to allow an unlimited number of values. This would allow for updated status as the project progresses. YMMV of course.


Querying the user list from the database

If you're set on scraping this out of the database, you could try looking at the user__roles table that Kevin mentioned in his comment above:

mysql> SELECT * FROM user__roles;
+--------+---------+-----------+-------------+----------+-------+-----------------+
| bundle | deleted | entity_id | revision_id | langcode | delta | roles_target_id |
+--------+---------+-----------+-------------+----------+-------+-----------------+
| user   |       0 |         1 |           1 | en       |     0 | administrator   |
+--------+---------+-----------+-------------+----------+-------+-----------------+
1 row in set (0.00 sec)

But since this is Drupal, you have other methods at your disposal.

For example, you could create a View of users and roles, and then use Views Data Export to export.

This module also exposes a drush command that can execute the view (interactively, or via scheduled jobs from the system crontab) and save its results to a file.

drush views-data-export [view-name] [display-id] [output-file]


Field in Custom Content Type Stripping out  tags

A custom field doesn't have the same attributes as the standard body area.

Another approach would be to add a second field for the image and separate the two types at the content entry stage. You can combine them using Views. You could hide the first field and then rewrite the second field to display them together. A possible problem here is that the image will appear at the beginning or end of the copy -- float the image to have the text wrap around it -- but you won't have an option to place anywhere else.


How to add a 2nd submit button to a node form?

The following code does create a 2nd submit button.

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

  $form['actions']['submit2'] = array(
    '#type' => 'submit',
    '#value' => t('Save & View'),
    '#access' => TRUE,
    '#submit' => array('node_form_submit'),
    '#weight' => -10,
  );
}

But since we want it on the top of the form, it's better to put it outside the 'actions' group. So the following code puts it just below the title, ready for styling:

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

  $form['submit2'] = array(
    '#type' => 'submit',
    '#value' => t('Save & View'),
    '#access' => TRUE,
    '#submit' => array('node_form_submit'),
    '#weight' => -10,
  );


Spam users on drupal7 site being created automatically

How to prevent it from happening you already know:

Anti-spam tools like Mollom
Captcha

For mass deletion, use Views to list them:

Create a new users view (add new view, show: "Users"),
add relationships you feel will be helpful to identify spammers, like "User: Content authored".
add filters based on these relationships, like

Created unreasonably high amount of content or no content at all,
only users with account younger than the spam wave,
et cetera;

use VBO to actually delete unwanted ones - just check them, or use select all and uncheck good guys. Of course good filters will reduce number of good gu


In view, $content is null when show: fields

It is possible that you don't override the correct template. For the reference see here: Views template files.

There are several different approaches possible, depending of your requirements.

The usual way is to change the output of each field individually, using the field specific override. Access to the raw value and the already rendered content is straight forward using the provided variables. It's very difficult to break something here.
Another way is to use a row specific override. Following this approach it is your responsible to assure to output all fields in the result set for each row. In exchange this can be much more flexible regarding the created markup structure, because it's entirely up to you,

You could go even higher up the abstraction road, but the use cases for that are becoming incredibly scarce. So the odds are your simply in the wrong template.

Also, just in case you don't know that, there is an overview for the available and the used template files in the Views UI. In Drupal 7 and Views 3 it is in the outer right block the last link on the bottom:


Ok First off all Installing drupal TCPDF module is not enough to have working pdf-s. We are also obligated to download TCPDF libray from http //www.tcpdf.org/ and place it to drupal files so that library will be avaible like this

  C:\xampp\htdocs\drupalac_gw\sites\all\libraries\tcpdf\tcpdf.php

above will solve:

  Fatal error: Call to a member function DrupalInitialize()

With working pdf library sending emails with attachments is easy i have like this:

drupal_mail('module', 'notice', "to@mail","", array(), "from@mail");

where:

function module_mail($key, &$message, $params) {
  $attachment = array(
    'filecontent' => generatePdf("S"),
    'filename' => 'example-filename',
    'filemime' => 'application/pdf',
  );

  switch($key) {
    case 'notice':
      $langcode = $message['language']->language;
      $message['subject'] = 'example submission from ';
      $message['body'][] ='my example.';
      $message['params']['attachments'][] = $attachment;
      break;
  }
}

And where:

function generatePdf($where="S") {
  $pdf = tcpdf_get_instance();

  $pdf->setFontSubsetting(true);

  // set font
  $pdf->SetFont('freeserif', '', 12);

  $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 008', PDF_HEADER_STRING);

  // set header and footer fonts
  $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

  // set default monospaced font
  $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

  // set margins
  $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP+10, PDF_MARGIN_RIGHT);
  $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

  // set auto page breaks
  $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

  // set image scale factor
  $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  return $pdf->Output('example_008.pdf', $where);
}

Above is now my working example :)


The search queries of Drupal 8 use the global pager. The total results count is available within its global $pager_total_items variable.

So the easiest way of showing the amount of total items is using this variable within a hook_preprocess_HOOK() of your template in your *.theme file.

For example, if you'd like to use the total results count within the item-list--search-results.html.twig, HOOK needs to be replaced by its theme hook item_list__search_results:

/**
 * Implements hook_preprocess_HOOK() for item_list__search_results.
 */
function mytheme_preprocess_item_list__search_results(array &$variables) {
  // The $pager_total_items variable is a global
  // array keyed by the pager element increments.
  global $pager_total_items;

  // Assuming you have one paged list on your page only,
  // the element's key should be 0.
  $variables['total_items_count'] = isset($pager_total_items[0]) ? $pager_total_items[0] : 0;
}

Then you can access this variable like {{ total_items_count }} within the template.


using hook_form_alter on a same form from 2 different modules

It sounds like you're altering the same form to provide the additional validation so it is expected that both the author and creator validation checks will be carried out when both modules are enabled.

If you want to continue using the same form for both blocks then I would suggest wrapping the code within your validation callbacks to check which form you are currently validating.


How can I export webform analysis data to excel sheet?

I wrote a module for this. You can find it here: drupal.org/project/webform_analysis_export


Prevent Multiple user registrations from single IP

You may find the problem there is that Drupal doesn't store the IP address of the user during normal core registration process.

Assuming you can hook in and store that IP address for later lookup, you could then validate that ip address count for the user with something like:

/**
 * Implements hook_form_FORM_ID_alter
 */
function mymodule_form_user_register_alter(&$form, &$form_state) {
  $form['#validate'][] = 'mymodule_user_register_validate';
}

/**
 * hook_form_user_register_alter validation callback
 */
function mymodule_user_register_validate($form, &$form_state) {
  $account = (object) $form_state['values'];
  $ip_address = ip_address(); // api call
  // do something to look up ip_address on registered user..
  // for example:
  $count = db_query("SELECT count(uid) FROM {user_ip} WHERE ip = :ip", array(':ip' => $ip_address))->fetchField();
  if($count > 3){
    $error = t('Sorry, too many registrations.');
    form_set_error('name', $error);
  }
}


Show all group content of a specific group type

Wow, I actually figured this out. Basically you need to do the following:

Add the "OG Membership: OG membership from Node" relationship to the view.
Add the "OG Membership: Group Node from OG membership" relationship, assigning the above relationship.
Add a Filter Criteria of "Content: Type" = the group content type you want to show, and (here is the trick) assign the above relationship for this.

Here is a screenshot that might be more helpful:


Retrieve the default image from an image field programatically

The default image is stored in field configuration. You can retrieve it as follows:

<?php

use Drupal\field\Entity\FieldConfig;

$field_info = FieldConfig::loadByName('node', 'article', 'field_image');
$image_uuid = $field_info->getSetting('default_image')['uuid'];
$image = Drupal::service('entity.repository')->loadEntityByUuid('file', $image_uuid);
$image_uri = $image->getFileUri();


How to create a list of vocabulary names for a widget?

As the vocabulary is an entity, you can find his name id (taxonomy_vocabulary) in Drupal\taxonomy\Entity\Vocabulary.

To load all the available vocabularies you can use the following code:

$vocabularies = \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->loadMultiple();

To create the dependent taxonomy terms select I recommend you to take a look at the ajax examples in the Examples for Developers module.


Replace the URLs entered in a textarea with "url_removed"

When adding your text area to the webform you can set form validation and use a regex that makes sure the text is free of urls.  Something like:
/^(?!.(http|www|ftp|file|data|irc)).$/gmi
You definitely want to revise the actual regex as Im sure this one is not all inclusive.  I'm far from a regex expert.


Send site emails to multiple administrators

This is much similar to Pontus's answer but in a different approach. and I have tested this and it worked on a Ubuntu server email program (not through an external SMTP server but it should work in a decent program). Pontus's solution will work as it seems. But recipient will see both email addresses. A good approach would be to set the BCC address (Blind Carbon Copy) instead of a new CC.

If you are not willing to make a module, I'd suggest http://drupal.org/project/maillog .

function MYMODULE_mail_alter(&$message) {
 if (-- enter your condition here -- ) {
   $message['headers']['BCC'] = $message['headers']['Bcc'] = 'hidden@example.com';
 }
 }

Note that now you have opened a serious security risk that hidden@example.com can now see any email, including password reset email address for the super user. So don't forget  to add some condition using $message['id] that contains the message's ID.

You can make the module fancy and really usable by adding some sort of system_settings_form()'d form and a few variable_get().

Also, if the purpose of this is to send multiple emails on new security releases for modules, don't forget that you can add multiple email addresses in settings out-of-the-box.


How make a standalone field with no Entity or Bundle?

Take a look at system_settings_form and how it is used by other modules to create a basic form and field for module configuration. It'll generally use variable_get and variable_set to get and store it's value.


I came across this post when facing the same situation so I am posting the solution I found in case someone else needs it.

The only way I found to solve this was declaring a custom token using hooks. This post was really helpful: https://drupal.stackexchange.com/a/78498

Once both hooks are implemented, you will only need to manually load the parent to get the data you need, whether it is the parent URL or the parent title. After that, just use the token you just created and voilá!

Hope it helps!


A simple workaround without an additional module would be to copy and paste the content of the yaml file views.view.[view-id].yml you find in the module's /config/optional folder to www.mysite.com/admin/config/development/configuration/single/import.

Select the configuration type "View" and add the first line containing the UUID from the active configuration (switch to Export - Single item).

If you have to do this on a regular basis then the recommend way is to manage the configuration with Git, see this tutorial Using Configuration Management and Git to Track Drupal 8 Configuration.


The results from node_load_multiple() are already cached within a single page load - the only time they're not is if you pass the $reset parameter as TRUE (which you're explicitly not doing). Looking at the code calls to node_view() don't seem to be cached, but I might be wrong there.

At a guess your performance hit might be coming from those individual calls to node_view(), which you might be able to mitigate a bit by using node_view_multiple() instead.

$nodes = node_load_multiple(array(1653,1654,1656,1657,1658));
$views = node_view_multiple($nodes);

foreach ($views as $view) {
  // ...
}

I'm pretty sure the reason your code isn't working as you expect is that the return from node_view() isn't a reference to anything, so the changes you're making to the array aren't actually getting saved anywhere, only to the local copy of the array.

One last piece of advice...it would be a good idea to take this code out of the template file and put it in a preprocess function at the the theme or module level. Running database queries directly in the template file isn't the best idea for a number of reasons.


Change page URL structure based on node field value

You can build a small module, called myalias and use this code to generate custom alias

<?php
function myalias_node_insert($node){
    //here you can access the $node variable and get its fields value
    $node->path['alias'] = 'your_custom_path';
}

You can also change the hook to myalias_node_update($node) to alter the node alias once it is updated.


Your invaluable suggestion moved me for searching deeply in the relationship of Views UI and guess what? I solved the problem after the hours of study in Views UI. Here in this case there are two relations involved. The 2nd relation is involving the first one. This will not be possible to sort out if I didn't know how to turn on the SQL query in Views UI. This link also helped me.

Use of relationships (joins) in Views

Thanks You Nikhil!


Another possibility: You could create a taxonomy (vocabulary) for your administrative features and use that with Taxonomy Menu. Add an image field to your terms with icon.  Or, just use Views to create your custom menu -- you'll be able to use your taxonomy term images there.


A couple of things I would check.

Make sure you're using the correct redirect URIs and JavaScript Origins. For example, the redirect URI should be https://www.example.com/coupon/hybridauth/endpoint?hauth.done=Google and the app you've registered at Google contain this too. The JavaScript Origins at Google should contain www.example.com (and example.com if you allow that too).
Since you're running the site in a subdir, make sure you've set RewriteBase in .htaccess to /coupon/. That might cause a problem with redirecting after auth.


Custom field type: make only one specific property translateable

content_translation has a feature that synchronizes certain property between translations, see how the \Drupal\image\Plugin\Field\FieldType\ImageItem field type uses that:

 *   column_groups = {
 *     "file" = {
 *       "label" = @Translation("File"),
 *       "columns" = {
 *         "target_id", "width", "height"
 *       },
 *       "require_all_groups_for_translation" = TRUE
 *     },
 *     "alt" = {
 *       "label" = @Translation("Alt"),
 *       "translatable" = TRUE
 *     },
 *     "title" = {
 *       "label" = @Translation("Title"),
 *       "translatable" = TRUE
 *     },
 *   },

By not setting translatable = TRUE, the UI by default suggests to keep that value across translations, although it can be configured differently.


Array Field for a Content Type. Is it possible?

In case you want to store complete array as a single input in a field, you can do so by serialize the array.

Create a long text field and serialize the array before input by calling hook_node_submit().


How do I fill form elements via onblur events?

You just need to AJAXify the form. Take a look at this article for more info on Drupal AJAX forms. To actually look up the user info you can just use the user_load_by_mail() function (more info).


There are different pieces to this problem.

The grid with images.
You can do that with Views. I'd say create a Views display of type "Block".
E.g. if every member of the company is a node or a user with an image field, then you can use the view to show an image for each of them. There is a display plugin to show items in a grid.
Display this stuff on one page.
One way to do that is with panels.
Another way is to create a node type with a Block reference field in addition to the body text field. You create the about page as a node of that type, and fill in the body text and reference the Views block you just created.
Yet another way is to simply put the block into a theme region, and configure it to only show up on the "about" path.

Another way for all of this is to create a node type with a multiple-value image field. This is if you don't want every single member of the company to be a node or user entity by itself.

Then you can use a custom formatter, or just some CSS, or Display suite hook_ds_field_theme_functions_info(), to display the images in a grid.


Moving / Migrating image files from another site into an existing Drupal 7 site

Why not use Feed Import  I am using it to import content from Joomla and WP sites into new Drupal sites with Drupal to Drupal export import should be a lot easy.
My process is as follows:

Create desired content types with all matching fields on the new
site.
Create Import profile for this content type go to mystie/import to
download csv template
Export content from the old site with path to images so to have
matching content with image
Upload images to new web site and change paths in csv file
Import and create or update content.


How to insert a theme table form inside an existing form?

Here is sample example where form and tables are used together.

Step1: Gather whole data, going to use in table.

$sample_data = array
(
  array('id' => 1, 'first_name' => 'jay', 'last_name' => 'chris'),
  array('id' => 2, 'first_name' => 'clo', 'last_name' => 'jason'),
  array('id' => 3, 'first_name' => 'len', 'last_name' => 'ken'),
);

Step2: Create table header.

$sample_header = array
(
  'first_name' => t('First Name'),
  'last_name' => t('Last Name'),
);

Step3: Create table rows and columns data.

$options = array();
foreach($sample_data as $data)
{
  $options[$data['id']] = array
  (
    'first_name' => $data['first_name'], // 'first_name' was the key used in the header
    'last_name' => $data['last_name'], // 'last_Name' was the key used in the header
  );
}

Your data should be something like this:

Array
(
  [1] => Array
  (
    [first_name] => jay
    [last_name] => chris
  )

  [2] => Array
  (
    [first_name] => clo
    [last_name] => jason
  )

  [3] => Array
  (
    [first_name] => len
    [last_name] => ken
  )
)

Step4: Use drupal function(tableselect) for table

$form['table'] = array
(
  '#type' => 'tableselect',
  '#header' => $header,
  '#options' => $options,
);

Here is complete form for you.

function my_form($form, $form_state)
{
  $sample_data = array
  (
      array('id' => 1, 'first_name' => 'jay', 'last_name' => 'chris'),
      array('id' => 2, 'first_name' => 'clo', 'last_name' => 'jason'),
      array('id' => 3, 'first_name' => 'len', 'last_name' => 'ken'),
  );

  $sample_header = array
  (
    'first_name' => t('First Name'),
    'last_name' => t('Last Name'),
  );
  $options = array();
foreach($sample_data as $data)
{
  $options[$data['id']] = array
  (
    'first_name' => $data['first_name'], // 'first_name' was the key used in the header
    'last_name' => $data['last_name'], // 'last_Name' was the key used in the header
  );
}

  $form['table'] = array
  (
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
  );

  $form['submit'] = array
  (
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

There can be some TYPO mistake, so do change in code accordingly.


How to create heirarchical taxonomy menu/list using VIEWS

You can try using Views Tree module..

Project page says

  Views Tree module provides a tree-based style plugin for Views. It is
  equivalent to the tree-based style template from Views 1.

  It is based off of the list style. Although it generates a nested
  view, there is still only a single query run for the view making it
  quite performant.

For node count, you can implement same using views.. Check this post Views and node count for taxonomy terms..


Empty node workflow state on node after programmatically saving

There's a code for creating a node and indicating its status, maybe it would help:

<?php
// add node properties
$newNode = (object) NULL;
$newNode->type = '{NODE_TYPE}';
$newNode->title = '{NODE_TITLE}'
$newNode->uid = {USER_ID};
$newNode->created = strtotime("now");
$newNode->changed = strtotime("now");
$newNode->status = 1;
$newNode->comment = 0;
$newNode->promote = 0;
$newNode->moderate = 0;
$newNode->sticky = 0;

// add CCK field data
$newNode->field_{YOUR_CUSTOM_FIELD_1}[0]['value'] = '{DATA_1}';
$newNode->field_{YOUR_CUSTOM_FIELD_2}[0]['value'] = '{DATA_2}';

// save node
node_save($newNode);
?>


How to filter a view based for the current user based the value of custom fields in his profile and fields in the list of items viewed

I'll take the assumption that your using a content view, that way we're only making relationships to the user or user of said content.

Essentially you could add an entity reference to a taxonomy term which would in turn be referencing the piece of content to filter. So;

We create a new vocabulary, add the entity reference field. Create a new term, we'll call this 'bald'. Bald will make an entity reference to the content item 'Miracle Grow Hair Spray'.

Next we'll add a taxonomy reference field to the user profile. This will reference the users 'properies' from our new vocabulary. E.G. if our user is bald we will reference this term.

Lastly on the view we should have enough data to make a bridge to the piece of content being referenced by the term associated with said user.

Although basic & very roughly explained this should hopefully help.


What's wrong with this simple debugging code?

The kint() and ksm() functions output the results in the status messages block.

Make sure in /admin/structure/block the Status messages system block is set to a region.


You can use the group by field option.

The process would go as follows.

In Fromt section next to the Format you have settings click on that.

You will find Grouping field Nr.1 Select the category Field from the list.

This would group the fields with the Category. But Now you would see both category as well as Link. Now you can go to the Category field settings and select exclude from Display so that only the links would be shown.


Behavior of taxonomy-term classified paths

/admin/config/search/path/patterns is an admin page for the module Pathauto, URL alias - Patterns. And the default pattern for Taxonomy terms just happens to be [term:vocabulary]/[term:name].

You can also see that each "vocabulary" of taxonomy terms can have it's own pattern.

To confirm if Views is handling the display of any of the taxonomy terms pages we need to find a view that takes over the default Taxonomy term path and is already enabled. Meaning, the modules View and Views UI must be enabled. If only Views is enabled, enabling Vies UI at this point makes this easier, plus we will need it later to change the "Sort criteria". With install of the of the Views module the Taxonomy term view is created. This view has a path of 'taxonomy/term/%' the same as the Taxonomy modules default path and when the view is enabled it overrides the Taxonomy module's handling of the display of the taxonomy terms pages.

For a final conformation that this taxonomy vocabulary's term pages are being handled by views lets look at the final HTML that is out generated.

For a views generated page you will see a few key classes in the content's wrapping elements (unless heavenly custom themed).

vs the generated page you will see from the taxonomy module.

Bonus tip: The classes added by the view let us know the machine names of the view being used. view-id-taxonomy_term tell you the "taxonomy_term" view is using used, while view-display-id-page tell you it is the "page" display in current view.


Whats the difference between a 'page', a 'panel', and a 'handler'?

If you navigate to admin/structure/panels. It gives a short description.

Panel page

Panel pages can be used as landing pages. They have a URL path, accept arguments and can have menu entries.

Custom content
Custom content panes are basic HTML you enter that can be reused in all of your panels.


Increasing width of Views 3 search form filter

Perhaps you can get away with a simple CSS rule in your theme's stylesheet? Something like this:

#views-exposed-form-blog--user-s-tab--page input{width: 200px;}

That width can be anything. In this example, it'd be 200pixels wide.


How to pass PHP variables to Javascript/jQuery?

You'd be better off using drupal_add_js() to pass your object in the JS Drupal.settings object:

// In PHP:
drupal_add_js(array('myModule' => array('variables' => $variables)), 'setting');

// In JS
var variables = Drupal.settings.myModule.variables;

Drupal handles all the conversions of objects/arrays internally and this is just a much cleaner way of doing it...at the moment you're including raw JSON as part of the page output which isn't great in terms of semantics; also bear in mind that search engines will pick up this text even though you're hiding it for users with javascript.

I'd also recommend separating this logic out from the template file itself and put it in a template_preprocess_ function in your theme's template.php file...again it's just cleaner. e.g.

function MYTHEME_preprocess_html(&$vars) {
  $variables = $your_variables;
  drupal_add_js(array('myModule' => array('variables' => $variables)), 'setting');
}

Have a look at the link to the drupal_add_js() function, there are quite a lot of options and you'll probably find them quite useful.


You could do this easily with jQuery, check the .wrap() method:

$('blockquote').wrap('

');

The wrap() method will wrap elements into another element.

If you want to do it as custom CKEditor plugin I would look at an existing plugin that does something similar and modify it to get the markup you want. I found a Drupal module with a custom plugin that add a wrapper element to blockquote: https://www.drupal.org/project/ckeditor_blockquote_attribution


What is rss category format in manage dislay?

This display setting hides taxonomy links on the node page and adds category elements into Drupal's RSS feed (http://example.com/rss.xml). Go to your site's RSS feed and you can see it in action.


How many child pages can be added under a book parent item?

Yes, books in Drupal 8 and 9 have a maximum depth of 9, which is the value of the
BookManager::BOOK_MAX_DEPTH constant.
const BOOK_MAX_DEPTH = 9;