hook_init() is invoked by Drupal only once for each requested page; it is the last step done in _drupal_bootstrap_full().

  // Drupal 6
  //
  // Let all modules take action before menu system handles the request
  // We do not want this while running update.php.
  if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
    module_invoke_all('init');
  }

  // Drupal 7
  //
  // Let all modules take action before the menu system handles the request.
  // We do not want this while running update.php.
  if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
    // Prior to invoking hook_init(), initialize the theme (potentially a custom
    // one for this page), so that:
    // - Modules with hook_init() implementations that call theme() or
//   theme_get_registry() don't initialize the incorrect theme.
    // - The theme can have hook_*_alter() implementations affect page building
//   (e.g., hook_form_alter(), hook_node_view_alter(), hook_page_alter()),
//   ahead of when rendering starts.
    menu_set_custom_theme();
    drupal_theme_initialize();
    module_invoke_all('init');
  }

If hook_init() is being executed more than once, you should discover why that happens. As far as I can see, none of the hook_init() implementations in Drupal checks it is being executed twice (see for example system_init(), or update_init()). If that is something that can normally happen with Drupal, then update_init() would first check if it has been already executed.

If the counter is the number of consecutive days a user logged in, I would rather implements hook_init() with code similar to the following one.

// Drupal 7
function mymodule_init() {
  global $user;

  $result = mymodule_increase_counter($user->uid);
  if ($result[0]) {
    // Increase the counter; set the other variables.
  }
  elseif ($result[1] > 86400) {
    // The user didn't log in yesterday.
  }
}

function mymodule_date($timestamp) {
  $date_time = date_create('@' . $timestamp);
  return date_format($date_time, 'Ymd');
}

function mymodule_increase_counter($uid) {
  $last_timestamp = variable_get("mymodule_last_timestamp_$uid", 0);
  if ($last_timestamp == REQUEST_TIME) {
    return array(FALSE, 0);
  }

  $result = array(
    mymodule_date($last_timestamp + 86400) == mymodule_date(REQUEST_TIME),
    REQUEST_TIME - $last_timestamp,
  );
  variable_set("mymodule_last_timestamp_$uid", REQUEST_TIME);

  return $result;
}

// Drupal 6
function mymodule_init() {
  global $user;

  $result = mymodule_increase_counter($user->uid);
  if ($result[0]) {
    // Increase the counter; set the other variables.
  }
  elseif ($result[1] > 86400) {
    // The user didn't log in yesterday.
  }
}

function mymodule_increase_counter($uid) {
  $last_timestamp = variable_get("mymodule_last_timestamp_$uid", 0);
  $result = array(FALSE, time() - $last_timestamp);

  if (time() - $last_timestamp < 20) {
    return $result;
  }

  $result[0] = (mymodule_date($last_timestamp + 86400) == mymodule_date(REQUEST_TIME));
  variable_set("mymodule_last_timestamp_$uid", time());

  return $result;
}

If hook_init() is invoked two times in row during the same page request, REQUEST_TIME contains the same value, and the function would return FALSE.

The code in mymodule_increase_counter() is not optimized; it is just to show an example. In a real module, I would rather use a database table where the counter, and the other variables are saved. The reason is that Drupal variables are all loaded in the global variable $conf when Drupal bootstraps (see _drupal_bootstrap_variables(), and variable_initialize()); if you use Drupal variables for that, Drupal would load in memory information about all the users  for which you saved information, when for each requested page there is only one user account saved in the global variable $user.

If you are counting the number of page visited from the users in consecutive days, then I would implement the following code.

// Drupal 7
function mymodule_init() {
  global $user;

  $result = mymodule_increase_counter($user->uid);
  if ($result[0]) {
    // Increase the counter; set the other variables.
  }
  elseif ($result[1] > 86400) {
    // The user didn't log in yesterday.
  }
}

function mymodule_date($timestamp) {
  $date_time = date_create('@' . $timestamp);
  return date_format($date_time, 'Ymd');
}

function mymodule_increase_counter($uid) {
  $last_timestamp = variable_get("mymodule_last_timestamp_$uid", 0);
  if ($last_timestamp == REQUEST_TIME) {
    return array(FALSE, 0);
  }

  $result = array(
    mymodule_date($last_timestamp + 86400) == mymodule_date(REQUEST_TIME),
    REQUEST_TIME - $last_timestamp,
  );
  variable_set("mymodule_last_timestamp_$uid", REQUEST_TIME);

  return $result;
}

// Drupal 6
function mymodule_init() {
  global $user;

  $result = mymodule_increase_counter($user->uid);
  if ($result[0]) {
    // Increase the counter; set the other variables.
  }
  elseif ($result[1] > 86400) {
    // The user didn't log in yesterday.
  }
}

function mymodule_increase_counter($uid) {
  $last_timestamp = variable_get("mymodule_last_timestamp_$uid", 0);
  $result = array(FALSE, time() - $last_timestamp);

  if (time() - $last_timestamp < 20) {
    return $result;
  }

  $result[0] = (mymodule_date($last_timestamp + 86400) == mymodule_date(REQUEST_TIME));
  variable_set("mymodule_last_timestamp_$uid", time());

  return $result;
}

You will notice that in my code I don't use $user->access. The reason is that $user->access could be updated during Drupal bootstrap, before hook_init() is invoked. The session write handler used from Drupal contains the following code. (See _drupal_session_write().)

// Likewise, do not update access time more than once per 180 seconds.
if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) {
  db_update('users')
    ->fields(array(
    'access' => REQUEST_TIME,
  ))
    ->condition('uid', $user->uid)
    ->execute();
}

As for another hook you can use, with Drupal 7 you can use hook_page_alter(); you just don't alter the content of $page, but increase your counter, and change your variables.
On Drupal 6, you could use hook_footer(), the hook called from template_preprocess_page(). You don't return anything, but increase your counter, and change your variables.

On Drupal 6, and Drupal 7, you could use hook_exit(). Bear in mind that the hook is also invoked when the bootstrap is not complete; the code could not have access to functions defined from modules, or other Drupal functions, and you should first check those functions are available. Some functions are always available from hook_exit(), such as the ones defined in bootstrap.inc, and cache.inc. The difference is that hook_exit() is invoked also for cached pages, while hook_init() is not invoked for cached pages.

Finally, as example of code used from a Drupal module, see statistics_exit(). The Statistics module logs access statistics for a site, and as you see, it uses hook_exit(), not hook_init(). To be able to call the necessary functions, it calls drupal_bootstrap() passing the correct parameter, such as in the following code.

  // When serving cached pages with the 'page_cache_without_database'
  // configuration, system variables need to be loaded. This is a major
  // performance decrease for non-database page caches, but with Statistics
  // module, it is likely to also have 'statistics_enable_access_log' enabled,
  // in which case we need to bootstrap to the session phase anyway.
  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);

  if (variable_get('statistics_enable_access_log', 0)) {
    drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);

    // For anonymous users unicode.inc will not have been loaded.
    include_once DRUPAL_ROOT . '/includes/unicode.inc';
    // Log this page access.
    db_insert('accesslog')
      ->fields(array(
      'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
      'path' => truncate_utf8($_GET['q'], 255),
      'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
      'hostname' => ip_address(),
      'uid' => $user->uid,
      'sid' => session_id(),
      'timer' => (int) timer_read('page'),
      'timestamp' => REQUEST_TIME,
    ))
      ->execute();
  }

Update

Maybe there is some confusion about when hook_init() is invoked.

hook_init() is invoked for each page request, if the page is not cached. It is not invoked once for each page request coming from the same user. If you visit, for example, http://example.com/admin/appearance/update, and then http://example.com/admin/reports/status, hook_init() will be invoked twice: one for each page.
"The hook is invoked twice" means there is a module that executes the following code, once Drupal has completed its bootstrap.

module_invoke_all('init');

If that is the case, then the following implementation of hook_init() would show the same value, twice.

function mymodule_init() {
  watchdog('mymodule', 'Request time: !timestamp', array('!timestamp' => REQUEST_TIME), WATCHDOG_DEBUG);
}

If your code shown for REQUEST_TIME two values for which the difference is 2 minutes, as in your case, then the hook is not invoked twice, but it is invoked once for each requested page, as it should happen.

REQUEST_TIME is defined in bootstrap.inc with the following line.

define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);

Until the currently requested page is not returned to the browser, the value of REQUEST_TIME doesn't change. If you see a different value, then you are watching the value assigned in a different request page.


Some pages hide content unless "Read more" is clicked

What you're probably looking at is a "View". This view is probably showing a list of "Content" (nodes).
Now each node is probably being set to render in "Teaser" view mode. But since some of your node types (article for example) doesn't have a "teaser" view mode configured, it shows the "Full" (or "Default") view mode, which renders the "whole" thing.
What you need to do is find the View Mode that your content listing View is using, the Node Type of the content that's showing up as Full, (for example 'Basic Page'), then go to:
Structure > Content Types > [Content Type you want to configure] > Manage Display
And configure the view mode that your View is using to display the Read More link, show the body text as "Summary or Trimmed" etc.


How to show a field in a view taken as input in a different content type?

Entity Reference is now included in Drupal 8 core.
To use it, simply add a field "Reference-Content" and you may use your Company Reviews content type. Then, following the tutorial from your link, you should be able to add any field from Company Reviews in a view showing content of type Company Information.


Short answer: yes.

Long(er) answer:
There are definitely modules that would make use of those MySQL permissions.  Not to mention administrative functions like installing new modules, doing updates, etc.

'grant all' for your Drupal database user is the easiest/best way to do this.  However, once a site is up and running,  I would imagine that you could remove a LOT of those permissions.


Set the inital number of empty values for a cck multi-value field

Unfortunately there is no way to do this without altering the module code of CCK.

There have been a few patches created that will allow you to set the number of fields initially shown and let you choose how many more to add when click the "Add another" button. However, this feature is not available in the core of Drupal 7 which may be a problem if you choose to upgrade.

Patch created for CCK 2: http://drupal.org/node/530828#comment-3397196

Patch created for CCK 3: http://drupal.org/node/841914#comment-3209072


