Environment dependend workflow with configuration management

Drupal 7

Have you considered adding some intelligence to settings.php? You could test $_SERVER['HTTP_HOST'] there, and set $conf['some_variable'] accordingly. Below are some examples from Pantheon. They use their own environment variables to test which environment is running, but you can achieve the same by testing $_SERVER['HTTP_HOST'] or maybe testing file_exists('some_file_which_identifies_environment') - whatever is convenient.

// All Pantheon Environments.
if (defined('PANTHEON_ENVIRONMENT')) {
  // Drupal caching in test and live environments.
  if (in_array(PANTHEON_ENVIRONMENT, array('test', 'live'))) {
    // Anonymous caching - enabled.
    $conf['cache'] = 1;
    // Block caching - enabled.
    $conf['block_cache'] = 1;
    // Expiration of cached pages - 15 minutes.
    $conf['page_cache_maximum_age'] = 900;
    // Aggregate and compress CSS files in Drupal - on.
    $conf['preprocess_css'] = 1;
    // Aggregate JavaScript files in Drupal - on.
    $conf['preprocess_js'] = 1;
  }
  // Drupal caching on dev environment, and all multidevs
  else {
    // Anonymous caching.
    $conf['cache'] = 0;
    // Block caching - disabled.
    $conf['block_cache'] = 0;
    // Expiration of cached pages - none.
    $conf['page_cache_maximum_age'] = 0;
    // Aggregate and compress CSS files in Drupal - off.
    $conf['preprocess_css'] = 0;
    // Aggregate JavaScript files in Drupal - off.
    $conf['preprocess_js'] = 0;
  }

  // Minimum cache lifetime - always none.
  $conf['cache_lifetime'] = 0;
  // Cached page compression - always off.
  $conf['page_compression'] = 0;

  if (PANTHEON_ENVIRONMENT == 'dev') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-X';
  }
  else if (PANTHEON_ENVIRONMENT == 'test') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-Y';
  }
  else if (PANTHEON_ENVIRONMENT == 'live') {
    // Google Analytics.
    $conf['googleanalytics_account'] = 'UA-XXXXXXXX-Z';
  }
}

Drupal 8

The same approach can work in Drupal 8, except that the global configuration variable is named $config. This is documented here: Configuration override system and that page shows the example:

$config['system.maintenance']['message'] = 'Sorry, our site is down now.';


You could try menu_get_object(), it's slightly cleaner:

$term = menu_get_object('taxonomy_term', 2);
if ($term) {
  // You're on a term page and have the loaded object in $term
}


Display Suite layouts not working for field collections Edit\Add forms

Just had a similar problem with ds and heartbeat module. Maybe my solutions also works for this problem. Just enable the needed submodules in ds - that fixed the problem.


How can I call hook_user_presave() only when an account is updated, not created?

On creation $account will have is_new set to true. And other minor differences, like it'll not have created property set yet.

object(stdClass)#92 (18) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(3) "::1"
  ["roles"]=>
  array(3) {
    [2]=>
    bool(true)
    [3]=>
    int(0)
    [4]=>
    int(0)
  }
  ["cache"]=>
  int(0)
  ["administer_users"]=>
  bool(true)
  ["name"]=>
  string(7) "test"
  ["mail"]=>
  string(14) "test@example.com"
  ["pass"]=>
  string(3) "aaa"
  ["status"]=>
  string(1) "1"
  ["notify"]=>
  int(0)
  ["timezone"]=>
  string(13) "Europe/Warsaw"
  ["signature"]=>
  string(0) ""
  ["picture"]=>
  NULL
  ["picture_delete"]=>
  int(0)
  ["picture_upload"]=>
  string(0) ""
  ["signature_format"]=>
  string(13) "filtered_html"
  ["init"]=>
  string(14) "test@example.com"
  ["is_new"]=>
  bool(true)
}


Menu doesnt appear on custom 'not found' page

Drupal doesn't render the region of your theme that your primary menu is in; there's a module to change this behavior:

  On 404 Not Found error pages, Drupal will skip rendering of several
  pieces of your website for performance reasons. Some of these include:

  The "Left" and "Right" regions of your theme.
  The "Primary links" block and any other menu links block.*
  The Primary links and Secondary links of your theme.*

  *Unless you have configured a "Default 404 (not found) page" on
  admin/settings/error-reporting.

From 404 Blocks module description.


I facing a problem when i want create two registration forums by using (profile2 & profile2 registration path) modules?

Fully not clear problem but you can try by this way

Hook: user A, user B
User: user-profile.tpl.php