This is how I achieved what I wanted, rather than use key value pairs I just used an empty textfield and used one line for each option and then when retrieving the textfield for the form I used the following.

$raw_marketing_options = explode(PHP_EOL, variable_get('marketing_sources_sources'));

I then just used the variable directly in the form.

$form['Marketing_source__c'] = array(
  '#type' => 'select',
  '#title' => 'Marketing source',
  '#options' => $raw_marketing_options,
);

There may be a safer way to do it as I am not sure how secure variable_set() is when storing plain text but only the administrator will see the textarea anyway.

Cheers


I'm afraid you should never use PHP in Views, as the link mentions you should write your own Views handler or Plugin, it's not that hard


Trying to print results of Apache Solr Search

If you want to print to the drupal messages, you need to use drupal_set_message instead of drupal_get_message first.


Keeping your date field, I don't know an easy way. But if you take a look at https://www.drupal.org/project/office_hours, it would create a new field allowing custom hours. Maybe combining both fields you could do the trick.


This should help: Direct Drupal 5 to Drupal 7 Migration in 24hrs.

So, rebuild the views and content types on the Drupal 7 site, then use a custom script (like the one provided in the article, or one you write yourself), or the Migrate module to move the data.


UI issues with the "Registration" module

It sounds like a lot of the issue is you you'll have to go into the theme and edit how it displays from there. The comments in particular you'll have to do this, you can create a tpl.php file specifically for for "Events" content type. You can learn how to do that here:

http://drupal.org/node/17565


How do I limit the number of images displayed in a teaser?

Try using this module http://drupal.org/project/field_multiple_limit

It allows you to go into the display settings for your content type and configure the teaser settings to display only a certain amount of values. You can even make it skip vales, for example if you want it to display values 2 to 5.


Is it possible to define a FieldFormatter as a service

You don't need to define your FieldFormatter as a service. FieldFormatters are instantiated inside the FormatterPluginManager's createInstance method (FormatterPluginManager::createInstance) which calls a create method on the formatter plugin object, passing a $container object as a parameter.

But this happens only if your FieldFormatter implements the \Drupal\Core\Plugin\ContainerFactoryPluginInterface. From then on, you are able to inject the service inside your FieldFormatter.


So after researches, everything work now and here is my configuration :

I putted this code into my sites/default/setting.php file :

$conf['https'] = FALSE;
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
  $base_url = 'https://www.efficient-network.eu';
}
else {
  $base_url = 'http://www.efficient-network.eu';
}
$_SERVER['HTTPS'] = 'On';

And needed to add a custom module to load every line in <head> </head> with https :

function https_process_html(&$vars)
{
    foreach (array('head', 'styles', 'scripts') as $replace) {
        if (!isset($vars[$replace])) {
            continue;
        }

        $vars[$replace] = preg_replace('/(src|href|@import )(url\(|=)(")http(s?):/', '$1$2$3', $vars[$replace]);
    }
}

I don't know if it's the proper method, but it works.


The default $main_menu variable in page.tpl.php is set to menu_main_menu(), which is a contextual view of the main menu tree.

To get your desired output, you need to get the entire menu tree using menu_tree_all_data() and menu_tree_output().

To do this in your theme, create template.php if you haven't already, and add a new preprocess function for the page template:

function THEMENAME_preprocess_page(&$variables) {
  // Get the entire main menu tree
  $main_menu_tree = menu_tree_all_data('main-menu');

  // Add the rendered output to the $main_menu_expanded variable
  $variables['main_menu_expanded'] = menu_tree_output($main_menu_tree);
}

Then, in page.tpl.php, you can just use:

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

to get a expanded, nested unordered list of the main menu.

For a little more flexibility, you might want to consider the Menu Block module, which will let you create blocks of expanded menus out of the box with its Expand all children of this tree option as well as a host of other options for segmenting menu trees.


It can be done quite easily. I'm assuming that you are using Drupal 7 and using the Node Gallery as well as the Node Gallery API.

Install Colorbox for Drupal (including the library - follow the instructions on that page).
Now you have to some editing of the site structure (exact paths may vary but the provided paths will work if you are using the default Node Gallery installation settings):
go to admin/structure/file-types/manage/image/file-display (or browse: Admin->Structure->FileTypes->Image [Manage File Display]). Select Node Gallery File Thumbnail and put a check before Colorbox. Scroll down to Display Settings and under Content Image Style select node_gallery_thumbnail and select Per page gallery in the Gallery (image grouping) dropdown. Then Save Configuration.

Slightly complicated but not horribly so.


Here is a jsfiddle that will show 3 different techniques. http://jsfiddle.net/3rYCs/


Drupal.org is using the Project module.

What you see as project page is a normal node to which the Project module adds extra fields. Keep in mind that the project page is also showing blocks shown just for those pages, and which are not part of the project page output.
The Project module automatically creates a path alias for every project node. That is the reason you see http://drupal.org/project/views, instead of http://drupal.org/node/38878; if you try the last link you will see you are accessing the Views project page.

The fact the project page is just a content type is proved from the fact project is shown in http://drupal.org/node/add, which lists the possible content types for which a user can create a node.

What you see in that page depends from the permissions you have on Drupal.org; as site maintainer, I see listed some content types a normal user doesn't see, such as the Story content type.

As alternatives to using the Project module there is the Storm module, which is more complex, in some way, and lack integration with CVS, or Git repositories (as far as I can see).

  Storm is a structured system for project management, including:

  Organizations, Teams, People,
  Projects, Tasks, Tickets, Timetrackings,
  Notes, Invoices, and Expenses.

  Each part provides permissions to control the sharing of data with other Drupal users, and based on assignment of projects/tasks/tickets to particular users or teams.

The difference is that the Project module has been thought to be used on Drupal.org, even if it can be used on other sites, and the main features are the ones required from Drupal.org.

The Support Ticketing System module implements a ticketing system, and a help desk.

  The support module provides a basic ticketing system and helpdesk that is native to Drupal, offering complete email integration.

  The Support module offers the following features:

  Ticketing activity is illustrated with colorful charts (depends on the Chart API module).
  -Tickets can be assigned to users (and users can view all tickets assigned to them).
  Tickets support states (new, active, pending, closed, etc) and priorities (low, normal, high, critical, etc).
  Configurable email notifications for new and updated tickets.
  Email integration allows tickets to be created and updated via email, with support for attachments. New users can be automatically created. Ticket properties can be updated via email (using included support_mailcmd module).
  Highly configurable client and user ticket overviews, highlighting tickets that haven't been updated for a long time.
  Fully integrated with Drupal's search functionality, users can only search for tickets they have access to.
  Supports an unlimited number of clients, each with their own configuration and access permissions.
  Tickets are nodes, ticket updates are comments.


Drupal Commerce: How to make more than 50 types of a product variation?

Commerce Bulk Product Creation

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

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

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

Commerce Backoffice

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

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

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

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


Using git to fetch changes from testing version to live website

I would use a post-update hook that will pull changes into the webroot and perhaps also run some other commands like clearing the caches etc.

First you need to create a bare repository:

mkdir /var/git/<repo-production.git>
cd /var/git/<repo-production.git>
git init --bare
cp hooks/post-update.sample hooks/post-update
chmod +x hooks/post-update

You then need to modifiy your post-update to something like:

#!/bin/sh
cd /var/www/<your_www_root> || exit
unset GIT_DIR
git pull hub master
# if you have drush installed you clear caches here
# drush cc all
exec git update-server-info

Then you need to clone out the repository in your webroot:

cd /var/www
git clone /var/git/<repo-production.git> <your_www_root>
cd <your_www_root>
git remote rename origin hub

Then on your local machine you add the remote like this:

git remote add production ssh://root@example.com:/var/git/<repo-production.git>

Of course you need to change the above to match your own username, hostname and path to your repository.

You should now be able to push changes to the remote repository, than in turn will deploy any changes into the webroot.

git push production

Notice that you can setup another bare repository for your staging environment and modify the above so it checkout the code to a different location. A nice approach would then be to add it using git remote add staging <path_to_staging_repoistory>. Done this you are able to push your code either to production using git push production or to staging using git push staging.


How to remove "Show row weights" option on File Upload field?

The first part of your question is regarding removal of link "Show row weights" (or "Hide row weights" if dragging functionality is disabled) in a form where table rows are draggable, so I'm going to answer that.

"Show row weights" string appears in Drupal.tableDrag.prototype.showColumns() method and "Hide row weights" appers in Drupal.tableDrag.prototype.hideColumns() method that is included in tabledrag.js file (see head in Drupal 7.x branch) so you need to override these methods in order to replace or remove these strings without losing row dragging functionality.

Place this code in a .js file that is loaded along with the form that uses tabledrag.js:

(function ($) {
  // Copy hideColumns() method
  var hideColumns = Drupal.tableDrag.prototype.hideColumns;
  Drupal.tableDrag.prototype.hideColumns = function() {
    // Call the original hideColumns() method
    hideColumns.call(this);
    // Remove the 'Show row weights' string
    $('.tabledrag-toggle-weight').text('');
  }

  // Copy showColumns() method
  var showColumns = Drupal.tableDrag.prototype.showColumns;
  Drupal.tableDrag.prototype.showColumns = function () {
    // Call the original showColumns() method
    showColumns.call(this);
    // Remove the 'Hide row weights' string
    $('.tabledrag-toggle-weight').text('');
  }
})(jQuery);


Create a vocabulary with terms that are linked to a content type

When you are creating a new node, you call taxonomy_term_save(), passing as argument the taxonomy term object $term, and using the node title for set $term->name, and the vocabulary ID to set $term->vid.
When you update a node, you first you load the taxonomy term with taxonomy_term_load_multiple(), as in taxonomy_term_load_multiple(array(), array('name' => trim($name), 'vid' => $vid)), change $term->name, and save the taxonomy term with taxonomy_term_save().
When you delete a node, you first load the taxonomy term with taxonomy_term_load_multiple(array(), array('name' => trim($name), 'vid' => $vid)), and then delete it passing $term->tid to taxonomy_term_delete().

The functions I reported needs to use the vocabulary ID; this means that the module you are writing needs to save in a Drupal variable the ID of the vocabulary it created, or to ask to the user the vocabulary name for the vocabulary that needs to be used. In the second case, and in the case the module stores the vocabulary name, code similar to the following one should be used to get the vocabulary ID:

$vocabulary = taxonomy_vocabulary_load_multiple(array(), array('name' => trim($name)));
$vocabulary = reset($vocabulary);
$vid = $vocabulary->vid;

The code needs to be changed for Drupal 8, as the conditions (the second parameter of taxonomy_term_load_multiple(), and taxonomy_vocabulary_load_multiple()) will be removed in Drupal 8.


White screen of death in hook form alter

It seems that dsm() and dpm() are not supported in Drupal 8. They are replaced by kint(). I have enabled the devel kint sub-module and used kint($form) to print my form array. You can also use ksm($form).


Check your view name that you are passing to views_get_view() and also from where are you getting the $account variable from (credits: wolverine).

And get rid off $view->set_arguments(array($account->uid));, you don't need it (credits: No Sssweat).


performance: rule set or triggered rules?

I believe the performance different is marginal, so I would chose the most maintainable.

Anyways in regards to performance my bet would be on the last option. Events function pretty much like a SQL where clause, so having more events doesn't hurt performance in itself. The number of rules that has to be fetched from the database, and initialized does effect performance, along with the number of queries that need to be executed.

So Rules will (most like) in the first case be running two queries. One to get the rule set based in the event and one to get the 5 rules in the set. It will need to instantiate 6 rules classes.

In the second case, rules will run a sigle query and only need to instantiate 5 rules classes.

So with fewer queries and rules classes that need to be instantiated the last version should be the most performance optimized. I doubt that you actually will be able to measure this though.


How can I center a logo image in an Omega theme?

By default the Omega theme CSS floats the image within branding left. You'll have to set it to float none.


Before answering YES/NO, let me make the context clear:

The .tpl.php files live near the city gates and are ready to produce code for the rest of the world. Moving towards the core of the city (our Drupal site) there is a very strong file: template.php. This file supports .tpl.php by providing new variables, changing variables, getting the HTML ready for pieces of our site and more.

Inside template.php there are 4 categories of things one can do:

write preprocess functions, like MYTHEME_preprocess_page(&$variables) or MYTHEME_preprocess_node(&$variables). With the aid of preprocess functions we can add or alter variables inside tpl.php files. Our main weapon: kpr($variables) or dpm($variables) provided by the devel module.
write theme functions like MYTHEME_links($variables) or  MYTHEME_breadcrumb($variables). Through theme functions we change the HTML output of some chunks of our site, like the breadcrumb. Main weapon: devel themer. (We check which theme function is responsible for the HTML output and override that one)
preprocess functions for theme functions. We manage to change a variable used in a theme function. For example, MYTHEME_preprocess_username(&$variables) prepares the variables for the theme_username(). We could put the code directly inside the corresponding theme functions, but then we would probably have a mess. (anyway, that's the idea behind the separation of the code here, and is not obligatory). Main weapon: kpr() or dpm()
implement hook functions. There are 4 hook functions available for template.php:

hook_css_alter
hook_js_alter
hook_page_alter
hook_form_alter

The first two change the css/js files loaded on a site (the one's we see as @import blah blah when we view the source code, and we can tell Drupal not to load a file (even if it a default module.css or anything else)

The third is used to change things around, regarding the whole page element of Drupal. So for example, we can move things around, from a node of the main content to the second block of the sidebar, etc

With the last one we can change variables inside any form in Drupal. Main methodology: call debug($form_id) to take the unique id of the form you want to play with
then target this form by if ($form_id == blabla), then call dpm($form) or debug($form) to see what's inside the specific form and alter variables, etc.

And YES, of course you can use both a preprocess function AND a specific .tpl.php
for example:

function MYTHEME_preprocess_node(&$variables){
if ($variables['type'] == 'article')
$variables['blabla'] = .. // creates a variable to be used in node.tpl.php
}

then create node--article.tpl.php and print that $blabla there


Disable cache a custom block for anonymous user

If you want to completely disable caching for the block, use this function in your block class:

  public function getCacheMaxAge() {
    return 0;
  }

I've never found in the documentation why

'#cache' => [
      'max-age' => 0,
    ],

doesn't work with blocks but, like you discovered, it doesn't seem to.


Why do I get a notice after migrating the site to a new server?

The problem might be the error handling settings have changed on the new server. You probably have a corrupt variable in the variable table that can't be unsterilized. Try using the variable check module.


Unable to save variable(s) from a custom form

Modify your example_form_form1_submit function as follows

function example_form_form1_submit(&$form, &$form_state) {
  variable_set('id_event', $form_state['values']['id_event']);
  $id_event = variable_get('id_event', '');
  drupal_set_message($id_event);
}


I have used the following code in hook_preprocess_page() to solve this issue.

$url = current_path();
  $arguments = explode('/', $url);
  foreach ($arguments as $value) {
    if (is_numeric($value)) {
      $node = node_load($value);
      if (og_is_group('node', $node)) {
        drupal_set_message('group id :' . $node->nid);
      }
    }
  }

From now, i can set to group member only could see this page.


Why is Drupal Core not updating via composer?

After running composer why-not drupal/core:8.5.4 and doing some more research on the error message, I came across Upgrading from 8.5.0 to 8.5.1 using composer

This command did the trick for me.

composer require drupal/core:8.5.4  webflo/drupal-core-require-dev --update-with-dependencies


pass view result from one view to another

You can use Views field view module ,https://drupal.org/project/views_field_view
with which you can have a view inside a view,and pass an argument from one view to another.


How to have all the fields available in a display mode for content type D8

You need to drag the items that you don't want to the disabled section. This works for both form display and front end display.

For your custom display mode, you should be able to select from each display mode:


What are the pros/cons/alternatives to creating a number of identical content types to allow for divergence?

Initially my approach was going to be much like theirs, to have one publications content type, and a publication type vocabulary to categorize them.

The problem with this approach is that you won't be able to use pathauto to give them different paths per type. Ex: You want the books type to be /books/title-goes-here and the cars type be /cars/title-goes-here

If books and cars are the same content type then node author would have to manually type in the url alias.

Also, how do you plan on theming them? If each type needs to be themed differently, I don't know how you're going to pull that off since they are all the same content type.

I think making 16 different content types is the way to go. You can always re-use existing fields whenever you can.

  I'm already seeing a little bit of difficulty in the ability to make
  dynamic templates that cover the entire set of publication types.

You could use the Panels module which allows you to theme all 16 content types differently or the same. With panels you won't have to deal with tpl (template) files.

Checkout this Panels Video Tutorial series


May be you can try this.

function yourmodule_views_pre_render(&$views) {
  if ($views->name == 'yourviewname') { //yourviewname is the machine name of the view
    $_SESSION['language'] = fr;
  }
}


Use an entity reference in URL as Views Contextual Filter

I have never added a views block into the admin overlay (trying to get a parameter from the URL form the views block). But this is how I would approach the problem.

In your view, pick the 'Block' display. Add a contextual filter for the field that is referencing (Vehicle). Expand 'When the filter is not available'. Pick the option PHP Code. User the following code:

return (isset($_GET['field_vehicle'])) ? $_GET['field_vehicle'] : 'all';

I am using 'all' as fallback assuming that you will show everything if a value isn't available. But I guess you can use FALSE if you want it empty.

Save it. Add the block into your overlay/admin theme. Check if it works...

Best regards.


Try it like this:

  field_diapo_home:
  -
    plugin: d6_field_file
    source: field_diapo_home
    migration: upgrade_d6_file
  -
    plugin: skip_on_empty
    method: process


How to change the duration of user access?

Yes. You are correct. Changing these settings will change the session time for logged in users.


To directly answer your question, yes, Predicates work. I use them extensively at a D6 Ubercart site of mine. Aside from that, my store is all digital goods, so no shipping.


PDF Module, PDF full pageheight or full scroll

I did something similar with print module , it also may be posible with PDF module. Override print--pdf.tpl.php file to fit your needs, copy print.tlp.php file from print-module directory (or look for a similar file in pdf module), paste it in sites/all/themes/your-sub-theme/templates folder. in line 100 is print $content, there add a css class "myclass" with higth=100%; done!.


How to save dynamic select list value into config table in Drupal 8?

There is some problem in the submit handler.

Replace

$this->config('test.settings')
 ->set('test_' . $content_type->get('type') . '_field', $form_state->getValue('test', 'test_' . $content_type->get('type') . '_field'))
 ->save();

line with

$this->config('test.settings')
  ->set('test_' . $content_type->get('type') . '_field', $form_state->getValues('test_' . $content_type->get('type') . '_field'))
  ->save();

Hope that this helps you.


Creating slightly different sites using same code base

The standard way of doing this is called a "multi-site".  It allows you to use the same codebase for multiple sites.  Each site in a multi-site has its own settings.php, so you may use different databases or the same database (this is controlled by the database settings in settings.php.
To use a different logo, just  go to appearance > settings and upload a different image for the logo.
Here is a link to my tutorial about setting up a multi-site:
http://wikihandbooks.com/drupal7/intro_multisite.html
There is also instructions at Drupal.org: https://www.drupal.org/docs/7/multisite/multi-site-sharing-the-same-code-base


Can I use panels (page_manager?) to layout create/edit forms pages for arbitraty entity?

I am new to panels and display suite both and trying to figure my way around those modules.

My preference is to use to Panels (or technically, Page manager) to control Context, that is, What to display Where.
Separately from that, you can use Display suite, or a recent favorite, Slate, for controlling rendering, or How things are displayed.
Allowing Page manager to render complete view modes instead of individual fields allows for much smarter caching most of the time, which can be a big performance gain.
If you're comfortable with code, Slate is significantly faster than Display Suite, for another large performance gain.

In "Display Suite" with "Display Suite Forms" you get an extensive list of all entities and bundles and can override any of the create/edit form layout.
In "Page Manager" I see only 'node add form', 'node edit form' and 'user edit form' context out of the box. Is there a way to generalize it and use "Panels" functionality with other entities on the site like Display Suite does it? I mean, without writing code.

'node add form', 'node edit form' and 'user edit form' are displayed as they are because the UI originates from D6, when there were no entities. The entire UI really needs a rewrite to be entity generic, but I don't know about anyone working on that.

What I want is to take existing entity, say 'commerce_customer_profile' and automatically have its 'X edit form' and 'X add form' contexts available in Panels. Or something equivalent.

Panels/Page manager has an entity generic context, but I think Display suite has deeper integration with entities.
You can bind any entity to a page as a context by creating a new Page, giving it a argument, for example %commerce_customer_profile and map it to the relevant underlying entity type.
To be fair though, I'm not sure this works for edit forms, I haven't had a reason to try that I can think off. If it doesn't, I can think of two things to do.

Implement a task handler. This is probably not trivial, but would allow full integration into Page manager. Could be contributed back to Ctools.
Use Page manager existing pages to take over the rendering of the existing edit forms. Using this module is likely a good option specifically for edit pages, as you should rarely be using Panels directly to tear up a form anyway; that can cause unintended data loss.

Because Display suite and Panels are often seen as some form of competitors (which I think is wrong), it's worth noticing that the author of PM Existing pages is also the author of Display suite.


Maybe ctools_collpasbile is a solution? http://timonweb.com/posts/painless-collapsible-divs-in-drupal/#

I just can't apply it to my table.


How to make a carousel with 1 highlighted node and thumbnails left and right?

You could do this with the jCarousel module:

Build your view to show the required nodes in the order you wish them to show.
Enable jCarousel view format
Create a style output template using a file name from OTHER -> Theme: Information -> Style output
Copy the code from the style template offered by the jCarousel module
Change the template code to output 7 rows at a time with the necessary wrappers and classes to make it look like your design
Make sure the .jcarousel and .jcarousel-clip divs are outside each group of 7 rows. [edit: it appears this happens outside of the template file, so not usually something you'll need to worry about]

Here's something to get you started with the style template file:

<?php

/**
 * @file jcarousel-view.tpl.php
 * View template to display a list as a carousel.
 */
$count = 0;
$rowcount = count($rows);
?>
<ul class="<?php print $jcarousel_classes; ?>">
  <?php while ($count < $rowcount): ?>
    <li class="<?php print $row_classes[$id]; ?>" style="display: none;">
      <?php // Print your seven rows here ?>

      ...

    <?php // Advance the counter ?>
    <?php $count += 7; ?>
    <?php // Depending on how you print your rows you may wish to slice 7 items off the $rows array ?>
    <?php $rows = arracy_slice($rows, 7); ?>
  <?php endwhile; ?>

Note that if you're referencing each row like $row[id] you may need to do a check before printing each one unless you're certain there will be a multiple of 7 rows in your view.


How can I pass multiple values to drupal_view()?

You can't pass an array. You have to implode the array to a string first. And use '+' as glue for OR and ',' as glue for AND. Like '1+2+3' or '1,2,3'. And maybe you also have to enable Allow multiple values in your view (in the very bottom of the contextual filter screen).

I have try that and it works but I'm not sure it's very clear:

{% set arguments = '' %}
{% set i = 0 %}
{% for item in content.field_articles_lies['#items'] %}
    {% if i == 0 %}
        {% set arguments = item.entity.nid.value %}
    {% else %}
        {% set arguments = arguments ~ "+" ~ item.entity.nid.value %}
    {% endif %}
    {% set i = i + 1 %}
{% endfor %}

{{ drupal_view('articles_lies', 'default', arguments) }}


How to resolve my Open Atrium installation error?

Try this

open -> admin/config/media/file-system

Change Temporary directory -> sites/default/files


Parent term suggestion on entering the child term in term reference field?

I think you'll need to override the taxonomy autocomplete path. Here's what you will need:

hook_menu_alter() implementation, so your custom module takes over the taxonomy autocomplete suggestions. See hook_menu() implementation, specifically $item['taxonomy/autocomplete'] item in /modules/taxonomy/taxonomy.module for more information.
You'll need to re-create the core taxonomy_autocomplete() function, which is in /modules/taxonomy/taxonomy.pages.inc.
You'll have to perform a check and see for which vocabulary you need to show suggestions:

If it's the vocabulary where you want to have child -> parent functionality, add the code for fetching the parent term and provide additional suggestions.
If it's some other vocabulary, make sure you return the same output as the core function would.

You'll need to add this in a custom module.

function YOUR_MODULE_menu_alter(&$items) {
  // This will re-route this path to your custom module, so you can have any
  // additional logic.
  $items['taxonomy/autocomplete']['page callback'] = 'YOUR_MODULE_taxonomy_autocomplete';
}

function YOUR_MODULE_taxonomy_autocomplete($field_name = '', $tags_typed = '') {
  // Copy the content of taxonomy_autocomplete() function here, and add necessary
  // modifications at the end of it.
}

Hope this helps.


How do I change the ID of a copy of an exposed filter?

This issue was discussed and answered in this thread, it includes a patch to fix the issue:

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

Another option is to use the module MEFIBS - More exposed forms in blocks


How to create custom ECK entity class (per bundle)

I guess it is impossible to do what you want. A bundle is not a sub-class of an entity as you seem to be assuming.

Classes are always defined in code and are always provided by a module. ECK uses a workaround but in fact only defines one entity type: EckEntity, it then performs some tricks to let Drupal see this as different entity types.

Creating entities for every bundle dynamically (since a user can add / remove bundles) would be difficult and appears to be only possible using dirty tricks like this:

// With a property
$myclassname = "anewclassname";
$myproperty = "newproperty";
eval("class {$myclassname} { protected \${$myproperty}; }";

From: https://stackoverflow.com/a/15579465/1293725

I am pretty sure Drupal does not support this (luckily).

Bundles are stored as properties on the entity, often (always?) as the type property, have a look at this example:

// Create node object with attached file.
$node = Node::create([
  'type'        => 'article', // < - this is the bundle
  'title'       => 'Druplicon test',
  'field_image' => [
    'target_id' => $file->id(),
    'alt' => 'Hello world',
    'title' => 'Goodbye world'
  ],
]);
$node->save();

From: https://drupal.stackexchange.com/a/189095/9921

So in your case, you would need to do this:

$car = Vehicle::create([
  'type'        => 'car',
   ...
]);

Or define a new class for your bundles, but you would need to either use the eval method above to create a class for all your bundles, or define them in code and loose flexibility. Then in that class extend the Vehicle class and in the constructor provide the type or something. For the sake of readability of your code I guess it would be best to just follow conventions and not create classes for bundles.


How to render a taxonomy field in a Views' PHP code field?

I can't comment because of rep..
Use devel module and use the dpm() function in your php for some debugging, drill down and find the value you are looking for then double click the value in the debug widget and it should tell you your field value.

here's my guess:

$data->field_field_my_category[0]['raw']['value'];

Might be slightly different if it's a tax term but devel is your best friend and you should use it quite frequently. Stop guessing and start debuging (best advice i've ever gotten).


Unable to post new forum topics in Drupal site

Yes i think @No Sssweat is right. You need to increase PHP memory limit.

ini_set('memory_limit', '256M'); in your sites/default/settings.php file.

Increase PHP memory limit

Increase PHP's memory limit, e.g. to increase it to 256M you could try adding:

memory_limit = 256M to your server's main php.ini file (recommended, if you have access)
memory_limit = 256M to a php.ini file in the Drupal root
ini_set('memory_limit', '256M'); in your sites/default/settings.php file
php_value memory_limit 256M in your .htaccess file in the Drupal root


You are absolutely correct. I know for a fact that many developers/sysadmins do not take the risk that the PHP interpreter might fail at some point, and include the db password (and other sensitive data like API keys) from a file outside the webserver's docroot.

I'm surprised that this is not documented as a best practice anywhere - at least I couldn't find it on drupal.org either. I have no information why it works the way it does.


How do I create a conditional form field?

You can do this using taxonomy terms.  A warning though ... taxonomy worked terribly due to the amount of conditional items.  For my situation, user selected a state, then the town it took about a minute for each selection.

Does this help?  http://www.webbykat.com/2013/04/conditional-fields-and-term-reference-tree-two-small-bugs-their-resolution

I'm assuming you have this Drupal 7 module?  https://www.drupal.org/project/conditional_fields


Change the "Create [content type]" title

You could do:

function MY_MODULE_NAME_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id == 'myContentType_node_form') {
         drupal_set_title('Your custom title');
     }
 }


"Configure Block" region highlight missing in Drupal 7

Make sure you have the Contextual Links module enabled.
If you're overriding the default block template in your theme, make sure you're printing the $title_prefix and $title_suffix vars; I forget which one, but one of those contains the markup for the contextual links javascript.


Return a 404 when a view pane in a page manager page has no result?

You can implement hook_views_pre_render in your module to do this task

/**
 * Implements hook_views_pre_render().
 */
 function mymodule_views_pre_render(&$view) {
   if ($view->name == 'myview' && $view->current_display == 'mypane') {
     if (empty($view->result)) {
       drupal_not_found();
     }
  }
}


Variables / settings configurable in Admin UI?

According to the change record The variable_get/set/del API is now removed you would need to store the settings in configuration. You can make this configuration available to an Editor by providing a Configuration Form or if you only want to add a few fields you can extend an existing configuration form in a form alter hook. For example add the Affilate ID to the Basic Site Settings. Similar to this example for the menu configuration: How to add field to menu


I generally handle this sort of thing like:
// First render my content and set it to a variable.
{% set submenu = drupal_entity('block', 'mainmenu', check_access=false)|render %}
// Next, check if the variable have content.
{% if submenu %}
  // If variable has content, render with wrapping div(s).
  <div class="my-wrapping-div">
    {{ submenu }}
  </div>
{% endif %}

It's important to render the submenu whether or not it has any displayable content to make sure it's cache settings are bubbled up.
Note: this will only work if whatever your rendering returns no html. If you're seeing some wrapping divs, etc return, but no content, you can alter your if statement like {% if submenu|striptags|trim %} to strip html and check for only content.


A configurable or a base field? Either way, that's a perfect use case for using a list (string) field type, then you tell Drupal what the allowed values and its keys and labels are. Views will use that when displaying he field and everything will just work.

If you define your field in Code, instead of hardcoding the list in there, you can also specify a callback that will call your PHP function, in case you expect the list to change or if it is dynamic (allowed_values_function in the field storage settings). Although you can also turn that around and treat that field configuration as the canonical source for your information and if you need it in PHP, read it out from there.

If that is for some reason not an option, then you can implement a Views field Plugin and expose it to views using hook_views_data() hook. That's very likely a lot more complicated than using the right field Type for your use case, though.


How to decide to create a content type or two if there are both common and uncommon fields?

I would use only 1 content type, and use the Conditional Fields module to hide those 30 extra fields for your select list field with value No.

This excerpt from this module's project page seems to perfectly fit as a possible solution for this approach:

  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.

Possible alternative

True, you might also go for 2 content types instead. But in that case you're using an approach as described in the (illuminating, I think) article "Relativity model for Drupal". For more details on that, and the typical modules involved in that approach, refer to my answer to "How do I model content (types) from a database-centric point of view?".

In the long run, I bet the overall implementation of your entire site would be much better (eg: you'd need way less contributed modules). But that also implies you're willing to do a way higher effort/investment then just adding the Conditional Fields module.


Drupal 7: Display Latest Revision's Author on the Admin Content Overview page with Admin Views Module

You need to add a relationship (Advanced > Relationships) for "Content Revision: User". Make a note of the name of the relationship.

Add a field for "User: Name" and then make sure the relationship matches that of the relationship you added.


I set up a workflow for doing this using field permissions, rules, and revisioning.  It works at the node level rather than the field level though, and it's rather complicated to set up.  In my searching there was no single module able to handle this.

Basically, I used rules to create a workflow in which users can only create and edit certain content types, all of which are subject to approval either upon creation or edit (using revisioning).


Need of re-indexing on search on Drupal site?

Cron by default only indexes a certain number of items each run.  I believe it defaults to 100 items.  The number is configurable from admin/config/search/settings.

The easiest way to force a reindex of an entire site is to use drush:

drush -y seach-reindex
drush -y seach-index

This will clear the index, and then index all unindexed items.  Be prepared, this can take a long time.

Sometimes, though, if you have some weird custom logic in the node load or field attach process, the search can get caught up.  When cron runs, the PHP timeout would eventually be hit.  When run from drush, you would see no progress running.


Set default value to an image field form element using form_alter

Try it like this:

$form['field_user_picture']['und'][0]['#default_value']['fid'] = $file->fid;

(Remove ['value'] key.)


How to handle complex redirection requirement?

You could use Services, you dont have to.

1) To have remote resources you need to create a url in drupal to consume data sent to it (Services can indeed do this). eg, mysite.com/secret/submit-a-resource-location. You could make this in a custom module with hook_menu, it could store values in a table with NID, and RESOURCE_URL as the columns.

2) If you goto some path on your site like mysite.com/passthrough/NID you could look at the NID passed in and in the hook_menu page_callback function and use drupal_goto to go to your remote url.

Eg:

function mymodule_menu() {
  $items['secret/submit-a-resource-location'] = array ( /* ... */ );
  $items['passthrough/%'] = array( /* ... */ );
  return $items;
}

function mymodule_passthrough_page_content($arg) {
  $result = db_query("SELECT resource_url FROM {external_resources} er WHERE er.nid = :nid", array(':nid' => $arg))->fetchCol();
  drupal_goto($result['resource_url'], 302);
  // implicit exit here by drupal goto.
}


just want to change checkbox value while submit

It should be possible to manipulate the values as desired in a custom validate function. In your form code, add something like this:

$form['#validate'][] = 'mymodule_custom_validate';

The mymodule_custom_validate is a function you could define as such to change the values to booleans, or anything else you need:

function mymodule_custom_validate(&$form, &$form_state) {
  if ($form_state['values']['title']['node_first']['value'] === 'value') {
    $form_state['values']['title']['node_first']['value'] = True;
  }
  else {
    $form_state['values']['title']['node_first']['value'] = False;
  }
  if ($form_state['values']['title']['node_second']['value'] === 'value') {
    $form_state['values']['title']['node_second']['value'] = True;
  }
  else {
    $form_state['values']['title']['node_second']['value'] = False;
  }
}

This is a fairly rudimentary implementation, but hopefully this will lead you in the right direction. You can see in this example how the values can be manipulated before they reach the submit handler.


You need an access check where you compare the passed user id with the current user, here's an example from simplenews:

public function checkAccess(UserInterface $user) {
  $account = $this->currentUser();

  return AccessResult::allowedIfHasPermission($account, 'administer simplenews subscriptions')
    ->orIf(AccessResult::allowedIfHasPermission($account, 'subscribe to newsletters')
      ->andIf(AccessResult::allowedIf($user->id() == $account->id())));
}

Note that this includes and admin permission check, for admins that can actually see the page for other users.

If you do not need that, you could also just make your route /my-cool-page and use the current user for whatever you are doing. With D8's routing system, you can even make local task appear on the user page if you want to.


How to use HTML tags in form error messages

All errors added to the form state will be finally handled by drupal_set_message.
That means that you can either use strings, or any class that implements the MarkupInterface.
Looking at that list I would say that what you are looking for is FormattableMarkup or even better TranslatableMarkup.

An example would then be:

$your_error = new TranslatableMarkup('<b>@message!</b>', array('@message' => 'A bold error'));
$form_state->setError($element, $your_error);

Good luck!


diff_diffs_show() is the page callback for the node/%node/revisions/view route. The only way to change the output for that route is changing the page callback with hook_menu_alter().
function mymodule_menu_alter(&$items) {
  $items['node/%node/revisions/view']['page callback'] = 'mymodule_diffs_show';
}

function mymodule_diffs_show($node, $old_vid, $new_vid, $state = NULL) {
  // Attaches the CSS.
  $build['#attached'] = diff_build_attachments();

  $default_state = variable_get('diff_default_state_node', 'raw');
  if (empty($state)) {
    $state = $default_state;
  }
  $state = str_replace('-', '_', $state);
  if (!array_key_exists($state, diff_available_states())) {
    $state = $default_state;
  }

  // Same title as the 'Revisions' tab. Blocked by non-page requests.
  if (node_is_page($node)) {
    drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
  }
  $node_revisions = node_revision_list($node);

  $old_node = node_load($node->nid, $old_vid);
  $new_node = node_load($node->nid, $new_vid);

  // Generate table header (date, username, log message).
  $old_header = t('!date by !username', array(
    '!date' => format_date($old_node->revision_timestamp),
    '!username' => format_username($node_revisions[$old_vid]),
  ));
  $new_header = t('!date by !username', array(
    '!date' => (format_date($new_node->revision_timestamp),
    '!username' => format_username($node_revisions[$new_vid]),
  ));

  $old_log = $old_node->log != '' ? '
' . filter_xss($old_node->log) . '
' : '';
  $new_log = $new_node->log != '' ? '
' . filter_xss($new_node->log) . '
' : '';

  // Generate previous diff/next diff links.
  $nav_suffix = ($default_state != $state) ? '/' . str_replace('_', '-', $state) : '';
  $next_vid = _diff_get_next_vid($node_revisions, $new_vid);
  if ($next_vid) {
    $next_link = l(t('Next difference >'), 'node/' . $node->nid . '/revisions/view/' . $new_vid . '/' . $next_vid . $nav_suffix, array('absolute' => 1));
  }
  else {
    $next_link = '';
  }
  $prev_vid = _diff_get_previous_vid($node_revisions, $old_vid);
  if ($prev_vid) {
    $prev_link = l(t('< Previous difference'), 'node/' . $node->nid . '/revisions/view/' . $prev_vid . '/' . $old_vid . $nav_suffix, array('absolute' => 1));
  }
  else {
    $prev_link = '';
  }

  $header = _diff_default_header($old_header, $new_header);
  $rows = array();
  if ($old_log || $new_log) {
    $rows['logs'] = array(
      array(
        'data' => $old_log,
        'colspan' => 2,
      ),
      array(
        'data' => $new_log,
        'colspan' => 2,
      ),
    );
  }
  $rows['navigation'] = array(
    array(
      'data' => $prev_link,
      'class' => array('diff-prevlink'),
      'colspan' => 2,
    ),
    array(
      'data' => $next_link,
      'class' => array('diff-nextlink'),
      'colspan' => 2,
    ),
  );

  $links = array();
  foreach (diff_available_states('node') as $alternative_state => $label) {
    $links[$alternative_state] = array(
      'title' => $label,
      'href' => "node/{$node->nid}/revisions/view/{$old_vid}/{$new_vid}" . ($alternative_state == $default_state ? '' : '/' . str_replace('_', '-', $alternative_state)),
    );
  }
  if (count($links) > 1) {
    $state_links = theme('links', array(
      'links' => $links,
      'attributes' => array('class' => array('links', 'inline')),
    ));
    $rows['states'] = array(
      array(
        'data' => $state_links,
        'class' => 'diff-links',
        'colspan' => 4,
      ),
    );
  }
  $rows = array_merge($rows, _diff_body_rows($old_node, $new_node, $state));

  $build['diff_table'] = array(
    '#theme' => 'table__diff__standard',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => array('class' => array('diff')),
    '#colgroups' => _diff_default_cols(),
    '#sticky' => FALSE,
  );

  // Allow users to hide or set the display mode of the preview.
  if (node_is_page($node) && $view_mode = variable_get('diff_view_mode_preview_node_' . $new_node->type, 'full')) {
    $header = '';
    if ($node->vid == $new_vid) {
      $header .= '
' . t('Current revision:') . '
';
    }
    else {
      $header .= '
' . t('Revision of @new_date:', array('@new_date' => format_date($new_node->revision_timestamp))) . '
';
    }
    $build['diff_preview']['header']['#markup'] = $header;
    // Don't include node links or comments when viewing the diff.
    $build['diff_preview']['content'] = function_exists('entity_view') ? entity_view('node', array($new_node), $view_mode) : node_view($new_node, $view_mode);
    if (isset($build['diff_preview']['content']['links'])) {
      unset($build['diff_preview']['content']['links']);
    }
    if (isset($build['diff_preview']['content']['comments'])) {
      unset($build['diff_preview']['content']['comments']);
    }
  }
  return $build;
}

The part getting the username is simplified: The code should check the username length, and truncate it if it's longer than 20 characters; the username should also be sanitized via check_plain().
See template_preprocess_username() to understand how that can be implemented.
I would rather not implement the code shown in this answer, since:

The node/%node/revisions/view route is accessible by the users who have the administer nodes permission, who should be allowed to see any link to revision pages
The users without the access user profiles permission wouldn't see links to user accounts in any case, but the users with the administer users permission should be allowed to see link to user accounts in any page, as that simplifies their work


How to load a user field in template_preprocess_comment()

Drupal already loads the user object. You can see the user object on that function:

function bartik_preprocess_comment($variables) {
  $user = $variables['user'];
  // Full load user
  $user = user_load($user->uid);
  // Now access your field
  $country = field_get_items('user', $user, 'field_country');
  if ($country) {
    $variables['author_country'] = $country[0]['safe_value'];
  }
  else {
    $variables['author_country'] = '';
  }
  // On your comment.tpl.php using $author_country
}


Choose node item from list and add to form

I'm not sure what kind of form your question is about. You say, you want to e-mail the result, so this is probably a Contact form.

Here you can add a reference field for content and then configure this field for the content type "Machinery". You can set this to unlimited values, so that you can add multiple machines. The default is an autocomplete field. You can change this to a select list in "Manage form display".


Is there any module that can show whoever edits a node?

This article should be able to help you: Adding 'Last edited by name some time ago' information

I'm not sure how you want it to look exactly, but with a preprocess function and a simple template edit, you can add an editors information.  You can style this however you like and add/remove information, but to show the editor's name and the edit date/time do the following:

Add to template.php (or add the code to the preprocess_node function if already exists):

function neuco_preprocess_node(&$variables) {
  $node = $variables['node'];
  $editor = user_load($variables['revision_uid']);
  $variables['edited'] = 'Edited by ' . theme('username', $editor) . ' on ' . format_date($node->changed, 'medium');
}

In your tpl file (node.tpl.php, node-YOURTYPE.tpl.php, etc):

<?php print $edited; ?>

Functions used: template_preprocess_node(), user_load(), format_date(), theme_username()


Show total amount of results for an exposed filter

I'm using Views 3.7 in Drupal 7 right now and finally found out you simply can add a result summary Global: Result summary to the header/footer.


you need to go to admin/structure/types/manage/article [if your content type is Article] or admin/structure/types/manage/page [if it's Basic Page]

click on comment settings and make sure you have threading checked, so the replies have an indentation.

Asfar as re: in subject box, to my knowledge, drupal does not come with that by default.


You need to provide the wildcard as title arguments:

$items['test/%'] = array(
  'title' => t('Test title'),
  'title callback' => 'function_title_callback',
  'title arguments' => array(1),
  'type' => MENU_NORMAL_ITEM,
  'access arguments' => array('access content'),
  'page callback' => 'function_content_callback',
);

And obviously make sure that your function is actually called function_title_callback() (which you've listed in hook_menu()), and not cjgimport_title_callback(), which you have listed in the question.

You should also be using the $arg variable, not the arg() function in your callback...but I guess that might be the result of debugging.


Use title instead of nid for node reference contextual filter

The reason Views' user reference field allows both the user uid and name is most probably because they are both unique, while the title of a node isn't guaranteed to be so, but of course the nid is.

If, however, your content titles are unique, you might try using it as the contextual filter, hooking it up with a relationship (or rather whatever the D7 term is for it :) to the node reference field, and using all of the lower case transforms and spaces to dashes stuff.

That only leaves a problem if the title has funky characters in it, eg, if the title is This & That your path has to be pagename/this-&-that for the view to work which is ugly to say the least.

Now, how I've dealt with this is to create another text field in my content types that I want to search for by title and I store a url safe title in there.  I auto fill them here in D6 land like this:

function MYMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  if (isset($node->field_url_safe_title) && $op == 'presave') {
    module_load_include('inc', 'pathauto');
    $node->field_url_safe_title[0]['value']=pathauto_cleanstring($node->title);
  }

  // all the other nodeapi stuff here

}

and now I can use pagename/this-that by filtering on this field instead of the title.

I use the nodeformcols module to hide this field on the node edit/add forms and don't display it in the node itself, but I am sure there are D7 ways of doing that.  Obviously, in D7, I'd also assume you'd use hook_node_presave() instead of hook_nodeapi() and add in a language array field when setting the field, but the logic would remain the same.


As you suspect the results from hook_menu() invocations are cached. As you're only clearing the caches while logged in as user 1, that's why the logged in user is always user 1 for your router item.

To get around it you'll need to use a title callback, which is evaluated separately to the cached data:

function MYMODULE_menu() {
  $items['test'] = array(
    'title callback' => 'MYMODULE_title_callback',
    'page callback' => 'test_output',
    'access arguments' => array('access content')
  );

  return $items;
}

function MYMODULE_title_callback() {
  global $user;

  $args = array(':uid' => $user->uid);
  $node = db_query("SELECT title, nid, vid FROM {node} WHERE uid = :uid", $args)->fetchObject();

  return t($node->title);
}

Also make sure you're not putting variables directly into the query string as this will leave you open to SQL injection attacks. You should use parameter replacement instead (as in the above example).


Drupal commerce email order notification not sending properly

Your issue is due to server email blocking. Please configure SMTP module for sending emails from the website. This will add appropriate headers in the mail, and your email will not get blocked.

Hope this will help you.

Thanks


how to extract values of field collection using Entityfieldquery?

An EntityFieldQuery can only refer to one type of entity, it cannot represent any relationships between entities. If the entity_type in your query is a field_collection_item, then that's the type of entity that the query will return. The EntityFieldQuery has no concept of the fact that your field collections are related to nodes, or anything else for that matter.

To get the entities related to the field collections you'll have to run another EntityFieldQuery. I haven't used field collection before but I would guess the logic would look something like this:

$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'customer')
  ->fieldCondition('field_name_of_collection_field', 'name_of_field_collection_column', array_keys($result['field_collection_item']));

There are things that need to be changed in that code (the name of your field collection field, the column name for the field collection relationship) but it should get you started.

Actual example of the two-query approach:

function get_species_country($id_country) {
    $inner = new EntityFieldQuery();
    $inner_r = $inner->entityCondition('entity_type', 'field_collection_item')
                     ->fieldCondition('field_species_country', 'target_id', $id_country, '=')
                     ->execute();
    if(!empty($inner_r['field_collection_item'])) {
        $keys = array_keys($inner_r['field_collection_item']);
        $query = new EntityFieldQuery();
        $species_r = $query->entityCondition('entity_type', 'node')
                      ->entityCondition('bundle', self::$bundle)
                      ->fieldCondition('field_species_countries', 'value', $keys)
                      ->execute();
        if(!empty($species_r['node'])) {
            $ret = node_load_multiple(array_keys($species_r['node']));
        }
    }
    return $ret;
}

In the example above:

field_species_countries - Name of the field collection
field_species_country - Actual field inside the field collection

Limitations: I think this has some limitations because the second query contains ... WHERE field IN (1, 2, 3 ...). For MySQL this is limited by max_allowed_packet


How to display a field of a referenced entity in views contextual block?

The solution is a two step solution, but first you need to decided if you are going from Parent to Child or Child to Parent.

Background info

If you are going from Parent to Child, you setup a relationship using the "referenced" variable.

If you are going from Child to Parent, you setup a relationship using the "referencing" variable.

To make life simple for myself, when I specify the relationship, I also using the Administrative Option on the Reference Window and enter a more understandable name for the relationship.  In you case, since I would make the Admin Name Event reading Organizer or something like that.

Setup a relationship for Event reading Organizer in the Relationship
field under the Advanced tab.
Once you have related your Event content type to the Organizer
content type, you should now be able to see the Organizer fields
appear in your list of available fields.  Select the fields from the
Organizer content type that you want to appear in your view and hit
Apply. Here is the CRITICAL part, once you have defined a
Relationship, a new drop down menu (Relationship) will appear on the
Configure field windows.  For any fields that is in another table,
you MUST choose the appropriate relationship for the field. In your
case, you would choose the Event reading Organizer relationship.
This relationship instructs view to go Organizer table and bring
back that field.  If you do not specify the relationship in the
Configure field windows, this will not work.

Attached is a copy of the Configure field with a relationship.  Note: In your example, you would want the referenced variable. But in my example, I was working with the referencing variable. Please do not let that confuse you.  Just image the word in the relationship is referenced.

If you have any questions, please post them here and I will respond.


Modifying argument of programmatically called render service. (e.g.: theme to use) = Get object from service container with modified argument

The mailsystem module is doing exactly what you are looking for I think. It has a configuration option to select which theme should be used to render mail templates.

See MailsystemManager::mail()

// Switch the theme to the configured mail theme.
$mail_theme = $this->getMailTheme();
$current_active_theme = $this->themeManager->getActiveTheme();
if ($mail_theme && $mail_theme != $current_active_theme->getName()) {
  $this->themeManager->setActiveTheme($this->themeInitialization->initTheme($mail_theme));
}

try {
  $message = parent::mail($module, $key, $to, $langcode, $params, $reply, $send);
}
finally {
  // Revert the active theme, this is done inside a finally block so it is
  // executed even if an exception is thrown during sending a mail.
  if ($mail_theme != $current_active_theme->getName()) {
    $this->themeManager->setActiveTheme($current_active_theme);
  }
}
return $message;

}

You can't tell the renderer directly which theme to use. But, you can switch out the active theme before you call it an then switch it back (the try/finally is important, so that you don't end up with the wrong active theme in case of an exception).