if((arg(A)=='user') && is_numeric(arg(1)))
{
$profile = profile2_load_by_user(arg(1));


Is it possible to create in Drupal a multiple pages on single page

Of course it's possible, with or without Drupal. Here is the second link from google: Ajaxify Drupal with JQuery Ajax

  Ajax links API module help you to load any content to a specified DIV or ajaxify whole drupal site, using JQuery Ajax. This module will also load JS for Ajax-loaded content by using Drupal.attachBehaviors(). In case you dont want to load js or css, you can alter tpl for path/node type.


You could create a simple text field to store the string, and then a custom formatter to render it as an image. Then under "Manage display" for the content type, you choose the formatter you just created.

If you don't want to create the custom formatter programmatically, you could use the Custom formatters module.

If you want to use the value of the text field for more than one output element, you could create Display suite custom fields using this value e.g. as a token.


Where do I add my own javascript or jquery so that it executes after the DOM is ready in Drupal 7?

There is a syntax error in above code. Change the js file contents to below. It will work as you expected !

jQuery(document).ready(function () {

    // Make the parent menu item of the active sub-menu item also active.
    jQuery('#block-system-main-menu li.active-trail > a').addClass('active');
});


Some feedback please on my hook_search_execute function?

The return $results was inside the foreach loop, which stopped the iteration, hence only 1 result.


How to do OR operation on one filter's options of Views 3

You should be able to click the arrow next to the criteria and select "And/Or" to change this setting. Here I've added two criteria and set them to "or"


Add a new configurations block to admin/config

I have solved my own problem. The reason the links appeared where they did and not under my new block is that I've moved existing items to a new location, which means they were still in the original location in the menu configuration screen. Moving them manually to their correct location solved the problem.


Display external link using theme settings

Drupal is probably applying your default text format to your field.

Try adding a #format value to the array that matches one of your less strict input formats.


write data in another drupal website / rest

Try the following modules.

Drupal Sync

  This module allows synchronizing content among multiple websites.
  Supported entity types: node and taxonomy, menu items.

  Many hooks were used during creation of the module. It allows widening synchronization functional by developing additional modules.

Deploy

  The Deploy module is designed to allow users to easily stage content from one Drupal site to another. Deploy automatically manages dependencies between entities (like node references). It is designed to have a rich API which can be easily extended to be used in a variety of content staging situations.


...but the hook implementation from my theme never gets called:

hook_block_view_alter() will not be called for themes; it is invoked only for modules. This is why your hook is never invoked.
To implement this hook, you need to create a custom module. If you need help to create a module you can check here to start.
I strongly suggest to read block_view_alter docs too.
Look at Theme Hooks to see what you can 'hook' in your theme.
For more information about hooks look here.


How can I embed a View inside a content of a node?

Option 1
You can create a View Block. Then the view block will be available in the blocks section. Assign the view block to a region and show it on specific pages if you need to.

Option 2
Create a twig template file for your node and use
Twig Tweak

Twig Tweak module provides a Twig extension with some useful functions
and filters that can improve developer experience.
Ex:    <dd>{{ drupal_view('view_name', 'page_1') }}</dd>

Option 3
If you use Panels or Display Suite, you can embed the view as a field.


This probably isn't the best solution, however it is working for me at the moment.

Using the following php in the IMCE directory path it generates the same random number for 5 minutes.  So I can have the directory structure user/Y-m-d-H-[random number]

php: function random() {  $seed = floor(time()/(60*5)); srand($seed); $item = rand(0,100); return $item; }  return $user->name.'/'.date("Y-m-d-H").'-'.random();


Is there a reference by url widget type for term reference field as we have it for node reference field?

Closest thing is RSpliet's sandbox module:

https://drupal.org/sandbox/RSpliet/1416486


Be aware of the Main Menu not translated issue, which states:

  When using the default 'Main menu' menu, and outputting that on the sitemap, the title, or menu name, isn't translated ...

I just double checked in a multi language site also where I have the i18n Menu Translation sub-module enabled (one of the Internationalization sub-modules).

I tried editing the Sitemap menu item to be translated, by navigating to admin/structure/menu/manage/navigation. From there I tried to use the "translate" link (for the Sitemap menu item), which one would expect that it can be used to translate that menu item.

However, after doing so, I only get something like "You are not authorized to access this page."

This issue appears to be fixed in the most recent dev version.


Take a look in this topic below

How to set the language for the user while it is created?

Just read it quickly, this seems  to be what you need?


How does routing order / matches effect performance?

The order doesn't matter, routes are stored indexed by name. The first and the second route have a different component count, so they can't interfere. The second route gets priority over the third, because it has one more fixed component. So in this case the route matching doesn't need any complex calculations. In general route matching rarely affects performance  because successful matches are cached.


Same CSS file generates under different folder when I flush

It's in a theme, module, library, Drupal's misc folder, or basically anywhere that the web server can read; that's as much as can really be said without more info.

To get that info, turn off css aggregation in Configuration -> Development -> Performance, then try inspecting the page again. Now you should see the original, unaggregated source file of the rule.

Bear in mind that if you're compiling Sass/Less to CSS, the file you find might not necessarily be the last place you need to look - it depends how the compilation actually happens in your application. But it gives you a good starting point at least.

Also bear in mind the nature of Cascading Style Sheets - if you introduce an identical rule with new styles after the original, it will take precedence. So as an alternative to tracking down the original, you could just add a new css file to your theme and give it an appropriate weight so it loads last and your styles "win".

Don't forget to switch aggregation on again afterwards if you need it.


Disabling the media browser private download option , showing public download as an option

Upgrade to the latest 2.x version of the media module and file entity module.

This issue was addressed in https://drupal.org/node/2001074

There is now admin configuration at the file system settings page.

In my opinion the configuration ability still needs some improvement but it dos the job for now.


How can I Pass a javascript variable value to PHP in Drupal 7

If you want to pass the value during loading page. You can do it by appending the JS value as query variable in path (e.g. http://www.example.com/new/page?demo=true) for requesting the next page. In PHP, you can use API drupal_get_query_parameters to read the data.

// retrieve data from www.example.com?data=value
$query = drupal_get_query_parameters();
$value = $query['data'];


Bootstrap theme doesn't work on mobile device (but work on computer, even when resize browser to min width)

I tried from another mobile (mine is nexus 4) and the problem doesn't appear.

Finally, I installed the module bootstrap_library and the problem disappeared.


How to show user info in DIV based on link click?

Have a look at the Colorbox module. Some more details about it (from its project page):

Colorbox is a light-weight customizable lightbox plugin for jQuery. This module allows for integration of Colorbox into Drupal.
Images, iframed or inline content etc. can be displayed in a overlay above the current page.
Features

Works as a Formatter in entities and in views.
Excellent integration with core image field and image styles and the Insert module
Choose between a default style and a number of other styles that are included.
Style the Colorbox with a custom Colorbox style in your theme.
Drush command, drush colorbox-plugin, to download and install the Colorbox plugin in sites/all/libraries.

Credits: rooby (in a comment below the question).


Checking if module has the right output on multilingual pages with simpletest_clone

I would set the default langauge in code first instead.

// Get the list of languages
$languages = language_list();

// Set up the new language code
$new_lang_code = 'fr';

// Make sure the required language object is actually set
if (isset($languages[$new_lang_code])) {
  // Overwrite the global language object
  global $language;
  $language = $languages[$new_lang_code];
}

and then you just need to get the front page (and Drupal should add the prefix).

$this->drupalGet('<front>');

If front doesn't work you might need

$front_url = variable_get('site_frontpage', 'node');
$this->drupalGet($front_url);


How can I have a custom module checked for deprecated functions?

Read Dries Buytaert's blog post on How to prepare for Drupal 9

drupal-check

  If you work on a Drupal site as a developer, run drupal-check. Matt
  Glaman (Centarro) developed a static PHP analysis tool called
  drupal-check, which you can run against your codebase to check for
  deprecated code. I recommend running drupal-check in an automated
  fashion as part of your development workflow.

Link: https://github.com/mglaman/drupal-check

Upgrade Status

  If you are a site owner, install the Upgrade Status module. This
  module was built by Acquia. The module provides a graphical user
  interface on top of drupal-check. The goal is to provide an
  easy-to-use readiness assessment for your site's migration to Drupal
  9.

Link: https://drupal.org/project/upgrade_status

Maybe also learn the background info of drupal-check reading Matt Glaman's blog post about Testing your Drupal code base for deprecated code usage with PHPStan.


Resolution of Recaptcha Error in Drupal 7 forms

I personally use the Are You a Human PlayThru Module:

PlayThru is designed to be more simple, more intuitive, and more fun than other CAPTCHA options. We use game mechanics to create an experience that’s more enjoyable than figuring out what that awful squiggly text says.
PlayThru is also more secure. Because users interact directly with PlayThru, we can analyze that interaction and track the resulting data to generate a Human Confidence Score: our level of confidence that a user is an actual human.

You can also check out a video about it this module here:
Drupal 7 Are You a Human PlayThru Module - Daily Dose of Drupal episode 78

Update
The Are you a human PlayThru service has shutdown, I recommend you go with ReCaptcha

Uses the Google reCAPTCHA web service to improve the CAPTCHA system
and protect email addresses.
reCAPTCHA helps power massive-scale online collaboration.


Geshi does not detect libraries on Drupal 7

The files should be copied, for example, in "sites/all/libraries/geshi" or "$config/libraries/geshi," where "$config" is the directory containing the settings.php file used for the Drupal site.
In the first case, the class.geshi.php file is put in "sites/all/libraries/geshi/class.geshi.php," and the "geshi" directory that is in the downloaded archive is put in "sites/all/libraries/geshi/geshi."

As for where the Libraries API module looks for the directory containing the library files, the documentation comment for libraries_get_libraries() reports the following text:

  Returns an array of library directories from the all-sites directory (i.e. sites/all/libraries/), the profiles directory, and site-specific directory (i.e. sites/somesite/libraries/).

The site-specific directory is the one that I reported as "$config/libraries/geshi."
The module doesn't look in "sites/all/modules/libraries."


View / Twig Extension : Display other items with the same field value

I finally found a solution with a function in my Twig Extension.
I don't know if it's a clean way to do it but it works.

The function is called from the twig file :

{% set parts = partsSameId(part_id) %}

This is the simplified code inside the twig extension php file :

<?php

public function partsSameId($part_id) {

    // Get nodes with the same part_id
    $nids = \Drupal::entityQuery('node')
      ->condition('type','my_custom_content_type')
      ->condition('my_custom_field_for_part_id',$part_id)
      ->execute();

    // return array
    $html = [];

    // For each node returned, get the title.
    $i = 0;

    foreach ($nids as $the_node){
      $node = \Drupal::entityTypeManager()->getStorage('node')->load($the_node);
      $part_name = $node->getTitle();

      // return array
      $html[$i]['part_name'] = $part_name;

      $i++;
    }

    return $html;
  }


Views Link Display Settings Is Not Accepting External URL

You must be using an older version of Drupal because this has been fixed: Views throws InvalidArgumentException in More Link with external URLs.

I tried it on the latest Drupal 8.6.2 and it accepts external urls (your example) without any errors.

You should update to the latest version, even more so for security fixes.


added in views header section is automatically closed: How do I avoid it?

Method 1: Unfiltered text

When setting up the header and footer in your view, select Global: Unfiltered text. For the header enter
 and for the footer type in
.

If you then override the default views-view.tpl.php, stripping out everything except

<?php print $header; ?>
<?php print $rows; ?>
<?php print $footer; ?>

... you should achieve output similar to:

Method 2: Use attachments

This might be ideal if editing the header and footer through the Views UI isn't important, but you want some flexibility in the output that wraps around your rows; for example, if you wanted it to be dynamic.

Override the default views-view.tpl.php so that it looks like this:

<?php print $attachment_before; ?>
<?php print $rows; ?>
<?php print $attachment_after; ?>

In a custom module you would then implement hook_views_pre_render():

function MODULENAME_views_pre_render(&$view) {
  $header_str = '
';
  $footer_str = '
';

  if ($view->name == 'your_view_name' && $view->current_display == 'your_display_name') {
    $view->attachment_before = $header_str;
    $view->attachment_after = $footer_str;
  }
}

(Remember to clear the cache after adding the function.)

Method 3: Simple template override (simplest but least flexible)

Override the default views-view.tpl.php and simply replace all of the mark-up with

<?php print $rows; ?>

Hope that helps!

A couple of links that might be useful:

Views template files
Drupal API hook_views_pre_render()


Here is the answer to the riddle.
My live VM is on an older version of Debian, different document root, different apache2.conf.
It is much easier to edit apache2.conf in the newer version, and that is why it was working:

    Options Indexes FollowSymLinks

AllowOverride None

AllowOverride All
Require all granted

In older version, I copied apache2.conf to something else and replaced Deny for Allow, like so:

    Order allow,deny
    Allow from all
    Satisfy all

.
Completely different, I am mulling to move server to testing version, in spite that everybody advices against it.


hook_schema() should return an array that defines a database schema.


You cannot: The part of the path after the first slash cannot be dynamic, so you cannot use /{username} as path. This is explicitly stated in Structure of routes, which describes path as follows.

  path (required): The URL to the route, with a leading forward slash (e.g., path: '/book'). You can use dynamic properties by including them in curly braces. (e.g., path: '/node/{node}/outline'). These will be passed along as arguments via parameter converters to the controller/form (see below). Note that the first item of the path must not be dynamic.

You can use /profile/{username}, but /{username} doesn't work.


How to pass extra information to search results page using hook node_api

You could try this

<?php

function your_custom_module_name_preprocess_search_results(&$variables){
    $var['info'] = 'the_value_you_want_to_include';
}
?>

Now you can use the variable $info in search-result.tpl.php.


Drupal autocomplete form, multiple values

Add a select list to your form. Add some #ajax to your textfield. Every time the textfield changes content, add the value (via #ajax) to your select list. Use the values of your select list in the submit callback.

OR

You could to it by attaching a custom JavaScript file using $form['#attached']['js'] with some good old JavaScript to fetch the users and add them to the csv textfield (autocomplete). Then split the values in the submit and add them to the database.

OR

Just use a select if that's OK with you.


Partial answer, but in the views settings page, you add a relationship to the field that holds the file.  Then, when you add a field, you should see an option for File: Size in the list.  Other fields for file into appear, but mtime isn't one of them.

A hackish way to get mtime is to use stat in your view template, but I would do that as a last resort if you can't find a module to add this as a view field.


Drupal Commons, can't break-contact error

to resolve this problem, two patches are needed:

1  patch for the trusted contacts module as discussed in comment #2 here:
https://www.drupal.org/project/commons/issues/2588155

2... and a patch for the membership-delete-action
 .../profiles/commons/modules/contrib/og/includes/actions/membership_delete.action.inc
as discussed here
https://www.drupal.org/project/opigno_lms/issues/2953675

works for me...
d


Show if a user is online, idle, or offline on their account page?

I guess the problem lies here, for starters:

//- The user has logged in at least once
  if ($user->getLastLoginTime()) {
    if (account_is_logged_in_less_then_thirty_minutes($user->id())) {
      $status = 'Online';
    }
    else {
      $status = 'Absent';
    }
  }
  else {
    $status = 'Offline';
  }

The if ($user->getLastLoginTime()) { will be TRUE always, after the user has logged in once. This will prevent the else from ever being hit, thus, 'Offline' never gets set.

I don't know what the difference is for you in terms of time between "Absent" or "Offline", but it sounds like you'd want to figure another calculation here to know what to set status to.

This can be simplified to:

function bootstrap_subtheme_front_office_preprocess_user(&$variables) {
  // get user object
 $user = $variables['elements']['#user'];

 $last = $user->getLastAccessedTime();
 $now = \Drupal::time()->getRequestTime();

 switch ($last) {
   case ($last > ($now - 900)) :
     $variables['status'] = 'Online';
     break;
   case (($last < ($now - 900)) && $last > ($now - 1800)) :
     $variables['status'] = 'Absent';
     break;
   default:
     $variables['status'] = 'Offline';
     break;
 }
}

Then break down smaller functions to evaulate the time against how many minutes ago they were active... use it in the switch above.

getLastAccessedTime() does:

  The timestamp when the account last accessed the site.

  A value of 0 means the user has never accessed the site.

So you don’t need a db_select.


You are not supposed to see the settings form in Manage Fields > edit (a specific field) > Field settings as you expect. Formatters are used for managing the display of fields (theming). So, go to 'Manage Display' tab (for your Content Type) and choose the view mode for which you want to manage the button visibility (default, full content, teaser, e.t.c). Find the field(s) you wish this functionality to be applied, and then select as 'Format' option, the label of the formatter you just created, which in this case is 'Copy to Clipboard'. Then if you click on the cogwheel icon on the right, you will see your settings form. Note that this setting will be applicable to all instances of this CT for the specified field for the specified view mode.

If you want other fields of the same CT as well, you need to repeat the process for the other fields as well. If you want this functionality for additional displays of this CT (e.g. teaser view), then you need to repeat the process. And of course, repeat the process for all CTs/view modes/fields as well. This is because Drupal offers much flexibility and variety in displaying content. If you want such a functionality to be applied globally (e.g. for all CTs, for all text fields) then perhaps you should consider another strategy; a new theming function or override of an existing one for example.


How to "flag" product that had already been purchased before "flaging feature" was added?

If you can think of a way to create a view which contains 1 row for each product and the user who actually bought such product, and which wasn't flagged with this "already purchased" flag, then you can use such view as part of an actual solution for your question. In that case, you could get this to work by using the integration of VBO with the Rules module, as further detailed below.

Step 1: Create a Rules Component

Create a (rather basic) Rules component to flag a product by a user. Here is a variation of such component in Rules Export format (which processes nodes instead of products):

{ "rules_flag_node_by_a_user" : {
    "LABEL" : "Flag node by a user",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag", "rules" ],
    "USES VARIABLES" : {
      "flagging_user" : { "label" : "Flagging user", "type" : "user" },
      "flagged_node" : { "label" : "Node to be flagged", "type" : "node" }
    },
    "DO" : [
      { "flag_flagnode" : {
          "flag" : "your_flag",
          "node" : [ "flagged-node" ],
          "flagging_user" : [ "flagging_user" ],
          "permission_check" : "1"
        }
      },
      { "drupal_message" : { "message" : "Node flagged for user  [flagging-user:name] (uid=[flagging-user:uid])" } }
    ]
  }
}

This Rules Component uses a flag with machine name your_flag. After you edit that machine name to fit the name of your flag, you should be able to import this rule in your own site (using the Rules UI, which needs to be enabled). You can then adapt (or clone) it to make it work for your products instead of for nodes.

BTW: the Rules Action to display a message is just to see it at work while QA-testing this rule, feel free to remove that if you want.

Step 2: Let VBO do the work

This step is pretty easy ... Just build an appropriate view (of all products that still need to be flagged) and transform it in a VBO view. The clue to what you want VBO to do as an operation is ... Execute the Rules Component from Step 1. Be aware: when creating that VBO view, you really need
to create a view to "List Commerce Products".

If your Rules Component (= variation of the one in Step 1, where you flag products instead of nodes) cannot be selected as the VBO-action to be performed, then it might be because you need to change the order of the parameters used by the Rules Component: make the flagged_node (or flagged_product in your case) the very first parameter. This might be needed because it's a Rules Component with several parameters, and only the first one will be auto-populated by VBO. That might help to be able to select that Rules Component as your VBO action.

If you're not familiar with how to use VBO, have a look at the video about Using Rules components with VBO". If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.

Attention: to process like 100.000 records at once is quite a challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

Video tutorials

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework.

Happy VBO-ing while Rules-ing!


How to send an email to an Organic Group admin for every comment of their group?

You can create a rule with:

Add Event "After saving new comment" or "after udating an existing comment"
Add action to the rule, under the "Organic Groups" section, there is a "Get group managers from group audience".
Then you add a loop for this list, and then use the "Send email" from under "System" section.


Maybe you could check the selected answer here How to provide back link to page? just to confirm if you really want this kind of functionality and it also suggests some options that you can do and it's "non-recommended" level.

Hope that helps.


You could keep it really simple by using something like file_get_contents() to retrieve your file and save it on somewhere on the servers filesystem, presumably /sites/default/files. After that, you can put in the database whatever you want.

The thing is, drupal won't know what to do with that in most cases. Files in drupal must be associated with a file field. That's the way things work.


May be something like this (with hook_form_FORM_ID_alter function):

function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {
  // dpm($form);
  if ($form['#id'] == 'MY_EX_FORM_ID') {
    foreach(element_children($form) as $key => $value) {
      if (isset($form[$key]['#type']) && $form[$key]['#type'] == 'select') {
        array_shift($form[$key]['#options']);
      }
    }
  }
}

EDIT:

Ok, it seems that better exposed filter doesn't allow to remove default value from radio if settings are default (with default settings, filter -> is one of, BEF Settings -> checkboxes/radio buttons). I realized that in my project radios have been made from checkboxes type (with alter function), that's why in my example it's working fine..

here is a working example:

in hook_form_form_id_alter function:

foreach(element_children($form) as $key => $value) {
    if (isset($form[$value]['#type']) && $form[$value]['#type'] == 'select') {

      $options = $form[$value]['#options'];
      $newOptions = array();

      for ($i = 0, $optionsCount = count($options); $i < $optionsCount; $i++) {
        $optionsKey = array_keys($options[$i]->option);
        $optionsValue = array_values($options[$i]->option);

        $newOptions[$optionsKey[0]] = $optionsValue[0];
      }

      unset($form[$value]['#multiple']);

      $form[$value]['#type'] = 'radios';
      $form[$value]['#options'] = $newOptions;
      $form[$value]['#theme'] = 'select_as_radios';
    }
  }


How to show, in a view, content depending on user language or default?

Use the Internationalizations Views module, which extends the i18n module with multilingual support for views.

Also, to make view results correspond to the language switcher, add a filter for Content Translation: User's Current Language, which is the language that an authenticated user has set in the user settings (it is NOT the same as the current browser language or the site language).

If no option for the User's Current Language is available in the filter criteria form, then verify your configuration at Configuration -> Languages -> detection and selection: The order should be URL, Default, User and not something like Default, URL, User (as mentioned also in https://www.drupal.org/node/1701854#comment-6279474).

Notes:

The above may turn out to NOT be the complete answer. You may use the Entity Translation module and, in that case, there is not this option if you use it in 'entity' mode: if only some fields of the node are translatable the option is there but a bit more difficult to find. If you have the 'Body' of your nodes set to translatable entity then the option is "Body language" to be set to Current User Language.
The Internationalizations Views module only has a DEV version for D7, but right now there are over 31K users using this version. Therefor I think "DEV" is not a valid release qualifier for that version anymore, because +31K users can't be wrong, right?


My best guess is that you haven't copied across the standard block.tpl.php file into your theme. This is required (for a reason that escapes me) for overriding node and block templates.

There's a bit of a discussion about it in the comments on the link you posted.


How to upload multiple images as multiple nodes?

Check out Bulk File Nodes Module

  Bulk File Nodes allows a user to upload or import many files at once,
  and have many individual nodes created, one for each file . Where this
  module significantly differentiates from other modules like Bulk Media
  Upload is that after uploading/importing the file(s), the user is
  given the opportunity to edit all of the fields for each node in a
  single form.

  Another form to the right acts as a bulk settings form where each
  field that has a value is applied to each node's corresponding field,
  except where the user has overridden the bulk settings form by
  specifying a value in the field of an individual node.


is it ok to manually remove menu_links entries from db?

The menu_links table contains a lot of automatically generated rows. These come from the hook_menu() implementation of modules. Deleting these rows will likely result in them returning on the next time you clear the cache, because menus will be rebuilt than and the systems scans through all hook_menu() implementations adding new links.

If you look closely at the menu_links table, you'll notice there is a boolean field hidden. A value of 1 tells Drupal not to show this item in menu's.

So you can either filter out all hidden items (you only need hidden = 0 since the value -1 represents a menu callback), or you can have a look at the Drupal menu functions. There are a lot of functions with menu and tree, but if I am not mistaken you are looking for menu_build_tree.


how to get XML content over HTTP request?

Its a little bit of a learning curve , but I would recommend using the feeds module for this

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

you can then load xml (or csv) to nodes, and map its contents to nodes.
This is preferable to writing your own custom functionality.

but if you do, drupal_http_request(), and then node_save() for constructing the nodes would be the way to do things.
If you do code it yourself, Id recommend getting comfortable with running scripts with drush, as that'll be easier than battling timeouts in the browser


Render content from page.tpl.php in ajax callback, without the html.tpl.php

There is AJAXify Pages (dev version only)

  Module to ajaxify site browsing and navigation. For instance, it
  allows for continuous audio playback via Background Audio module while
  changing the content of the pages.

or AJAXify module (D5 only)

  You can always create links that load other pages via AJAX but you
  will still load a full page HTML while you may only need a single HTML
  element from the loaded page and this is what AJAXify focuses on.

If youre not planning to use any of these module take a look at THIS function
to get some idea.


The commerce_customer_address is an Address field. You can add your behavior by implementing a custom format plugin, like the one in the addressfield_example submodule.


How to remove the default "Anonymous" from comment author name?

hook_form_alter()

http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_form_alter/7

Allows you to hook in to and alter any form, including setting the default text to empty. Here's some more help on what the valid elements are:

http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html

Best way to start is to determine the form ID by creating a mymodule_form_alter() function and printing out the $form_id using print so it appears at the top of the page. (Or better still, use the devel module to print it out in a Drupal status message). Once you know the form ID, you can add an if to make sure you only act on that form and then alter the array to remove the default value you don't want.

Look at pretty much any module for an example implementation. Many modules use this hook. I can't think of any specific example off the top of my head, but there are loads.

EDIT: Here's a good Lullabot blog post on the matter... there's not much different between Drupal 6 and Drupal 7 in this regard, AFAIK:
http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6


How to add nofollow attribute to links in profile text field and url field

In your link field settings, there is a setting...

Rel Attribute rel = " "

When output, this link will have this rel attribute. The most common usage is rel="nofollow" which prevents some search engines from spidering entered links.


Drupal hide form items completely with states

Find this field in $form array and set states currently to it.
I'm not sure, but maybe it is in $form['field_plakat'][LANGUAGE_NONE][0][$fid]?
It must be somewhere in this renderable $form array.


content profile title token issue (trying to write own module)

It is not appearing because the ImageField module is using user tokens, for the image title, while your module is defining node tokens.
You can see this from the code in imagefield_widget.inc (imagefield_widget_settings_form()), which is the following one:

  $form['title_settings']['title_type'] = array(
    '#type' => 'select',
    '#title' => t('Input type'),
    '#options' => array(
      'textfield' => 'textfield',
      'textarea' => 'textarea'),
    '#default_value' => !empty($widget['title_type']) ? $widget['title_type'] : 'textfield',
    '#description' => t('Choose type of field to be displayed to the user.'),
  );
  $form['title_settings']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Default Title text'),
    '#default_value' => !empty($widget['title']) ? $widget['title'] : '',
    '#description' => t('This value will be used as the image title by default.'),
    '#suffix' => theme('token_help', array('user')),
  );

The tokens you define in your module are node tokens, which are not shown when the code calls theme('token_help', array('user')).


hide unpublished content in view, for everybody except the author

I think the similar question asked previously . You can find the solution at Use Views to display unpublished nodes to authors, but not to other users


Drupal 7 Forms API radios value not saving to the $form_state array after submitting

My mistake!

I am using AJAX to submit the form and selecting the radio button using the .attr() function.

I was using an improper name in the element selector thus nothing was technically being selected.

Hope that helps someone else!


Submit button to filter data from table select by selecting on list select

Digging in, and trying to run some pseudo code it looks like there may be a problem with AJAX callbacks and tableselect fields regarding Drupal Core.

https://www.drupal.org/node/1458824 (7x and 8x)

I would consider using the Views module with exposed filters.

You could fairly easily create a view that displays 2 articles, which exposes a state drop down list.  You could use a page or block view for the front end.

If you update your question with what you are ultimately trying to accomplish I can try to put together a more appropriate Views setup.


This was solved with a patch to coder module(7.x-1.2), introducing my custom command argument, "custom" which selects the modules i want form the database using a machine name query.

Coder review will never work on a file-system basis, since it grabs the module info from the database not the file-system.


"See Also" section inline node body text

Really the best way to do this is with multiple fields. Rather than injecting your related content block in the middle of your body, have 3 separate fields.

1) A teaser field (contains the first paragraph)

2) Related content field (This would likely be an entity reference field. You can render the referenced node with a chosen display mode.)