The service names for the two used services is theme.manager and theme.initialization.


Can't add new language to a Drupal 8 installation

Uff, silly me!!! The problem was that the block that shows the link to add a new language was removed from my admin theme. Ok, I hope this helps somebody else with a similar problem too.


The Views Module and Contextual Filters

I believe the Views module can accomplish all of your requirements.

Contextual filters will allow you to feed arguments into View using URL components.  You can customize your URL's using Views re-writing features.

Video Tutorials:

Check out Johan Falk's video series called "Taming The Beast: learning Views With NodOne"

Video 17 will show you how to rewrite field output so you can build the proper links.

Videos 19-24 should cover most of what you need regarding Contextual Filters.


This looks like a CSS issue with your template rather than a Webform/Drupal issue.

The webform module adds a default ".form-item" class to the wrapper DIV around each form element.

Try adding "clear:both;" to that class to force the form elements to vertically stack. Something like this:

.form-item {
   clear: both;
}


Migration doesn't work when executed with cron

It seems that the path to drush was wrong when the script was running by cron. Lesson learned - I should be using full paths when working with cron.


Quickly, it's $block['content']=module_race_results(); in your hook_block_view(), and $blocks['raceresults']... in your hook_block_info() so it matches your hook_block_view().

More precisely, this is probably more of what you are trying to accomplish:

function module_race_results_block_info() {
  $blocks = array();

  $blocks['raceresults']['info'] = t('Race Results Block');
  // any more blocks here

  return $blocks;

}

function module_race_results_block_view($delta) {
  $blocks = array();

  switch($delta) {
    case 'raceresults':
      $blocks['subject'] = t('Race Results');
      $blocks['content'] = module_race_results();
      break;

    // any more blocks here

    }
  }

  return $blocks;
}

function module_race_results() {
  $content = "Testing Race Results Block";  // eventually this should become a renderable array instead of plain text or html
  return $content;
}


Importing data using Feeds into dropdowns/select lists/taxonomy terms

Import the same way you would if it was a textfield. The taxonomy terms will be created for you and reused for terms with the same name.


Change text on "Create new Account" button makes administration created user registration fail

That code works without a problem for me. I hope you didn't change the code in Drupal's user module directly?

You should make this change by implementing hook_form_alter() in your own custom module or theme.

function MODULENAME_form_user_register_form_alter(&$form, $form_state, $form_id) {
     //your changes here
   }


hook_init is used, when you want to do something while the request is initialized,
you could use hook_preprocess_page and there set the message, checking on a custom field you added to your user, storing the date of the last information. If this is not today, then show it and update the field value.


You don't use PHP hooks to execute Javascript. You would put the Javascript you want to execute into a .js file, and then use PHP to just attach that file to any page where it is needed, for example, using drupal_add_js().