3) Body field (contains the rest of the post)

The other way to do this would be by dynamically splitting your content (probably with regex) and inserting your other field in the middle. Personally, I wouldn't recommend this second option.


How to update content type field programmatically

It's better to use Drupa API to do that instead of missing with the database directly. you can use field_attach_update to update your field value

$node = node_load($nid);
$field = field_language('node', $node, 'field_your_field');
$node->field[$field_language][0]['value'] = 'Your New value';
field_attach_update('node', $node);


How to adjust price in Drupal Commerce based on quantity and attributes?

Attributes
Consider using the Commerce Pricing Attributes module. Here is an excerpt from its project page:

... provides some enhancements to the Commerce Product Option and Commerce Product Attributes handling by applying pricing rules to custom product attributes.
Features:

Dynamic price calculation based on selected operators.
Cart combination based on product attributes.
Support for multi currency.
Multilingual attributes.
Different attributes and settings per product.
Price adjustments either per item or per order.
Rules integration.
Easy UI for editing and reordering attributes.

This module depends on Commerce Product Option and Commerce Product Attributes.
Refer to the video about this module for a great introduction about it.
Quantity
From your question it's not realy clear to me what exactly you mean the quantity part of it.
Which is also why I'm not convinced (yet) that you should use the modules
Commerce Price Table or Commerce Pricelist.
However, you should probably consider the Rules module, using some custom Rules, something like so:

Events = Calculate Sell Price of Product.
Actions = calculate the price, and set the price to the calculated value.

Not sure (yet) ifff you'd need some extra 'Conditions' added to this.
Refer to Drupal commerce and rules: changing the product price dynamically for an example of dynamically changing product prices.


How to change the numbering in duplicate path aliases?

pathauto_alias_uniquify(&$alias, $source, $langcode) is the function that does the suffixing to generate uniqueness. It has a hard-coded value that starts at 0.

However, Pathauto evokes a hook, hook_pathauto_is_alias_reserved() when it checks for uniqueness when generating its path alias. If you have a custom module evoke this hook, you can check reject instances of the -0 suffixing and tell pathauto to move onto the next entry.

/**
 * Implements hook_pathauto_is_alias_reserved().
 */
function MYMODULE_pathauto_is_alias_reserved($alias, $source, $langcode) {
  // Return FALSE when the alias ends with '-0'
  $zero_suffix = variable_get('pathauto_separator', '-') . '0';
  return (substr($alias, -strlen($zero_suffix)) == $zero_suffix);
}

This might catch entries that legitimately have "-0" in the path, but I'll leave to the reader to devise a workaround for that scenario.


how to make the field label in Views hidden or visible?

This is normal because you are using a template file, view's will use your template file and nothing from the UI (User Interface) for fields.

Therefore, you will need to type Address: in your template file, just like you did for Location:, on line 47.


From what I understand you have a distributor node that has a term reference (multi value) to Product categories.

In your view that lists the distributors you must add a relationship: Content: Taxonomy terms on node. When presented with a choice of vocabularies you select 'Product Category'.

Then you add two fields: Taxonomy term: Name, and Taxonomy term: Image (your image field might be named slightly differently). For both of these fields, during the multi form process of adding them, you will be presented with a form that says for instance: Configure field: Taxonomy term: Name. Here you must select the Relationship as term.

This will create one row for each taxonomy term on the node, which might not be what you want. You can now group it under the content:title of the distributor.

There are two other ways that I can see by which you can group all of the images from one distributor under a single distributor.

First method:

Create a new field: global custom text. Make sure that it is below all of the distributor fields. Move the image field below it. In this global text field add all of the distributor fields (using html and replacement patterns) except for the image field. For instance, you might have something like this:

[title]

[address]

[phone]

Now go and hide all of the fields, the global text field as well, except for the image field. Then in your grouping, select this new global text field as the field to group on. Now apply some CSS to make it look good. And if you want to get rid of that pesky h3 tag around the grouping header, then override the theme view template. Click on Theme: Information in views and select one of the Style output templates.

Second method:

Install the Views Field View module. This allows you to create a field in a view that will be the result of another view.

Create a new view that takes as contextual filter the nid of the distributor, and then as before add a relationship to the terms etc. so that this view only outputs the pictures in groups.

In your original view remove the relationship to the terms, and insert a field to the new view, and make sure to pass it the parameter of the nid.


Which tables are safe to omit from sql-sync?

If you update to the latest dev version of Drush, you will find the following definition in examples/example.drushrc.php:

# $options['structure-tables']['common'] = array('cache', 'cache_*', 'history', 'search_*', 'sessions', 'watchdog');

The wildcard syntax is very useful, as with it, it is no longer necessary to make a comprehensive list of all cache tables used by all of your contrib modules.  Note that you must use the latest version of Drush pulled from git; the 8.x-6.x-dev from 18 June does not have wildcard support.


Custom module wiped out all content of type

Your query seems to be ok, irrespective of drupal version it should work. Here are the few pointers to debug.

Check the query output, is your query returning all nodes of type 'recent' without filtering by created

function delete_old_nodes_cron() {
  $query = \Drupal::entityQuery('node')
      ->condition('created', strtotime('-2 year'), '<=')
      ->condition('type', 'recent');
  $nids = $query->execute();
  dpm($nids);
}

Make sure for your recent created nodes created time is not altered somewhere.


This generally happens when your web server does not have access to make the overrides to your webroot.

Check if your httpd.conf file has something of the following format

<Directory "/Applications/MAMP/htdocs">
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

The important piece above is AllowOverride All, which will make possible for your .htaccess file to override the settings.

If you cannot change the settings in this file, I would recommend you to create a .conf file specific to your site (e.g. mysite.conf using the default file 000-default) in on of /etc/apache2/sites-enabled or /etc/apache2/sites-available, and modify the <Directory> tag to point to the root of your site.

Restart Apache in order to make this change visible. The site should now be able to pick up your .htaccess file.


How to show the data returned via hook_views_data() in a page?

You should be able to print the output to the page using print_r. Just add print_r($data) at the end of the function, before your return statement.

If you're just printing this data out so you can take a look at it for debugging purposes than you might want to use error_log instead. For error_log just add error_log(print_r($data, 1)) at the end of your function, before the return statement.


Not able to connect to remote database after migration

In case you're using SELinux see this article.

setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1


Without disabling/uninstalling the modules, you deleted and placed them in different folder. So here the beauty is Drupal will automatically scan for modules in modules/ and sites/ folder. Thta's why for Drupal the module is still in use.