For example if you wanted to attach it to every page with a certain type of form you would put drupal_add_js() inside of a hook_form_FORM_ID_alter).

If you want it on every page all the time, you can add it to your module's .info file like so:

scripts[] 'path/to/js/foo.js


how to create domain specific domain admin

I have used Access Domain module.

What you have to do is:

A- Create a user role. Example: [domain A admin]

B- Give that [domain A admin] user permission to access the admin menu system as well as other permission you want.

C- Go to domain module settings - admin/structure/domain/roles Now restrict the [domain A admin] to the domain you want.


What is the SQL query to filter og Admin Accounts?

This worked nicely... how can I make this available in a view?:

SELECT
a.label AS `Group Name`,
a.gid AS `Group ID`,
a.etid AS `Node ID`,
b.type AS `Type`,
b.uid AS `Owner ID`,
c.name AS `Owner Username`,
d.realname AS `Owner Realname`,
e.rid AS `OG Role ID`
FROM `prefix_og` a
LEFT JOIN `prefix_node` b
ON a.etid=b.nid
LEFT JOIN `prefix_users` c
ON b.uid=c.uid
LEFT JOIN `prefix_realname` d
ON b.uid=d.uid
LEFT JOIN `prefix_og_users_roles` e
ON b.uid=e.uid


Manage Display page not displaying anymore

after playing around in the database for awhile and trying things (I backed it up first) I found the problem in the field_group table by deleting all the default user groups I can now see and edit the manage display page for the account


Ok so since you already have a url field:

Set up a new rule where the event is Content is viewed of type YourContentType.
Add a Page redirect action.
For the destination use your field as a replacement pattern. So something like: node:field-url.

Just take note that you won't be able to view your content with this rule. But you can still access the edit page using the content management interface.

Just for your information, if you DO get access to the code:

You can use hook_node_view to create redirects. Since you already have the event URL in the node data you can use a drupal_goto.

Here's a snippet I found in a related question. I changed some things though.:

module_node_view($node, $view_mode, $langcode) {
  if ($view_mode == 'full' && "Conditions") {
    // Change $node->url to what works.
    // Use the devel module and krumo() to check the contents of $node.
    drupal_goto($node->url);
  }
}

I've assumed you're using Drupal 7.


Create my own slideshow like views_slideshow and views_galleria?

Your question lacks a lot of information about what you already have in place but I'll try my best to answer you. You have a couple of options here.

Clone the nivo_slider implementation an use your own javascript in place of nivo.
Add your JS to the page using drupal_add_js and call the necessary functions to init the js.


There is three sides to the question.

One is to make dropdown multi-columns menu, also called mega menu. The Superfish module should provides that. But I'm sure there are others.

The second is to have pictures associated with the menu entries. One solution is to use pictures associated to the pages linked from the menu. If all the pages are nodes, this can be done by using a file (or media) field. Another solution is to use picture associated to taxonomy terms. And to use these terms as categories for the pages (through classic term-node association or any other solution). To get the picture for a menu entry, simply get the image for the term associated with its page.

Instead of looking for the pictures of menu entries when building the menu, which could be query intensive, I would rather use a custom menu callback to deliver the picture of a menu entry. The menu callback takes a single argument, the menu path, and ends by issuing a redirect (ie. drupal_goto()) to the picture to use. Off course, use an image style to resize the pictures to fit in the menu.

The third question is to automatically generate a menu from the products list (nodes). I'm not sure this is actually wanted. The menu in Drupal are dynamic and can be edited at any time by users with the right permissions. On creation a node can be placed in a menu. If automatic menu are needed, custom code may be needed. The Auto Menu provides this feature even if it has not been ported to Drupal 7. The Taxonomy Menu produces menu from taxonomy hierarchies, so if product are terms this can work too. If coding is an issue, the Rules menu can provide the necessary tools to implement any custom menu entry creation logic. The solution really depends on the actual site structure.

Off course, you can also bypass the menu system and produces your menu using Views or custom code, but it means you will end up with a full-custom solution which won't be able to re-use any existing module, or even code snippets, targeted at normal Drupal menu.


How do I remove the colon from my field labels?

The answer is definitely to use field.tpl.php. If you look at the source for that file you can see the offending lines:

<?php if (!$label_hidden): ?>
  <div class="field-label"<?php print $title_attributes; ?>>
    <?php print $label ?>:&nbsp;

<?php endif; ?>

(spacing and indentation mine for clarity).

Removing the colon is as simple as replacing the above lines with:

<?php if (!$label_hidden): ?>
  <div class="field-label"<?php print $title_attributes; ?>>
    <?php print $label ?>&nbsp;

<?php endif; ?>

I've just tested that on a blank Drupal installation and it works perfectly; no more colons after field labels.

If you're already doing the same thing, but not getting the correct results, then I can think of one or two things that could be going awry:

You've put your custom version of field.tpl.php into a module folder, rather than in your site's active theme folder (it needs to be in the theme folder).
Another module/element in the system is also overriding field.tpl.php, in a more robust manner than you currently are. Seeing if this is the case will involve the always-tedious  disabling of each enabled module to determine where the problem is coming from.

You won't be able to make the change with a template preprocess function, as the colon is hard-coded into the template file.


Should you upgrade?

All contrib modules will slowly shift major version. If you don't follow suit, you risk needing to re-invent the wheel more often than otherwise necessary. Most module maintainers have since long ago shifted focus to D7. A few have even begun maintaining their D8 version.

D6 will become unsupported, and have no more security updates after D8 is released.

How do we make it painless?

I don't think there's an answer that can be applied across all sites, but here are some general guidelines.

Features needs to be "released" (warning, lots of reading), and then upgraded by their providing module, and finally re-added to their respective features.
Use the Migrate module to easily test getting content over.
If possible, run both versions at the same time. Hide the fact as well as you can, possibly using a reverse proxy. This is non-trivial to accomplish, but ensures that when you move your last piece of functionality from D6 to D7, parts of your D7 site has been live for a long while already, and you know that it's stable. As one quick example of a relatively general measure one can take to ease this, Entity API can allow you to redefine where an entity reads/writes its data.
Often Contrib-space will solve a common problem that Core later decides to incorporate. Switching to these techniques for problem solving everywhere it's relevant will allow you to "partly" upgrade a current DX site to DX + 1, making the gap during the complete upgrade much smaller.
Two examples of this are below, but this list could probably be much longer:

Use Panels and Page manager instead of modules like Context and Spaces. The Pm+P approach to site building is the foundation of a huge re-write of core for D8.
Use Guzzle instead of Http Client. Guzzle is the official http-client for Drupal 8.

Anything else?

Nothing that comes to mind at the moment.


You can use the 'Before saving a commerce order' trigger in Rules.  It's right there in the 'Commerce Order' section.  Then you don't need a save action since it's about to be saved already...

That should do it for you!


How do I get rid of  tag in manually created block?

It's in fact because of the text input format. Going to admin/config/content/formats and removing the checkbox for

Convert line breaks into HTML (i.e. <br> and <p>)

for the input format you're using should do the trick (re-save the block, of course). Also, if you use WYSIWYG editor, it could do some formatting for you and put the image in <p> tag.


You want to read the Cacheability documentation. it says render arrays, but it also applies to response objects.

ResourceResponse implements CacheableResponseInterface, which has the addCacheableDependency method.

If in any way possible, you want to avoid disabling the cache (which you would do by setting the cache max age to 0), but add the necessary cache contexts and cache tags.

In your cache, that means all you need to do is $response->addCacheableDependency($account).

You also don't need getAccount(), just use currentUser() directly, it's a proxy.


Set default registration type for content type

Since Registrations are fields make it a required field.

And then from the default values select the type of registration you want to force for a content type.


Site performance , cache not working properly

Slide #85 from my performance presentation talks about max packet size in MySQL, you need to increase that value; SET GLOBAL max_allowed_packet=33554432; or change it inside of the configuration file https://dev.mysql.com/doc/refman/5.7/en/packet-too-large.html


The second option would be better, because of aggregation.

For the first option, if you turn on aggregation on your site, the files will be bundled by media query. So, in your case, you would have at least 4 bundles, so 4 requests to fetch your site CSS files.

For the 3rd option, the browser will request the imported CSS files seperately, so you lose the benfit of aggregation completely.

If you put the media queries inside the CSS files, they will be aggregated together, resulting in only one bundle. This is better for performance, especially for mobile devices.


So, Basically I was trying to piece together a few views under one local task tab for a content admin. I finally figure out how to write a small module to create the structure and used views path and menu to point to the sub task items. See below.

/**
 * Implements hook_menu().
 */
function secondary_tabs_menu() {
  $items['node/%node/update'] = array(
   'title' => 'Update',
   'page callback' => 'price_callback_function',
   #'access arguments' => array(2),
   'type' => MENU_LOCAL_TASK // This adds the 'Update' tab to the node path
 );

 $items['node/%node/update/price'] = array(
   'title' => 'Price',
   'type' => MENU_DEFAULT_LOCAL_TASK,
   'weight' => -10
 );

 $items['node/%node/update/test'] = array(
   'title' => 'Test',
   'page callback' => 'callback_function',
   #'access arguments' => array(2),
   'access callback' => TRUE,
   'type' => MENU_LOCAL_TASK // This adds another tab under 'Update'
 );
 $items['node/%node/update/test/test1'] = array(
   'title' => 'Test1',
   'page callback' => 'callback_function',
   #'access arguments' => array(2),
   'access callback' => TRUE,
   'type' => MENU_LOCAL_TASK // This adds another tab under 'Update'
 );
 $items['node/%node/update/test/test2'] = array(
   'title' => 'Test2',
   'page callback' => 'callback_function',
   #'access arguments' => array(2),
   'access callback' => TRUE,
   'type' => MENU_LOCAL_TASK // This adds another tab under 'Update'
 );

  return $items;
}

/**
 * Implements hook_admin_paths().
 *
 * Show admin theme on the participants totals report.
 */
function secondary_tabs_admin_paths() {
  return array(
    'node/*/update' => TRUE,
    'node/*/update/test' => TRUE,
    'node/*/update/test/test1' => TRUE,
    'node/*/update/test/test2' => TRUE,
  );
}

I also found out the best way to make those views show up within the admin theme. See hook_admin_path().


How to tell if a view is cached from generated HTML output?

The answer you linked to is wrong. X-Drupal-Dynamic-Cache only exists in Drupal 8. Beyond that, the answer itself is also wrong. Will comment there.

In Drupal 7, you can't tell that the view is cached based on output (HTML markup) or headers.


"The specified file temporary://fileXXXXXX could not be copied" warning

The temporary directory set under Admin > Configuration > File System is incorrect or does not have write permissions. Typically for local dev (on Linux/OSX machines) this path can simply be /tmp. On Windows, I believe it is C:\temp.

See: Configuring the temporary directory


Regions do not display in "Demonstrate block regions"

Try switching the administration theme you're using, to a theme shipped with Drupal core.
Or refer to the article "Demonstrate block regions" missing in Drupal 7 for some more hints about this. Here are some quotes from it:

On a fresh install, you should see "Demonstrate block regions" when you go to admin/structure/block.  If somebody has played around with the block settings on your Admin theme, this selection might disappear.
Make sure that “System help” is assigned to a region (probably ‘Help’) in your Admin theme (probably 'Seven’).  Go to 'configure’ for the 'System help’ block and make sure that the visibility settings are not restricted in some way.

Another possibilities you may want to try (haven't had a chance myself to try that, sorry):

inspired by Issue # 996214, which is about another theme though:

Verify if the "System Help" block is placed in the help region.

inspired by Issue # 1392206, which is about another theme though:

You might need to turn on the Help module in core modules.


There is a module that does what you want, and it isn't XML Sitemap but just Sitemap:

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

  This module provides a site map that gives visitors an overview of
  your site. It can also display the RSS feeds for all blogs and
  categories.

  Drupal generates the RSS feeds automatically but few seems to be aware
  that they exist.

  The site map can display the following items:

  A message to be displayed above the site map.
  Any books.
  Any menus that will be displayed fully expanded.
  Any vocabularies, with all the terms expanded. Optionally with term depth, node counts, and RSS feeds.
  A syndication block, the "more" link goes to the site map.

Then:

  because the site already has too many modules?

There is really no way to quantify this for you. There isn't necessarily a module limit, your limit is defined by the limits of your hosting space. The performance impact of adding the Sitemap module, vs spending hours doing it yourself (to reach the same point but with 10x the maintenance) is negligible, especially since you can cache it in Drupal and use things like Varnish or Memcache if your host supports it (if not, find an updated host!). You will be fine.


Display images instead of nodes titles in Drupal 7

For non-coders: the views slideshow module (or something similar) could easily solve this problem without requiring custom code to maintain.
From http://drupal.org/project/views_slideshow:

Views Slideshow can be used to create a slideshow of any content (not just images) that can appear in a View. Powered by jQuery, it is heavily customizable: you may choose slideshow settings for each View you create.
Potential uses
News item slideshow (such as the title, image and teaser of the last 5 news articles submitted)
The Last X number of X submitted (images, videos, blog entries, forum posts, comments, testimonials, etc.).
Rotate any image, based on any filters you can apply in views.
Hottest new products for any ecommerce drupal site.
Rotate contact links, share links, etc.
Heck, you could rotate entire nodes, categories, image galleries, etc. I wouldn't suggest it, but you have that power.
Its also a great space saver. Places where you had multiple images or multiple items such as RSS feeds or category listings can now be presented in a slideshow.
The possibilities are really endless, as the more ways you can think of to categorize and add to views, the more you can rotate.


JPG user photos not displaying in Drupal 7

"username picture" is likely the alt text applied to the image. So it's trying to render an image, but failing because the web server can't find it. If you check the page source, is it trying to show the image with a .png extension instead of .jpg? If not, is the path correct?

If either the extension or the path are wrong, this could be a problem with the template. Perhaps it was hard coded in the past and settings have changed since?


Multilevel Menu but all in the same drop down?

Bootstrap has recently removed the sub-menu features from version 3.x, so it won’t support the multi-level menu anymore. But drupal 8 has multi-level menu structure. I am going to show you how to get back the sub menu features in bootstrap and how to render multi-level menu in the drupal 8. Just copy and paste the following css in your custom css, its has been taken from the bootstrap version 2.x with some custom changes, The following article would help to create multi-level menu in drupal 8


Import soap webservice xml to node with Feeds?

I assume you have no access to change the feed provider.

There are couple of additional contributed modules which handle different types of authentication for the feeds module.

This handles regular http authentication, which is more likely with soap:
https://www.drupal.org/project/feeds_httpfetcher_aa

and this one is for oauth which ia also possible with soap:
https://www.drupal.org/project/feeds_oauth


How to make select option works like a button?

You can write a simple jQuery script for achieving this.

$('select').on('change', function() {     // you can refine this with your field id.
  if( this.value == 'reset' ) {           // Replace value for your 'reset' option.
    $('#yourid').find('form')[0].reset(); // Replace id here
  }
})


How to update field values of a content type's nodes when when viewing a particular content type page

hook_node_view() will be used in this scenario.

function hook_node_view($node, $view_mode, $langcode) {
  if($node->type == 'park' && $view_mode == 'full')
   {
    /* change the value of proximity here after applying your formula.
      * Here you have complete node array, so you alter the result easily here.
    */

   }
 }


How to change operator in schema.xml and configure site for AND search

You need not to edit the Solr_Base_Query.php file just add the following line of the code in your module

function modulename_apachesolr_query_prepare($query){
$query -> addParam('q.op', 'OR');

}


Forms - Save Draft and unique user access code to Resume (on any computer)

You could always have users register accounts, use their passwords as the access code, and then use one of the revision management modules (Workbench, Revisioning/Workflow, etc.) to handle draft/publishing.


Module that allows access to node based on roles

Drupal offers a wide selection of node access modules.

Many (but not all) of these offer role based access control.

While still only in beta for D7, Content Access is a module I personally use for role based node access control. I regard it as stable for role based access control.  However do not use it for lower resolution (user based) access control, as this mode is not yet stable.

  This module allows you to manage permissions for content types by role and author. It allows you to specifiy custom view, edit and delete permissions for each content type. Optionally you can enable per content access settings, so you can customize the access for each content node.

One of the advantages by this module is that it is fairly straightforward to control access to individual nodes by role.


Change permission on Content Overview page

This is such an old question, but I had the same question and hiding it in css is not the answer.

The correct answer IS to enable the Actions permissions (VBO) (actions_permissions) module.  That will allow you to set which roles can perform bulk operations.


I've used this module successfully today actually - with no configuration alterations.

One reason for things not working for you could be your theme which after all does control the markup for your site.


Drush Aliases into Remote Hosts not Working - Tried everything

Try this first:

ssh-copy-id username@url.com

Make sure that the username and url match what is in your alias, of course.  The "Permission denied" error is complaining that the remote site does not have your public key stored in its "authorized keys" file.  ssh-copy-id will fix this for you.

If you are on a Mac, you can get ssh-copy-id from here:

https://github.com/beautifulcode/ssh-copy-id-for-OSX

It should be bundled with openssh on linux.


Edit Drupal Form in "popup" just like it is done in Drupal Views Edit form

I think what you are looking for is the ctools modal functionality.
Without further digging into that - because I think the following tutorial is comprehensive, easy to understand and complete - here is a link that will help you: https://www.deeson.co.uk/labs/insert-form-pop-modal-ctools-and-drupal-7

Some important things you should not forget:

Add the ctools module as dependency.
Add the callback to the menu.
Include the ctools js files on the page where the link to the title popup is.

ctools modal helped me a lot! Give it a try!