Disabling a module means, the module is currently not in use, however its data(like DB tables), configuration and everything will kept.

Uninstalling a module means, the module is completely removed. Its data, configuration everything will be cleared.

However the particular module folder will not be deleted.


Well I tried alot of approaches, the last thing that I would think of was the solution, it was because clean-url ,  I just enabled it in server and it start working just fine again.


How to automatically create nodes according to related content types?

In order to relate content to each other you could try Relations module. But you'll have to extend it in order to automatically create the linked node and delete them if the master node is deleted. Take a look over the docs of this module.


With HTML5 on Drupal 7 no JS is necessary if we can add a maxlength attribute to the textarea tag.

I tried to use a hook_form_alter to set this attribute, something like

$form['field_NAME'][LANGUAGE_NONE][0]['#attributes'] = array('maxlength' => 220);

or

$form['field_NAME'][LANGUAGE_NONE][0]['#maxlength'] = 220;

...and a gazillion variations using dsm($form) for ideas and to check my results. I could easily change the $form['field_name'] values but my textarea failed to acquire the maxlength atttribute.

This worked:

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 * Add a maxlength attribute to field_NAME.
 */
function MYMODULE_field_widget_text_textarea_form_alter(&$element, &$form_state, $context) {
  if (isset($element['#field_name']) && ($element['#field_name'] == 'field_NAME')) {
    $element['value']['#attributes'] = array('maxlength' => 220);
  }
}


What tables are affected by "drush cc all"?

The list is dynamic, there's a convention to use cache_ as a prefix but it's not enforced. Modules can implement hook_flush_caches to register names of tables to clear:

  This hook allows your module to add cache table names to the list of cache tables that will be cleared by the Clear button on the Performance page or whenever drupal_flush_all_caches is invoked.

So basically the answer lies in the code for the modules you have installed, and you'll need to invoke that hook to get an accurate list of tables used as cache bins.


Some tokens show as "missing name or description" in status report

In my case, the answer is related to the autoslave module: https://www.drupal.org/node/2898888

Also discussed here (not resolved), https://www.drupal.org/node/1265848#comment-12191146

Other mentions online about the PHP memory settings had no effect for me.

Hopefully this helps someone as the issue has been quite elusive.


Your question seems to be all over the place. However, the Bakery Single Sign-On System module sounds like what you need.

  Bakery provides a "single sign on" feature for Drupal based sites that are on the same second-level domain (i.e. example.com, subsite.example.com, subsite2.example.com). It could also provide support for any other website that implements the same web cookie, xmlrpc, and POST methods.

  This module started at the 2009 Drupal.org redesign sprint in San Francisco as a way to manage single sign-ons across *.drupal.org infrastructure.

  Read the bakery documentation for more information.


Downloading a feed's embedded images to server and rewriting paths in html automatically

One possible solution is the feeds_imagegrabber module.

What is does is when the feed is importing it goes to the original web page of the feed item and scrapes the image from the page and imports it into drupal.

Depending on the specifics of your requirements this could be a good easy solution.


In drupal 7 there are a view having name Taxonomy term (A view to emulate Drupal core's handling of taxonomy/term). Enable that view and sort that view result according to title of content.

Note:
Enable module View UI if already not installed.


Path breadrumb crumb displaying just first letter of title

Maybe it helps someone so I will respond my own question: It resulted to be very easy using the module custom tokens with the following code:

    <?php
$node = node_load(arg(1));
$title = $node->title;
$rest = substr($title, 0, 1);
return $rest;
?>


Import images from RSS with Feeds module without Feeds Image Grabber

RSS feeds are XML files, so you could indeed use the XML parser from Feeds extensible parsers to extract data from it. This parser works with XPath queries. XPath is a query language to select data from a XML file. So to select the image from the RSS feed, you'll need to figure out how to select that data with the right XPath query.

It would be a good idea to learn more about XPath before using the XML parser. I think that the XPath tutorial from W3Schools is a good resource for this.


on('load') is not working with jQuery 3?

With Drupal, you don't (need to) use $.on(). It is handled through a combination of Drupal.behaviors, $.once(), and Drupal.attachBehaviors().

First you create a function using $.once() that will add your handler the same as you would with $.on(), but use $.once() to ensure that the handler is only applied a single time:

function addVideoHandler(context) {
  $(context).find(".video").once("add-video-handler").each(function() {
    $(this).load(function() {
      alert("video loaded");
    });
  });
}

Next, this function is called in Drupal.behaviors:

Drupal.behaviors.someArbitraryButUniqueKey = {
  attach: function (context) {
    addVideoHandler()
  }
};

This will be executed on page load, which will add the handler to all .video elements on the page. However, unlike other onload handlers (JS, jQuery), this is also called every time after an Ajax Call is executed, with any new loaded content passed as context. Therefore any newly loaded .video elements will have the handler applied to them - same as with $.on().

Generally, this is all you will need to do. However, if you are loading any content through Ajax in one of your own functions, you will need to pass the newly loaded content through Drupal.attachBehaviors():

$.ajax({
  url: "http://example.com/callback",
  success: function (data) {
    var targetElement = $("some_div");
    // Insert the returned HTML into the DOM, casting it as HTML.
    targetElement.html(data.response);
    // Finally pass the new content through Drupal.attachBehaviors().
    // Note - pass through the HTML, NOT a jQuery object. This can be done
    // by passing the [0]th element of the jQuery object.
    Drupal.attachBehaviors(targetElement[0]);
  }
});

This will call every Drupal.behaviors element, passing it the newly loaded content, which in turn will have the handlers attached. Using $.once() ensures that handlers are not accidentally applied multiple times, for example if someone calls Drupal.attachBehaviors() without passing a value, which in turn will pass the entire document.


Content type title field not available in manage display

It is not normal
but may be the theme you use does not display page title or you hide it with css
anyway you can go to node.tpl and write echo $node->title to check that


It maybe isn't exactly what you are after but I found the answer at Find orphaned unused files and images to be most helpful.  Particularly the comment by @Marcos Buarque mentioning comment 7427898 which mentions a nice query to tidy up using the file_delete() function built into D7


What hook_form_alter code do I need to change an exposed filter from a text field to a select box search?

If you would like to go for specific implementation using hook alter this would be great option.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    $view = $form_state['view'];
    if ($view->name == 'my_view_machine_name' && $view->current_display == 'display_name') {
      // alter your exposed form here
      $addition[$field_name] = array(
        '#attributes' => array(
          'class' => array(
            // you can define you class overhere
          ),
        ),
      ),
    }
  }
}


How do I change the global site url when serving Drupal from behind a reverse proxy?

inside settings.php:

global $base_url;
$base_url = 'http://my.domain.name';


How can I rewrite an "edit" operations link in Views?

Under fields, add the User ID.  Select Exclude from display and choose Unformatted for the Formatter.
Under fields, add User Name again.  Uncheck display as link.  Under Administrative Title, you can add something descriptive like user name (no link) so that you can remember what this is for.
Rearrange the fields so that User ID and the second User Name fields are at the top.
Click User: Operation Links under Fields.  Under Rewrite results, input the following for the text: edit {{ name_1 }}

This makes a plain link instead of a button.  I imagine there is a more efficient way to do this, but this is the best I could come up with for now.


Returning Values from Tableselect Form with AJAX

Short answer: you cannot use tableselect for submitting form elements.

Longer answer: the tableselect is for selecting one or multiple rows for further processing. You can check this through your submit handler only receiving one value for each row.

See http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#tableselect (it links to a full example on http://drupal.org/node/945102#drupal7).

If you really need a table form you could use dwillcox suggestion to use a theme function to render your form as described http://drupal.org/node/1587968

I'm not sure but have you thought about multiple forms on one page? That is each line from your tableselect attempt has it's own form. For this to work you need to implement a hook_forms(). I've used this for annotate module.

Some arguments about tableselect versus theming a form:

As table select adds radio or checkboxes it changes the complete form thus its meaning. The bad implementation of Drupal is it renders the form elements thus making the complete page looks like a form.
Theming your form is ugly as the exercise from http://drupal.org/node/1587968 shows.

Some nitpicking one your code:

mixed case function names : violation of the coding standards
mixed case array keys:  this is not expected by most coders.
swapped the key and value for $hinput which makes it hard to maintain.

Let us know what solution you took.


Going off memory here:

For both if and else, Add Action >> Set a Data Value >> node:field-email-max >> OFFSET: +1  (To get the offset, you will have to click the switch data selection button)

For both if and else >> Add Conditional >> Data Comparison >> node:field-email-max >> Less than 3


How do I add updated timestamp to a file url to ensure people download the latest version?

The best approach would be to actually rename the file both on the file system and the database and incorporate the upload time in file name.

Appending time after the question mark in URL would have purely informative purpose. And if that's what you want then create a custom module and place the following code in it:

function my_custom_module_node_view_alter(&$build) {
  if (isset($build['field_file'])) {
    $time = gmdate("Y-m-d:H:i", $build['field_file'][0]['#file']->timestamp);
    $build['field_file'][0]['#file']->filename = $build['field_file'][0]['#file']->filename.'?'.$time;
  }
}

If you have multiple files per node then use the following code instead:

function my_custom_module_node_view_alter(&$build) {
 if (isset($build['field_file'])) {
    foreach ($build['field_file'] as $key => $file) {
      if (is_numeric($key)) {
        $time = gmdate("Y-m-d:H:i", $file['#file']->timestamp);
        $build['field_file'][$key]['#file']->filename = $build['field_file'][$key]['#file']->filename.'?'.$time;
      }
    }
  }
}


Current Password issue for New Register User

with the one time login the user is logged in automatically and he can set the password without inserting the current one.


Unless you get a fatal error (or blank screen) it's pretty easy to get a list of modules that will invoked when a special hook is called:

$modules = module_implements($hook);
foreach ($modules as $key =>  $module) {
  $function = $module . '_' . $hook;
  if (!function_exists($function)) {
    unset($modules[$key]);
  }
}
// $modules is now an array containing all the modules that will be invoked by $hook.

You could use stuff like xDebug to track the flow of the Drupal, but this can be overwhelming, especially if you are new to Drupal.


Passing a custom variable from preprocess view to a template file

I'm not fully sure what I'm going to tell you is completely true, it is just my experience of how Views works.

From what I know, Every preprocess function has access to a specific output template file. As an example variables of template_preprocess_views_view_fields are available in views-view-fields--AnyThingElse.tpl.php template file, so the domain access of variables of template_preprocess_views_view_fields is views-view-fields--AnyThingElse.tpl.php.

In Theme Information there are three levels of output styles:

Display output
Style output
Row style output

The views-view-list--mycustomviewname--block_1.tpl.php is a TPL file in the second level (Style output) but I guess the mycustomtheme_preprocess_views_view domain of access of its variables is in the first level (Display output) TPL files.

To make sure, select one of the TPL files from Display output and check if the variable is set in there.


Can you make 1 View per report you want. Using Views aggregates and filter conditions you should be able to generate the values you want.

Then make 1 master View and use views attachments to build your single massive report page by showing all these reports in that page view.


Check our the module Search combine, it gives you exactly that.

Here's how I have the admin search configured:

Also related: How to have a combined search view that shows both users and content on search terms?


How to check for entity access when displaying views fields?

Presuming your entity providing module has Views integration already setup, and you're not worried about pagination, you can
invoke hook_views_pre_render() to iterate over the results and invoke your access callback for each entity in your base table and filter out entries that the user doesn't have access to:

/**
 * Implements hook_views_pre_render().
 */
function MYMODULE_views_pre_render(&$view) {
  global $user;

  // Iterate over View results for our custom entity
  if ($view->base_table == 'my_entity_base_table') {
    foreach ($view->result as $index => $row) {

      // Presuming eid is the entity PK
      $results = entity_load('my_entity_machine_name', array($row->eid));
      if (!empty($results)) {
        $entity = $results[$row->eid];

        // If the custom access callback returns FALSE, remove from results.
        if (!MYMODULE_my_entity_access_callback('view', $entity, $user)) {
          unset($view->result[$index]);
        }
      }
    }
  }
}

If pagination is a concern, it's a tougher problem; adjusting the view results break consistent offsetting (e.g. page 1 might return 4 results, page 2 might return 10 results). Plus, the results of SQL query can't adjust for information that is only known by executing PHP.

In those instances, you'll have to adjust your method (e.g. hook_views_query_alter() if the access callback is DB query based, altering your View pager options, etc.) to accommodate for the access callback manipulating the view.


3 separate fields,one views exposed filter

If you add all 3 fields as exposed filters and hide 2 of them (with CSS or if you set all fields as "hidden" type with hook_form_FORM_ID_alter()). Then you can use the visible field as master and alter values of the two others with a #submit callback.

<?php
/**
 * Implementation of hook_form_FORM_ID_alter().
 */
function mymodule_form_views_exposed_form_alter(&$form, &$form_state) {
    if (isset($form['field_to_expose1'])) {
        // Hide two fields and left one exposed.
        $form['field_to_hide2']['#type'] = 'hidden';
        $form['field_to_hide3']['#type'] = 'hidden';

        // Execute set_value_for_hidden_fields() as first function submit on $form['#submit'] array.
        array_unshift($form['#submit'], 'set_value_for_hidden_fields');
    }
}

function set_value_for_hidden_fields($form, &$form_state) {
  $value = $form_state['values']['field_to_expose1'];

  // Modify form_state values of concerned field.
  $form_state['values']['field_to_hide2'] = $value;
  $form_state['values']['field_to_hide3'] = $value;

  // Modify form_state of concerned field to pass to the view.
  $form_state['view']->display_handler->handlers['filter']['field_to_hide2']->validated_exposed_input = $value;
  $form_state['view']->display_handler->handlers['filter']['field_to_hide3']->validated_exposed_input = $value;
}

That's unstested code, but I hope you get the idea.

But is it worth the effort? Is sharing a field between multiple content types really a blocking issue when planning an upgrade? I'm not well informed on upgrade procedures for D7 to 8, but sharing a field between content types seems to be a pretty common thing using D7.


How do I relate two similar text fields between users and content with user as argument?

You need to make a View that lists nodes, containing a contextual filter that filters by SFID.  Do that, and what remains is the problem of how to pass the user's SFID value to the contextual filter.  There are many ways to do this, depending on how you're generating the user/%user/mynodes page.

Panels / Page Manager approach

My go-to recommendation for this sort of thing is to use Panels / Page Manager to generate the user/%user/mynodes page, and embed your view there.  If you enable the Views Content module (bundled with CTools) you will have a new type of Views display available called "Content pane".  Build your view using this type of display.  In the view configuration when configuring this display there's an option for "Argument input".  You'll probably want to choose "input on pane config".  Then, when embedding the view in your page (using Page Manager) you'll be given the opportunity to plug in a token there from the ctools user context that represents the user's SFID.

Custom module alternative:

Since you said you can't use Panels, your best alternative is probably to create your own menu callback at user/%user/mynodes wherein you extract the SFID from the user object and return the view by calling views_embed_view().

This is greatly simplified, but here's the gist of it:

function mymodule_menu() {
 $items['user/%user/mynodes'] = array(
  'page callback' => 'mymodule_user_nodes',
  'page arguments' => array(1),
 );
 return $items;
}

function mymodule_user_nodes($account) {
 return views_embed_view('viewname', 'displayname', array($account->field_sfid['und'][0]['value']));
}

Note: I haven't tested that code, it's just off the top of my head.  I may have forgotten something.  Don't forget to add things like an access callback since I presume you'll want to limit access to this page.

Views Field View or Entity Views Attach (EVA) alternative

This is a little bit icky but should work.  Either of the modules I listed (Views Field View or Entity Views Attach) will work for this approach.  I'll specifically outline how to do this with Views Field View but you could adapt these methods to EVA if you want; it would be similar.

You will make 2 views:

A view that lists users and accepts the user ID as a contextual filter.  So this view will always return only 1 single user (whatever user is passed in the URL).
The view that you've already likely created; the one that has a contextual filter that accepts a SFID value and lists nodes.

What we'll do is use view #1 to generate the page at user/%/mynodes, and view #2 will be embedded inside of view #1; view #2 will generate the actual list of nodes for us.

We'll assume you've created view #2 correctly already (it's basically what we've already discussed previously) and I'll focus on view #1.

Create a view based on the users table
Path for the view should be user/%/mynodes
Add a contextual filter to the view that filters on uid
Configure the view to output fields
Add the SFID field to the view, but check the "exclude from display" option so it's not actually displayed.  We add this to the view so that it's available as a substitution for our next step.
If you've installed Views Field View then you'll have a new field available called Global: View.  Add this to your view.  This field has a few settings; you'll need to select the name and display of view #2, above, and enter [!field_sfid] (this is the substitution token we get from the field we added in step 5) into the Contextual filters option.

Now you need only visit user/%/mynodes with an appropriate uid in place of the % and it should work.


How to use Drush with Apache Directives?

This is not a Drush function; it is a BASH function.  For example, you could do this:

DB_NAME=mydbestting drush status

Optionally, you could set your DB_NAME environment variable in your .bashrc file.

However, this is probably not what you want.  You would probably prefer to have Drush set the environment variable for you, after you specify the alias.  Drush does not have this feature, but there has been some discussion of it in the issue queue on drupal.org:

https://drupal.org/node/1848766


How to stopping spam when using Print_mail (submodule of Print)?

About sending eMail using the print module
Even though this module can be used for printing, creating PDFs and sending an eMail, your question seems to only be about the sending eMails part of it.
Yes you're right: if you grant access to the eMail part of it to anonymous users, then that is a huge spam risk: any spammer can use it to enter any (repeat any ...) eMail ID ... to have "your site" send that eMail (and who knows what the content, from the spammer, might be) ... to the eMail Id "requested" by the spammer.
"The way to stop that" (spamming), as in your question, is to not grant that permission to use the eMail function of it to anonymous users.
If you do grant that permission to logged in (+ registered) users, then you have at least a trace which user used the eMail part of it.
Recommended alternative
Have a look at the Message Stack, these are the basic components and dependencies of it:

Some more details about the Message-related modules (=quotes are from the module's project page):

Message:

The Message module is the core of the message stack. It enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Message Notify.

This module provides a method for sending a message via a notifier plugin. Message Notify comes with plugins for email and SMS and may be extended to other transport mechanisms as required.

Message Subscribe.

With this module, users who subscribe to content will be notified when events occur that involve that content. The module leverages the Flag module, which provides a subscribe functionality to users.

Quite a few popular Drupal distributions already adopted to this Message Stack, Open Atrium is one of them.
If you want to see it at work in an existing module (as an example), then checkout the 7.x-4.x version of the Answers module (disclosure: I'm a co-maintainer) and its Answers Notification sub-module. This sub-module allows logged in users (not anonymous users ...) to subscribe to selected nodes (such as "questions"), so that they receive notifications (using the Message Stack) when Questions receive Answers.


how to change the url based on region and language selection in drupal 7

You can change language based on such parameters (I am not at the position to check at the moment) under /admin/config/regional/i18n


Cron failed with drush: Segmentation fault

It sounds like a resource problem.  Memory limits tend to be the culprit.

Check to see that drush is using the same php.ini file your site is.

drush status

Tells you what php you are using for drush.

Running the following will give you memory output information when running cron

drush cron -d

if that memory stack is near what your php.ini limit is.. raise it up an integer of 32Mb. (i.e. 128mb to 160mb)  and then test again.


If you mean the "Interface Translation", it should be available under this URL => http://foo.bar/admin/config/regional/translate

If you clear the cache after activating the Interface Translation module, you could also see this option under "Configuration" >> "Regional and language" >> "User interface translation" menu


How to create timestamp field? I get Undefined index: timestamp:normal in DatabaseSchema_mysql->processField()

Looking at DatabaseSchema_mysql::getFieldTypeMap we can see that timestamp itself is not implemented:

$map = array(
    'varchar:normal' => 'VARCHAR',
    'char:normal' => 'CHAR',
    'text:tiny' => 'TINYTEXT',
    'text:small' => 'TINYTEXT',
    'text:medium' => 'MEDIUMTEXT',
    'text:big' => 'LONGTEXT',
    'text:normal' => 'TEXT',
    'serial:tiny' => 'TINYINT',
    'serial:small' => 'SMALLINT',
    'serial:medium' => 'MEDIUMINT',
    'serial:big' => 'BIGINT',
    'serial:normal' => 'INT',
    'int:tiny' => 'TINYINT',
    'int:small' => 'SMALLINT',
    'int:medium' => 'MEDIUMINT',
    'int:big' => 'BIGINT',
    'int:normal' => 'INT',
    'float:tiny' => 'FLOAT',
    'float:small' => 'FLOAT',
    'float:medium' => 'FLOAT',
    'float:big' => 'DOUBLE',
    'float:normal' => 'FLOAT',
    'numeric:normal' => 'DECIMAL',
    'blob:big' => 'LONGBLOB',
    'blob:normal' => 'BLOB',
  );

So, according to Schema API

  'mysql_type', 'pgsql_type', 'sqlite_type', etc.: If you need to use a record type not included in the officially supported list of types above, you can specify a type for each database backend. In this case, you can leave out the type parameter, but be advised that your schema will fail to load on backends that do not have a type specified. A possible solution can be to use the "text" type as a fallback.

In your specific case "int" makes more sense than "text" as fallback.

Or simply do as core modules, go with "int" for timestamps and calculate everything date-based in PHP code.


Show Description Field on Individual Webform Submission Result

After looking through the webform module I found out how to achieve this.

I used hook_webform_component_display_alter() which is there to enable customising the display of components in display only contexts. This function is in webform.api.php. I created my own function using this hook in a custom module to add the description to all textfield components as follows:

<?php
function my_mod_webform_component_display_alter(array &$element, array &$component) {
  if ($component['type'] == 'textfield') {
    $element['#description'] = $component['extra']['description'];
  }
}

For reference, the notes and example given from the webform module for hook_webform_component_display_alter() are:

/**
 * Allow modules to modify a "display only" webform component.
 *
 * @param array $element
 *   The display element as returned by _webform_display_component().
 * @param array $component
 *   A Webform component array.
 *
 * @see _webform_display_component()
 */
function hook_webform_component_display_alter(array &$element, array &$component) {
  if ($component['cid'] == 10) {
    $element['#title'] = 'My custom title';
    $element['#default_value'] = 42;
  }
}


I removed the template line from hook_theme and renamed the file to flot-d8-my-template. Cleared the cache and it worked.


Can users disable email notifications sent to them by Rules?

Unchecking the box for the contact form only affects the personal contact form provided by the Contact module (part of Core).

I added a similar feature (allow users to opt out to e-mails sent via rules) to a Drupal 7 site in the following manner.

First, I added a field (Boolean single on/off checkbox) labeled "Send me notifications" to the user account page.

Then, I made a couple rules to award a role nomsg upon checking the box and to remove the role upon unchecking the box.

After that, I created a rules component of type condition that checked to ensure that the user did NOT have the nomsg role.  I then added that component to all rules that sent e-mails.  This was a bit of a pain, because some of the rules that sent e-mails also did other things, so I had to break out the part about sending the e-mail (as another component) so that the other actions would be performed but the e-mail would not be sent if the user had the nomsg role.


This is issue has been fixed. @see https://www.drupal.org/node/2916409


Panel Page with Node Views, Flags and Rules Integration

If you can create a view (using the Views module) of those users that correspond to all those "prospects who did not get accepted" for a given game node, then you can process the results of a VBO enabled view via Rules, using a rule that looks like so:

Rules Event: After flagging the prospects flag with an accept flag (flag B).
Rules Actions:

Load the VBO list of the users in your View.
Add a loop to perform a Rules Action "Send an eMail", for each user contained in your Views results.

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


Creating a custom field with dynamic/virtual computed property value

UDPATE

I think the new part of your configuration is not necessary. I recall that there is a module called entity_reference_uuid which does something like you want: extends from core ER field type, adds an extra column target_uuid and uses the entity property which is computed from the reference.

In their schema they only have these keys definition:

field.storage_settings.entity_reference_uuid
field.field_settings.entity_reference_uuid
field.value.entity_reference_uuid

If you look here you will see the entity is computed (like the one you want to add). Further down you can see they kept sync between the entity property during ::setValue  ::getValue methods and implement ::onChange to notify any changes on the property. This all are entity lifecycle logic, nothing to do with rendering.

Until here everything is more like your code.

Later on the formmatter they just iterate over the referenced entities which are obtained from the $items. The thing is I think that your problem comes from not implementing the \Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase::prepareView:

/**
 * {@inheritdoc}
 *
 * Loads the entities referenced in that field across all the entities being
 * viewed.
 */
public function prepareView(array $entities_items) {
  ...
  // Fragment fromt line 142 and on.
  // For each item, pre-populate the loaded entity in $item->entity, and set
  // the 'loaded' flag.
  foreach ($entities_items as $items) {
    foreach ($items as $item) {
      if (isset($target_entities[$item->target_id])) {
        $item->entity = $target_entities[$item->target_id];
        $item->_loaded = TRUE;
      }
      elseif ($item->hasNewEntity()) {
        $item->_loaded = TRUE;
      }
    }
  }
}

As you can see there is where the entity key is populated for the formatter to use.

ORIGINAL ANSWER

By default all (most) pieces of data in Drupal 8 are typed data or get composed by it; means that fields are complex typed data which are like maps or mappings. EntityReferenceItem extends from \Drupal\Core\Field\FieldItemBase which extends from \Drupal\Core\TypedData\Plugin\DataType\Map. As explained in both of your renferences you should override the ::getValue method from EntityReferenceItem. Here is an example

/**
 * {@inheritdoc}
 */
public function getValue() {
  $values = parent::getValue();
  $values['computed_value'] = $this->myAwesomeService->getJSONApiData();
  return $values;
}

There on your formatters (and view's field) can use the computed_value key from your field.


Including files in template.php. failed in some cases (when using some contrib modules)

If you read the docs for path_to_theme(), there is this tidbit:

  It can point to the active theme or the module handling a themed implementation. For example, when invoked within the scope of a theming call it will depend on where the theming function is handled. If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the active theme. When called outside the scope of a theming call, it will always point to the active theme.

The Print module invokes preprocess functions within its own preprocesss functions (look at the code), so I think that is why yours is getting called with a scope other than your theme.

You should really do your include as

include drupal_get_path('theme', 'YOURTHEME') . '/template_includes/file1.inc';

or

include dirname(__FILE__) . '/template_includes/file1.inc';

There is debate in the Drupal community which is best.

Personally, I think including code within a function is a really bad practice, and would recommend splitting out whole functions into separate file(s), and doing the include at the top.  If you go that route, then you using the second form is best.


Define zone-wrapper in Omega 4 and 960px

If you are using Susy, something like that will do the job:

$total-columns: 12
$column-width: 6em;
$gutter-width: $column-width / 3;
$grid-padding: $gutter-width / 2;
$container-style: fluid;

html {
  font-size: 62.5%;
}

.l-page {
  @include container();
}


Allow users to manage other users but all content is site-wide not based on group

This could be convoluted but this is how I would do it.

To start with, I would use rules and have either entity reference fields or integer fields for the users and content.

With rules, when the new users are created, USER A is referenced (or their UID in the integer field) using rules.

Then, using rules, every node the new users create have this entity reference (or UID integer) applied to it automatically.

For editing, I would give USER A's role editing permissions and then write a custom module that redirects users from the node edit page if the node's field doesn't match the user's field. (And allow certain roles like admin and also allow the node author).

One benefit of this is that you could create a view for USERS A that only shows nodes they can edit and provide a link per node. And I'd use an intreger field as a preference.

Edit: You could do all of this without any extant contrib modules or rules and just custom code. But I always have rules so it's an obvious go to for me.


Render media url in node--page.html.twig

To get the uri of remote video in node--page.html.twig try with:

node.field_video.entity.field_media_oembed_video.value


How to return Views Field Value in Twig Template

Views templates don't work like field templates, so the modules you have installed won't help. Though you can use node and field templates by switching the Format of the View to Content instead of Fields or you can configure a single field to use a field template in STYLE SETTINGS.

If you want to use the views templating system you might consider switching to the format Table, because this template has the most options.

The template you have now has very limited options. The field array is exactly the output you have configured in Views UI and this is the place where you should apply your adjustments.

After all of that, if you still want to see which fields and their content are delivered to your template, then use this loop for debugging:

views-view-fields.html.twig

{% for key, field in fields %}

{{ key }}: {{ field.content }}

{% endfor %}

field.content is finally rendered html, so you can't do much with it. The array keys contain the field names of the fields you have selected and arranged in the FIELDS section of the Views UI. It doesn't matter whether the fields come from relationsships.


Why do so few code examples use the ::load($id) method for loading entities?

There is actually an issue about adding this info to the docs.

In short, the long winded version is unit test friendly.

A comment by one of the Core's contributors fully detailed explains why. Just to highlight the main point:

  If we call Node::load() in OO code we are breaking this principle (dependency inversion),
  because we are hardcoding the specific implementation
  (\Drupal\node\Entity\Node::load() to be exact). This code path is hard
  coupled to \Drupal::entityManager() which is hard coupled to
  \Drupal::$container. So now our code becomes impossible to run outside
  of Drupal.

  Furthermore, since code that uses the dependency inversion principle
  is fully standalone it is very easy to unit test it by mocking the
  dependencies according to the requested interfaces. If we introduce
  Node::load() then it becomes really hard to "properly" unit test the
  class, since it will start polluting the test environment with
  external code, and the dependency injection container is not available
  in unit tests.

Now if you wonder then why does Entity::load exists

  There were many loud voices at the time that D8 was going to be a DX
  disaster, that the OO approach was too difficult to understand and
  write, that it would never get adopted by the wider community. There
  was a huge push going on to make D8 more DX friendly, mainly driven by
  the Backdrop fork that was announced a few months earlier.

  So we created these static methods that wrap the loading of the entity
  manager from the container, and can be called directly from the
  procedural side. It was great, since it offers a drop-in replacement
  that works and looks very much like the original code. This made
  porting of procedural D7 code vastly easier:

// Original D7 procedural code.
$node = node_load($nid);

// New D8 procedural code.
$node = Node::load($nid);


How do I get a node, or a taxonomy term URL knowing the node ID or the taxonomy term ID?

The generic way is this:

$uri = entity_uri($entity_type, $entity);
$url = $uri['path'];

So for a node, $entity_type would be 'node', and $entity would be the fully loaded node object.

Taxonomy terms are also entities in D7, so the syntax would be similar.


Re-use value entered in component in previous webform page on following page in markup

For one I would be wary of matching $form_id like that.
It means you will be altering any webform you might add in future.
Plus it is possible for other form id's to contain webform, for example webform_node_form, which is the node add/edit form for the webform content type.
There is also webform_components_form, webform_component_edit_form and probably lots of others.

If you really want to regex it I would use webform_client_form_\d+

However if I wanted to do all webforms I would use hook_form_BASE_FORM_ID_alter(), like this:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function hook_form_webform_client_form_alter(&$form, &$form_state, $form_id) {

}

and to do just one webform I would use hook_form_FORM_ID_alter(), like this:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function hook_form_webform_client_form_922_alter(&$form, &$form_state) {

}

Now for your actual question, you can accomplish this in form alter:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function hook_form_webform_client_form_922_alter(&$form, &$form_state) {
  // If we are on the second page.
  if ($form['details']['page_num']['#value'] == 2) {
    // You can get the value via the submitted_tree using the field key.
    $name = $form_state['values']['submitted_tree']['name_field_key'];
    // However I would recommend instead using submitted.
    // The reason is that with fieldsets the submitted_tree gets more complex,
    // and also, users can change the field key (who knows why that's allowed)
    // so that is unreliable. The submitted array uses the webform field cid
    // so it won't change.
    // (1 is the id of my name field)
    $name = $form_state['values']['submitted'][1];

    // There are 2 main ways you can add the markup.
    // 1. If you actually have a webform markup component on the second page
    // and you want to set its value. This means you can control the field via
    // the webform UI.
    // I use check plain because this is data entered by the user and needs to
    // be sanitised. You could also use filter_xss() if the field might
    // contain HTML.
    $form['submitted']['markup_field_key']['#markup'] = '
' . check_plain($name) . '
';
    // 2. If you don't have a webform markup component and just want to add
    // markup in, you can do this, just using regular form API.
    $form['submitted']['my_markup_field'] = array(
      // Defaults to type #markup.
      '#markup' => '
' . check_plain($name) . '
',
      '#weight' => 10,
    );
  }
}


Views to use relative paths for image fields

Add your image to the view (mine is called Image2)

Create a theme file for your image field, see screenshot. (mine is called views-view-field--relative-url-example--page--field-image2.tpl.php and it's bolded). Pick the last one for the most granular themeing possible.

 (full size here)

After you have added the theme file to your theme templates (/sites/all/themes/THEME/templates or similar), hit the "Rescan template files" button. Your field template should be bolded now.

Add the following code to your theme file, I removed the comments but you can leave them in if you like:

<?php

/**
 * @file
 * This template is used to print a single field in a view.
 *
 * It is not actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the template is
 * perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $field: The field handler object that can process the input
 * - $row: The raw SQL result that can be used
 * - $output: The processed output that will normally be used.
 *
 * When fetching output from the $row, this construct should be used:
 * $data = $row->{$field->field_alias}
 *
 * The above will guarantee that you'll always get the correct data,
 * regardless of any changes in the aliasing that might happen if
 * the view is modified.
 */
?>
<?php

    $url  = file_create_url($row->field_field_image2[0]["raw"]["uri"]);
    $url  = parse_url($url);
    $path = $url['path'];

    print $path;
?>

I only printed the path to demonstrate it works so you will need to add the image tag, etc.

Here is my output:

You may need to clear the cache and be sure to save your view after you update the theme file.


I used Quick tab module to made taxonomy terms as tabs then i have created different views for each tabs and yes its working ...Thanks..


If you are not logged in the property will be undefined. This is all I've got for the anonymous user

object(stdClass)#7 (4) {
  ["uid"]=>
  int(0)
  ["hostname"]=>
  string(9) "XXX.XXX.XXX.XXX"
  ["roles"]=>
  array(1) {
    [1]=>
    string(14) "anonymous user"
  }
  ["cache"]=>
  int(0)
}


Rule fails to send email to billing address

As per one of the comments below this question (which kept showing up as a question with no answers):

It seems that for the email field an additional field was added to customer profile form. Thus obviously it couldn't be accessed.
A solution which works is to continue using the "Account information" checkout pane instead.

Credits: Gugols


The below instructions allows one to create an empty module, and is helpful for anyone just getting started with module building. If you have troubles getting your first module working, or even showing up in Drupal, ensure you've read all the instructions below.

Drupal 8

A project must at least have

A machine name.
An yaml info file named after the machine name, in the form module-machine-name.info.yml with the following attributes:

name: A humanly readable name
type: A type, defining to be a module.
core: The major Drupal core version the module is compatible with, 8.x, in this case.

An empty module file, name in the form module-machine-name.module

Drupal looks for modules in these locations, as seen from the web root:

/modules/
sites/[example.com]/modules
sites/default/modules
profiles/[install-profile]/modules

Technically, Drupal also looks for modules in core/modules, but one should never, place modules there, hence it's not on the list above.

An example module structure, for a module with the machine name helloworld, would look like this:

/modules/helloworld/helloworld.info.yml

/modules/helloworld/helloworld.module

Notice that both the info and module file as named exactly the same as the machine name, which is important.

The module file may be empty, but the info file must contain a few minimum values for Drupal to recognize it as a module. For our helloworld module, that could look like:

name: 'Hello world module to demonstrate module building'
core: 8.x
type: module

If you follow the above instructions, you should be be able to get a new module listed in your Drupal site, although it won't do anything, at this stage.

Drupal 7

A module must at least have

A machine name.
A humanly readable name
An info file named after the machine name.
An empty module file.

To be loadable by Drupal, it must also define which core version it is compatible with.

Further Drupal looks for modules in these locations:

sites/all/modules/
sites/[example.com]/modules
sites/default/modules
profiles/[install-profile]/modules

Technically, Drupal also looks for modules in modules, but one should never, place modules there, hence it's not on the list.

An example module structure, for a module with the machine name helloworld, would look like this:

sites/all/modules/helloworld/helloworld.info

sites/all/modules/helloworld/helloworld.module

Notice that both the info and module file as named exactly the same as the machine name, which is important.

The module file may be empty, but the info file must contain the humanly readable name of the module, and the core version the module is compatible with.

For our helloworld module, that could look like:

name = Hello world module to demonstrate module building
core = 7.x

If you follow the above instructions, you should be be able to get a new module listed in your Drupal site, although it won't do anything, at this stage.


Install Meta Tags and Meta Tags Quick modules on the same site

Couple of things to mention.
Meta Tags Quick does have a meta description field - check the module settings and enable the field for the content types.

Metatags and Meta Tags Quick can be installed on the same site - I've done this successfully (I do suggest testing on a mirror development site first). Bear in mind the two modules will duplicate some fields so you need to decide which fields you want each module to use.

The data cannot be imported from one module to the other however - maybe running SQL commands, but not from Drupal admin


term reference field with empty select list

Try with the following code

function yourmodule_form_alter(&$form, &$form_state, $form_id){
 if($form_id == 'your-edit-form-id'){
   $form['your-select-feild']['#options'] = array();
 }
}

Hope this will help you..


Drupal 7 Views Contextual Links edit Nodes and Fields

At the moment, contextual links for the node are displayed only when you choose "Unformatted" as style and "Node" as row style. I already posted a feature request to allow adding contextual links when the row style is "Fields".


You don't need to change the order directly, commerce_cart_product_add do it for you.

Try this code:

Variables:

 $product : commerce product
 $quantity: number of elements

Code

 global $user;
 // Create new line item:
 $line_item = commerce_product_line_item_new($product, $quantity);

 // Add to current user's cart: if the user is not logged in ($user->uid: 0) Drupal Commerce manages the $_SESSION
 $line_item_added = commerce_cart_product_add($user->uid, $line_item);

 // If $line_item_added !== FALSE the line_item has been added OK!


Is the Drush backend API a web-accessible API? How does one install it?

As the previous respondents said, drush is a cli tool.  If you would like to invoke Drupal functions via web services, try the services module.  If you would like to manage multiple Drupal sites via a web ui, try aegir.

If you would like to call drush functions remotely from php:

$values = drush_invoke_process('@alias', 'drush-command', $args_array, $options_array);

See examples/example.aliases.drushrc.php for examples on how to make an alias record.  Instead of '@alias', you can also pass in an array containing the site record definition, or you can use username@myserver.com/path/to/drupal#mysite.com.  See the source code comments in drush for an explanation of drush_invoke_process, and the contents of the $values array.


Displaying the contents of a document file (doc, docx, etc.)

Maybe this module can be usefull : Flipping Book

  This module provides an integration point between Drupal7 and FlippingBook (http://flippingbook.com/).
  Flippingbook is a very used software to make digital publication from any document you have (.doc, .pdf...).


The "Add to Cart Form" is not available directly from Panels.  You need to create a view to load the Add to Cart Form and then display that view in the panel. When creating the view you have total control over what you want to display or not display.

Panels is a way to put other Drupal content constructs together, first you have to build the constructs to hold the content though...