Show administrative description in Views

Ok here is one way to do it does however involve creating a custom twig Extension. its not to hard and there are a few youtube videos on the subject ...
for others it is good to note that custom Twig Extensions has replaced php input fields in older versions of Drupal.

in a nut shell you create a custom module,
you add a MODULENAME.services.yml  file.

in it you put...

services:
modulename.getWebformDescription:
  class: Drupal\modulename\getWebformDescriptionTwigExtension
  arguments: ['@entity_type.manager']
  tags:
    - { name: twig.extension }

then you need here is your class file (getWebformDescriptionTwigExtension.php)

<?php

namespace Drupal\modulename;

use Drupal\Core\Entity\EntityTypeManagerInterface;

/**
 * Provides twig function getWebformDescription()
 */
class getWebformDescriptionTwigExtension extends \Twig_Extension {

  /**
   * Load entity type manager.
   *
   * @var EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * {@inheritdoc}
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'getWebformDescription';
  }

  /**
   * {@inheritdoc}
   */
  public function getFunctions() {
    return [
      new \Twig_SimpleFunction('getWebformDescription',
        [$this, 'getWebformDescription'], [
          'is_safe' => ['html'],
        ]),
    ];
  }

  /**
   * Provides getWebformDescription function to Twig templates.
   *
   * Use example {{ getWebformDescription( webfrom_id) }}.
   *
   * @param string webfrom_id
   *   The webform id eg 'contact'
   */
  public function getWebformDescription($webfrom_id) : string {
    // Invoke __toString and cast to int.
    $webfrom_id = $webfrom_id->__toString();
    $webform_storage = $this->entityTypeManager->getStorage('webform');
    $webform = $webform_storage->load($webfrom_id);
    return $webform->get('description');
  }

}

after all that is done and the module is enabled you can then in views add the webform id field (and exclude it from display)

then add a new custom field and look at the replacement patterns you will see
some thing like {{webfrom_id}} ...

in that field you can then enter ...

 {{ getWebformDescription(webfrom_id) }}

if stuck
see stuff like https://medium.com/@thihathit/extending-custom-twig-extension-to-drupal-8-twig-extension-class-d4b99c2177ae

or google "create custom twig extension for drupal 8"


How can I clear all check boxes on failed validation?

You can unset your field in the form .Check for the array which has field array.

unset($form_state['field_checkbox']['und'][0]['value']);


How to Show Nodes under different flags in a view

I found out the solution for this question.

Refer:https://stackoverflow.com/questions/1340423/or-operator-in-drupal-view-filters?rq=1

If you are using Views 3 / Drupal 7 and looking for the answer to this question, it is baked right into Views. Where it says "add" next to filters, click the dropdown, then click "and/or; rearrange". It should be obvious from there.


Feed content type field with configuration value

finally, I decided to do a custom autocomplete for the field with a validation in the form submission :-S


Drupal 7 doesn't include the core profile module since users are entities which you can attach fields to. If you have added additional fields to the user you can get them with just user_load().

FYI: it is not advisable to the $user when calling user_load() since $user is a global variable which can cause problems.

It doesn't look like that tutorial would ever fully work since get_user_comment_count() is never defined and the get_user_rank() parameter call's for a comment count but uses the $user object in the user_forum_load() function.

To get the comment count of a user you could just lookup the number of comments from the comment table for a given user and the tutorial's user_comment_rank() should still work.


Feature revert deletes existing Strongarm variable

In case someone gets on this question: We finally managed to find the answer to our problem.

We had an old version of the strongarm module (7.x-2.0-beta2) instead if 7.x-2.0 which is stable now (since 2012). The update hook from this update saved a lot of variables from the features to the drupal variable table, and on every further feature revert, no more variables would be deleted, so the problem was fixed. Credits to @Weri!


You can use menu icons module to generate icon for the menu item.

  This module allows you to upload an image in the menu-item's
  configuration form.

  After uploading the image, the icon data will be added to the menu
  link's options array.

  When a menu link is goes through the theme layer, it will receive an
  extra class which by default is used to attach the images as a
  background image to the corresponding menu item.


You could do this with views (without PHP), but if you want to use PHP you should check out Entity Field Query

You will have to do something like this:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->propertyCondition('status', NODE_PUBLISHED)
  ->fieldCondition('your_field_course', 'target_id', $nid, '=')
  ->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
if (isset($result['user'])) {
  $uids = array_keys($result['user']);
  $users = entity_load('user', $uids);
}


May I use width and height CSS properties on images?

What I understand is, it is suggesting opposite to what you are interpreting.

Lets take a look again.

  Never apply widths or heights except to elements that natively have these properties (e.g. images).

So, it is saying that, you can apply the height and width to image freely as the Height and Width are the default property of images. This you can understand as all images has some width and some height. So they are intrinsic property of image.

Now, lets take other proof, why you can apply Height and Width to image. If you see the Drupal's core feature,
Image Style at Admin/Config/Media/Image style, there you can specifiy as many image style as you want with different Width and Height.

Hence this feature allowing the facility to  change the dimensions of same image with different Image styles - AND how this is happening, simply by changing the height and width, So this is the core feature.

Hence, image comes in the category of except in your highlighter following statement.

  Never apply widths or heights except to elements that natively have these properties (e.g. images).

So, you can freely use width and height to Images.


Boost Module: Delete Cache for single node on update

You should be able to do this using the Cache Expiration module:
https://www.drupal.org/project/expire

You might use the rules integration:

event: a node is saved
condition: (type of node, etc - depends on your scenario, might be nothing)
action: expire URL


How to quickly update/reinstall using Drush 4.x

It's best practice to always backup your database first when updating modules (especially when working with -dev versions). A useful module is Backup and Migrate, when installed it also provides a Drush command to backup the database (drush bb). (But avoid GZ compression at the moment, bug introduced with version 2.3). Since you currently have a fatal error, you'll probably have to make a backup of your database via your database management tool in Ubuntu, or use something like phpMyAdmin. You should also note which modules you will update and what the currently installed versions are. If you do all upgrading via Drush, it creates a backup of all modules it updates (so you don't have to keep track manually), and if something goes really wrong you can go back to the previously working code and if necessary put your backed-up database in place.

It looks like the current version of your Flag module is throwing the fatal error which is preventing you from updating / accessing the site. I assume this is still an old version (cf. e.g. this report), and it's likely that if you put the latest recommended relase of Flag in place the error goes away (remove the current flag module folder and replace with the 7.x-2.0-beta6 version). (If this doesn't solve the Fatal error, you should provide some more details on what versions of Flag and Rules you were using previously, and what version they are at now).

Once you get the site back working, it's a matter of doing the regular Drush commands from your Drupal directory. For example:

# If you have many sites you can check to make sure you're working on the right site
drush status

# update all modules but not Drupal core
drush up --no-core

# make sure update.php is run (in my experience sometimes some updates aren't run)
drush updatedb

Now check that your site is still working properly and then update Drupal core.

drush up drupal

And check your site again. The status report will show you if all modules and themes are up to date and if there are any database upgrades that still have to be executed.

For more info on Drush also check out drush.org.


Search result issue with Search API module

If you are not using Apache Solr in the back-end, then you will have to use the Fuzzy Search module in conjunction with the Search API module. This module provides drupal sites with a fuzzy search engine to allow for broader keyword matches including partial or misspelled keywords.

*Note: At time of writing this there is some incompatibility with Search API 7.x-1.0-rc1 and Fuzzy Search 7.x-1.x-dev (2011-May-12). To get these two working together, you will need to use the search_api 7.x-1.0-beta10 until the Fuzzy Search maintainer gets the module caught up to the current release of Search API.


Search facet user entered date field display

If anyone else has this same problem, there is a patch on drupal.org. If you've not used to patches, See this beginner's guide.


Is it a good practice to declare drush as a dependency of a contrib module?

If the module doesn't do anything when Drush isn't installed, for example because it's only implementing Drush commands, adding Drush as dependency in composer.json is perfectly fine.

I don't see any reason for not adding it in the composer.json dependencies. Probably, the users who don't add it as dependency for their modules think that most users download the module from the project page on drupal.org and the dependencies on composer.json wouldn't stop them from installing the module.

I would rather add the dependency from Drush in the composer.json file, in the same way I would add a dependency from a module the Standard profile installs, in the .info.yml file of a module I develop.
Eventually, I would add a hook_requirements() implementation that doesn't allow users to install the module when Drush isn't present, for the users who install the module from the user interface or using the project archive downloaded from drupal.org.


Show login or register to anonymous user fro flag

If I understand the question correctly:

You should be able, through permissions, to restrict access to the Flags, so that anonymous users don't see it
you could use the default user login block, or create a custom one that redirects users, and place that block in the same position as the Flags, with a message like "To Flag objects, you must first login" and then restrict that block to show only to anonymous users


The installation directory "/root" is not writable - Error when install Drush

The composer method for installing drush works, but is outdated. Use the drush documentation for the right instructions: http://docs.drush.org/en/master/install/

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush.phar');" > drush
# Or use our upcoming release: php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush-unstable.phar');" > drush

# Test your install.
php drush core-status

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x drush
sudo mv drush /usr/local/bin

# Optional. Enrich the bash startup file with completion and aliases.
drush init


ArgumentCountError: Too few arguments to function Drupal\hal\Normalizer\ContentEntityNormalizer::__construct(), 3 passed and exactly 5 expected

#0 in the stack trace contains Drupal\hal\LinkManager\LinkManager. That was ultimately the clue that the missing services were in our custom rest module. Whereas three services in our custom module was okay in Drupal 8. In Drupal 9, all five need to be included.
So yes, upgrading a Drupal 8 site to Drupal 9 works as advertised. It is, of course, still a lot of work. :-)


Which core module provides the default send email action for use in rules?

There is no "module", at least not one that can be turned on and off like other modules. Emails are normally handled by drupal_mail() and a bunch of other functions found in the system.mail.inc file under /modules/system and mail.inc found in /includes .  These work together to create the framework, using templates that you can set up in order for other modules (like VBO) to actually send emails.

drupal_mail():

  Sending an e-mail works with defining an e-mail template (subject,
  text and possibly e-mail headers) and the replacement values to use in
  the appropriate places in the template. Processed e-mail templates are
  requested from hook_mail() from the module sending the e-mail. Any
  module can modify the composed e-mail message array using
  hook_mail_alter(). Finally drupal_mail_system()->mail() sends the
  e-mail, which can be reused if the exact same composed e-mail is to be
  sent to multiple recipients.


It sounds like your question cannot be answered unless it is redefined.  Drupal entities, views, and all of the other niceties that you would like to do involve storing information in the database.

You might look more closely at your regulations, and see what specifically they allow you to do.  For example, sqlite stores its entire database in a file. If you used an sqlite database where the database file was stored in a volitile storage device (e.g. a RAM based filesystem), would you still meet regulations?

Even if this is possible, you might have performance problems if the amount of data you need to store is large, because sqlite was designed only for small databases, and is mostly used for testing.  The same idea might work for mysql or postgres, though, as ultimately even these databases store their data in files.

If your data retention regulations are strict enough, you may find that the technique you are currently employing is the best you can do.


how to apply single page checkout using drupal ubercart

Yo cant make it single page. Mandatory steps are,

Add product to cart
Go to checkout page
Payment

You can combine the steps 3 by adding Shipping and billing address using Ubercart Checkout Tweaks module, which helps to

Assume billing and delivery addresses will be the same

  In many stores, orders are delivered to the billing address more times
  than not. Enabling this option in the checkout settings will default
  the "same address" checkbox at checkout, making the checkout page seem
  shorter and less intimidating.

For limit the products that added to cart you can use hook_add_to_cart

Parameters:
$nid - the node ID of the product
$qty - the quantity being added
$data - the data array, including attributes and model number adjustments


It shouldn't break anything, and it has no special meaning to core: as long as it's in a modules directory, it will be searched recursively (which is why larger projects often have submodules in a subdirectory).

However, it does allow site-builders to organize their modules more neatly than just lumping everything together. You'll often see modules/ directories structured in a way similar to this:

/path/to/modules/contrib: Modules downloaded from contrib
/path/to/modules/custom: Custom modules that you write for this site
/path/to/modules/devel: Modules not meant to be enabled on live
/path/to/modules/features: Modules created by Features

This organizational setup is often used when building installation profiles and distributions as well, so if you download a few you'll probably see more examples of this sort of organization put into practice.


Search node by Image Field and return image as result rather than the node

The problem you are facing is that Search API has a flat structure, so it cannot save multiple values for fields, as it would require a change in data structure which isn't done during indexing, since it will effect the already indexed results.

If you knew how many values you could get (fx max 3), then you could create entity properties that pointed to the values for image 2 and 3. Otherwise this is beyound the scope of what's possible right now with Search API module (at least to my knowledge.


Dynamically Caclulated Values with Entity Field Query

I don't think Entity Query supports expression.

In your case, I think you might not even need it as you can workaround.

$value_to_compare = 5 - $user_provided_value;
$query->fieldCondition('field_some_number', 'value', $value_to_compare, '>=');
But if you need to compute value based on columns of database table, you can go ahead with db_select, where you can have addExpression for calculation.

$query->addExpression('table_columns_1 + table_columns_2', 'sum');
$query->having('sum', 5,'>=');


How do I display a message after redirecting users from the logout page?

Reading your code, it appears to me that you want to redirect /user/logout to /user.

If that's what you actually want, then you could use the Rules module for this, using an approach that is similar to my answer to the question "How to create a redirect to point to the user's id?", in which you use values for the_old_path and the_new_path that fit your needs here, i.e.:

Change all occurences of the_old_path to user/logout.
Change all occurences of the_new_path to user.
Adapt the message being displayed to fit your needs, so that the user will also receive an informational message, e.g. similar to something like this one:

  The path /user/logout has been redirected automatically to path /user.

If you don't want such message to appear, then just delete the line containing drupal_message in the rule.

Use the value of the [destination] variable in the redirect

In case you want to make the value  (user in this case) of the URL argument (destination in this case) available as new variable to Rules, you can use the Rules URL Argument module. Here is a quote about it (from its project page):

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

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

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

The newly provided Rules actions and conditions can be found under the "URL Argument" conditions and actions groups in the rule configuration interface.

For an example of how to use it, refer to Comment # 3 in issue # 1686360 which is about "Pass an amount to the url, ie; site/content/node-title?amount=10 or /node-title?=amount:10". Here is the relevant part of it:

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

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

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


Force Creation of New Node With hook_feeds_presave Rather Than Node Update

You can make use of Entity::isNew function to check if the entity is new, and skip the setting of skip to true:

  if(!$entity::isNew()){
    $entity->feeds_item->skip = TRUE;
  }


One way would be to give each user an account / profile. Then add the fields you need to the user profile and the people can provide all the information you need by themselfs. And they can update the data whenever something changes. Or even you can update the data if they're not able to do it or forget about changing them on your site.

An other way would be to have a content type if you dont want user profiles. But in this case, you have to maintain and update the data.


how to set and unset javascript files for specifc path aliases in Drupal 7?

As far as adding the JS file goes it probably depends where you're calling that code from. If you're calling it directly in a template file it's probably happening too late in the page build.

A hook_preprocess_page() implementation would probably be a good place for it (as would hook_init() and probably a bunch of others). You can also use request_uri() to check the current path without incurring a lookup for the alias.

function MYMOUDLE_preprocess_page(&$vars) {
  if (request_uri() == '/about-us') {
    drupal_add_js(drupal_get_path('theme', 'mytheme') . "/page-download.js");
  }
}

If for whatever reason you can't get that to work, you can remove a JS file by implementing hook_js_alter():

function MYMODULE_js_alter(&$js) {
  if ($some_condition) {
    $js_path = drupal_get_path('theme', 'mytheme') . "/page-download.js";
    if (isset($js[$js_path])) {
      unset($js[$js_path]);
    }
  }
}


I apologize, but I am trying to do something similar.

OG_Menus, taxonomy_menu have seemed to provide a solution. nodeone.se provides a warning, it's unclear if it's been fixed or not. also look at simpleaccess and taxonomy access control.


hook_library: if two libraries share common file, might this cause files to get loaded in wrong order?

For question #1 --

$options in hook_library() supports all the options in drupal_add_js.

$options in drupal_add_js supports a weight value to determine ordering:

From hook_library:

  'js': An array of JavaScript elements; each element's key is used as
  $data argument, each element's value is used as $options array for
  drupal_add_js(). To add library-specific (not module-specific)
  JavaScript settings, the key may be skipped, the value must specify
  'type' => 'setting', and the actual settings must be contained in a
  'data' element of the value.

From drupal_add_js:

  weight: A number defining the order in which the JavaScript is added
  to the page relative to other JavaScript with the same 'scope',
  'group', and 'every_page' value. In some cases, the order in which the
  JavaScript is presented on the page is very important. jQuery, for
  example, must be added to the page before any jQuery code is run, so
  jquery.js uses the JS_LIBRARY group and a weight of -20,
  jquery.once.js (a library drupal.js depends on) uses the JS_LIBRARY
  group and a weight of -19, drupal.js uses the JS_LIBRARY group and a
  weight of -1, other libraries use the JS_LIBRARY group and a weight of
  0 or higher, and all other scripts use one of the other group
  constants. The exact ordering of JavaScript is as follows:

For question #2 -- the safest thing todo is to always specify the inclusion order; eg weight.


File upload error "Files must be less than x MB" despite file being smaller than x

The upload_max_filesize parameter in php.ini (or accessed elsewhere) must follow the file size naming that PHP understands:

upload_max_filesize = 100MB  // NO
upload_max_filesize = 100 MB // NO
upload_max_filesize = 100 M  // NO
upload_max_filesize = 100M   // YES

Also keep in mind that many shared hosts will cap this value at a higher level.  So ask your host and use something reasonable like 25M or 50M - just putting in a ridiculously high value like 500M won't necessarily help you.


In the CKEditor profile area if I am hearing you correctly:

  admin/config/content/ckeditor


How to create a rule that checks an extra profile field created with the core profile module?

With the limited info provided in your question, the best bet is that you cannot test for that extra field because you forgot to add a Rules Condition like "entity has field" (related to your profile_field1 field). So add that Rules Condition first (as your very first Rules Condition), and then try again.
For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.
Update:
As per your updates to your question, I now understand that you're using the deprecated (core) profile module. This is a quote from its .info file:

; The Profile module is deprecated, and included in Drupal 7 for legacy
; purposes only. By default, the module will be hidden from the UI unless you
; are upgrading a site that uses the Profile module to extend user profiles.

Because of that, I doubt that there is a way to use the Rules module to check "if the content of the 'profile_field1' doesn't match a certain regular expression" (as in your question). Mostly because the Rules Condition like "entity has field" (=  typical prereq to configure these kinds of Rules Conditions) will not have any effect for such profile_field1-field. Maybe not the answer you would want to hear/read, but I'm afraid it explains that what you're asking for cannot be done with Rules.
Plan-b:
Give it some thought to consider switching to the Profile 2 module. Quote from its project page:

Designed to be the successor of the core profile module, which is deprecated for Drupal 7. In contrast to the deprecated module this module provides a new, fieldable 'profile' entity - leverage the power of fields!
Features
... Thanks to the foundational entity API the module integrates well with Rules ...

If you do, pretty sure my original answer (= add a Rules Condition like "entity has field") will turn out to be the solution for what you try to achieve.


HTML tags being removed after theme_preprocess_node

As described in Render API overview, the value passed in #markup is sanitized via \Drupal\Component\Utility\Xss::filterAdmin(). You can eventually pass the tags not to filter via the #allowed_tags properties, but the tag attributes could still be sanited.

To have full control on what it is sanitized, you should use #theme or #type instead of #markup. (The first is my choice when the markup is rendered only in a single place/page. Alternatively, you could also use #inline_template as in the following example code taken from the documentation page.

$build['hello'] = [
  '#type' => 'inline_template',
  '#template' => "{% trans %} Hello {% endtrans %} <strong>{{name}}</strong>",
  '#context' => [
    'name' => $name,
  ],
];

It allows to use any Twig filter Drupal core can use and to have full control over the rendered tags.
It's the easier alternative to #theme which doesn't require to implement hook_theme() nor putting the template content in a separated file. (If you need to reuse the same inline template in different pages, or the template content is rather complex, using #theme is still preferable.)


Left Join query causing 'Column not found' error

You made 2 mistakes:

For complicated queries, use db_select(), not db_query(). That way you will use enough of built-in failsafes to know what exactly went wrong.
If you insist on db_query(), or need an UNION or something db_select() simply cannot create, never use unbracketed full table name. That's why aliasing exists.

Your query should look about like that:

$result = db_query("SELECT nid, type FROM {node} n
LEFT JOIN {field_data_field_test} f
ON n.nid = f.entity_id
WHERE n.type IN (:type) AND LOWER(n.title) = LOWER(:title)
AND f.field_test_value = :test_value",
array(':type' => $node_types, 'title' => $page_name, 'test_value' => $tvalue,));


How can I add a real name field beside username to user information?

Simply add a textfield (or two, if you want first/lastname) to your users at admin/config/people/accounts/fields. That will allow them to enter their realname and it will be displayed on the user profile page.

And if you want to display that name in various places (like node author), that's exactly what Realname module is for. It allows to configure the displayed name based on tokens (which can either be profile fields or user fields).


How do I modify the email maximum length to 320 characters?

You can using hook_element_info_alter.
mymodule.module
/*
 * Implements hook_element_info_alter().
 */
function mymodule_element_info_alter(array &$info) {
  if (!empty($info['email'])) {
    $info['email']['#maxlength'] = 320;
  }
}

Flush all caches so hook gets pickedup.
As Neograph734 pointed out, the mail column's VARCHAR length will also have to be increased in the DB.  See Resizing Fields in Drupal 8 Without Losing Data to learn how you can accomplish that.


Show node IDs along with titles in Entity reference Autocomplete list

Install the Views and Entity Reference modules, create a new View and Add a Entity Reference Display:

Then Add in the fields the content title and the nid, click in the nid and check Exclude from display, Save and click in the title and go to rewrite the output of the title as [title] - ([nid])

Go to edit the settings of the format and check the title, this will allow you to search by title.

Save the view.

Go to edit your Entity Reference field and select in the Mode Views: .... (like the following image) and select your View (in this case the name is: articles_with_id) and save the settings:

Then go to see the result:

EDIT: This is now working in Drupal 8, at least in the version 8.3.4.


Wanting to add a drop down menu to reg form

Create a  BLOCK-VIEW of type TAXONOMY.
Select the vocabulary which u have created and want to be displayed in DROP DOWN LIST.
In the format type,select JUMP MENU.
SAVE the view.
Assign view to a region where you want drop down menu to be displayed..


Taxonomy Term description in views when "no results" (Haven't associated nodes)

Forgot about "Empty Results". insert code in "Global:Text area" and It's works. Thanks me for helping)))


Drupal content type node not overwriting the default node.tpl.php

If its drupal6 site then it is node-school.tpl.php . If Druapl7 then tpl should be node--school.tpl.php.

After Creating the files you need to clear the performance cache once.


How to gather user opinions via a survey based on tagging?

You can easily do this with taxonomy free tagging

Step 1 : Create a vocab, going at admin/structure/taxonomy/add
check the screen shot after adding a vocabulary named as survey.

Step 2: Create custom content type,going at admin/structure/types/add

Step 3: Add taxonomy term reference field to it.Check the settings in screen shot

once you click on save it will take you to next config page,where you will be choosing the vocab you created in step 1

Clicking field settings will take you now to last configuration page as in screen shot


Validate form: at least one of the fields is required

Where are these fields attached to? User registration page or content type?

Anywhere it might be, there must be a form, and what you need to do is add a form level validation function, not a field level validation. Field level validation works well, when logic is associated with that particular field but for your case you need to add form level validation handler:

Here is an example:

/**
 *  Implementation of hook_form_alter().
 */
function yourmodulename_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_register': // or whatever is the form id in which you want to apply validation
      // this line adds a new validation function
      $form['#validate'][] = 'custom_data_validate'; //or whatever validation function name
      break;
    }
}

/**
 *  Custom validation function.
 */
function custom_data_validate(&$form, &$form_state) {
  $values = $form_state['values'];  //all submitted values will be in this array, keyed by the name, grab any value you want.

  if (empty($values['facebook']) && empty($values['twitter'])) {
    form_set_error('facebook', t("you need to fill up either of the two fields"));
  }
}

I did not take care of the logic and the code provided is just an example but the basic workflow is:

Alter the form and add a custom validation function.
All the submitted values will be available in $form_state in the validation function.
Check the logic and trigger a form_set_error() to set the error.


how to print google map field value in a page tpl

For a start don't load the node in the template file like that.

If you want to load a node do it in a template preprocess function in your theme's template.php file, like this for example:

/**
 * Variable preprocess function for the page template.
 */
function THEMENAME_preprocess_page(&$variables, $hook) {
  // Load a node and save it to the variables array.
  // This will then be available in the variable $node, in the page.tpl.php template.
  $variables['node'] = node_load(41);
}

However don't use $variables['node'] in the page template because it is already in use.
If you are on a node page then that variable will already be populated with the node object of the current page, so in your template you can access it using $node.

If you are aloading a node that isn't the current page node then you can do it your way but give the variable a different name, like $variables['map_node'] for example, which would then be available in the template file as $map_node.

On to the field printing.

The problem is you are trying to print the GoogleMapField property of the field value, which as far as I know doesn't exist.

The values in this field type are:

lat
lon
map_width
map_height
zoom
name

So doing what you are doing you could print those out, however I'm thinking you probably don't want those either.

So you want to print the rendered field item.
There are a few ways this can be done but a good option is using the field_view_field() function like this:

/**
 * Variable preprocess function for the page template.
 */
function THEMENAME_preprocess_page(&$variables, $hook) {
  // Load a node and save it to the variables array.
  // This will then be available in the variable $node, in the page.tpl.php template.
  $variables['map_node'] = node_load(41);
  // Get the rendered markup for the map field to print in the template.
  $variables['rendered_map'] = field_view_field('node', $map_node, 'field_add_map', 'full');
}

That example uses whatever display configuration you have set on the "full" display mode for your node type for that field. You could use "teaser" or some other view mode if you prefer.
You could even add a custom view mode specifically for this if it suits your use case.

Then in your page template you could do something like this to print the map using the render() function:

if ($rendered_map) {
  print render($rendered_map);
}


how do I add a favicon to RSS feed in Bitnami Drupal?

You can try to modify the line 1611 of the file installdir/apps/drupal/htdocs/includes/theme.inc. Change feed.png for the name of your image previously placed in the folder installdir/apps/drupal/htdocs/misc/

The original line is:

  if ($image = theme('image', 'misc/feed.png', t('Syndicate content'), $title)) {


How do I fetch the user ID from the shipping profile?

Shipping and billing profiles don't have a user ID, they are always anonymous because they belong to the parent entity (order/shipment), not the user.

Only address book profiles have user IDs.


Can't render a block due to recoverable fatal error

The error:

  Recoverable fatal error: Argument 1 passed to Drupal\block\BlockViewBuilder::view() must implement interface Drupal\Core\Entity\EntityInterface

usually is caused by viewing the invalid block (NULL). So for some reason Block::load() fails to load your block (bartik_search). So clear your caches and check whether the block exists at Block Layout page, theme is enabled and permissions are configured properly. If this still happening and the block is definitely there, please raise a relevant issue ticket.

You can always add the condition or try/catch block whether the code loads the block correctly.

Please also note that drupal_render() is deprecated and you should return $block_content instead.@googletorp Or use \Drupal::service('renderer')->renderRoot() instead.

See also: How can I programmatically display a block?


It's recommended to use #default_value instead of #value.

You have to use property of object instead of whole object. For example $dval->body.

$form['display_result'] = array(
    '#title' => t('Result'),
    '#type' => 'textarea',
    '#default_value' => !empty($dval->body) ? $dval->body : '',
  );


Based on some research, I was able to find Editview for Drupal 6. I'm not quite sure if it's like how Editable views work for Drupal 7.

It states in the Editview's module page that,

  It allows you to create a view in which the nodes are editable, and
  new nodes can be created.

Hope this helps.


What is incorrect with this HOOK_node_presave method ?? Trying to modify a FAPI textfield

Your structure is wrong, you are missing the 'value' part. Something like this should work:

$node->field_product_short['und'][0]['value'] = 'test';

I'd recommend to explicitly use [0] instead of [], the first always writes the first field value while the second appends a new one (which is 0 if it is the first). Within it are the actual values of the field, which is, in case of a text field the mentioned 'value'. A term refernence would be tid, a node reference nid and so on.

The reason you are getting 't' is because the field structure is now a string where Drupal expects an array. Example:

$string = 'abc';
echo $string['value'];

This prints 'a', because only integers are supported when accessing strings like this which means 'value' is casted to a 0 and the first character of the $string is 'a'. Welcome to the strange world of PHP.

And another hint. The callback stuff is there because there also exists a function 't'. krumo doesn't know if something is a callback or not (as this is not possible to know in PHP), it simply checks if a function with the same name exists.


How to create a google map block to display number of nodes for a content type

Use Geofield_map module:

  Geofield Map is an advanced, complete and easy-to-use Geo Mapping
  solution for Drupal 8, based on and fully compatible with the Geofield
  module, that lets you manage the Geofield with an interactive Map both
  in back-end and in the front-end.

  It represents the perfect solution to:

  geolocate (with one or more Locations / Geofields) any fieldable
  Drupal entity throughout an Interactive Geofield Map widget; render
  each Content's Locations throughout a fully customizable Interactive
  Geofield Map Formatter; expose and query Contents throughout fully
  customizable Map Views Integration; implement advanced front-end
  Google Maps with Marker Icon & Infowindow advanced customizations,
  custom Google Map Styles and Marker Clustering capabilities; customize
  Map Geometries properties (Lines & Polylines, Polygons, Multipolygons,
  etc.), based on Google Maps Polygons APIs;

Take a look at Demo.

So, in summary, you need to install this module and add it to your content type.
then with creating a custom view, you can achieve what you want.


I presume you're using the MoneyScripts "Membership Suite" module? You'll want to install the Rules contrib module, which will allow you to modify content (your node's CCK field) when a payment is made:

  New Rules Integration allows you to take action when users purchase a new membership, make a payment, cancel their membership, etc! The possibilities are limitless!


Display all values in a facet block even when a value is selected

I need the same behavior, with drupal 7.

I know 2 ways :

Use a facet block
use minimal facet count
rewrite yourself the missing facets


Custom Block Twig: File field how to get direct link to file?

#item is as far as I know only added by the image field formatter, so it's unlikely you'll find it in other field types.

Instead you can use the block content entity to get field values, for example:

{{ elements.content['#block_content'].field_file.0.entity.uri.value }}

This works independently of field formatters and as commented by @Kevin also when a field is hidden.


"Class" -> "class".
It needs to be lowercase, or else Drupal does not discover it while scanning the file.


How can I limit the allowed quantity in the cart to one item?

Drupal 8 / Commerce have field "Default quantity to add to cart", so you can add default quantity for product is 1 and hide it from product page. After that user can't change quantity of products. Problem is solved!


View filtering, Relationship Vs Contextual filter

You should use the contextual filter to identify the article the block is being displayed on.  E.g. content id from URL should work.

Then you should use the relationship option to link the field_product_teaser info to products.  E.g. Content referenced from field ....

Then in the view, you can select the product fields you want to display and use the reference to tell views what you want displayed. E.g. title w/ product reference relationship = product title.


The issue you're running into sounds as if the file permissions are messed up; here's a checklist of things to go through:

Open .info files of those modules and verify that they exist and have all regular information (name, dependencies, version, etc.).
If they exist and have all info, check if they have some weird file access permissions; this could prevent Drupal from reading the content. See file permission instructions for Linux servers, specifically the commands which ensure that the proper permissions are in place:

[root@localhost]cd /path_to_drupal_installation
[root@localhost]chown -R YOUR_USERNAME:www-data .
[root@localhost]find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
[root@localhost]find . -type f -exec chmod u=rw,g=r,o= '{}' \;

Try replicating the issue on a clean install AND on a clean install with the same installation files.
If the above steps don't tell you anything and you still have the issue - hack the core, specifically _module_parse_info_file() function in includes/module.inc and do a var_dump() or print_r() on the $info variable once it parses the file. Maybe the formatting is off, encoding or something else. This might get you a step further if everything else fails.

Hope this helps.


Drupal 6: How to create a special case for searches on a limited set of single symbols (such as @ and ! and " and : )?

Taking a fresh look at the problem this morning, I took a stab at finding out how to create a module to solve it. I think the search terms are run through 'check_plain', stripping it down to just text (no symbols).

Turns out that a module providing the hook_search_prepocess hook can override the text used by the indexer and the search. So I put together a module in which my hook does a replacement of '@' with 'atsign', which appears to solve the issue. Also means I can set the minimum word size back to '3', as long as my replacement text is 3 or more characters.

I now have a sites/all/modules/searchfix/searchfix.module file (and corresponding .info file), with the following function in it:

function searchfix_search_preprocess($text) {
    return str_replace("@", "atsign", $text);
}


How do I get a list of all taxonomy terms assigned to a node (or any entity)?

One way to do it is to iterate through each field and check if it's an entity_reference field with target type taxonomy_term, then extract the data you need.

$terms = [];

foreach ($node->getFields() as $key => $field) {
  if ($field->getFieldDefinition()->getType() == 'entity_reference') {
    $targetType = $field->getFieldDefinition()
      ->getItemDefinition()
      ->getSetting('target_type');
    if ($targetType == 'taxonomy_term') {
      $new_terms = array_map(function (\Drupal\taxonomy\TermInterface $term) {
        return $term->label();
      }, $field->referencedEntities());
      $terms = array_merge($terms, $new_terms);
    }
  }
}

One advantage to this approach is it will work with any fieldable entity type.


Display content between squares with links

What you want to do can be easily accomplished with JavaScript and CSS. And. since Drupal already ships with jQuery, you could make use of the slideToggle() effect to slide up and down your content.

I'll give you a general idea:

In Drupal, create a page that displays your 3 nodes. For example, you could create a View and show the Title and Body fields of your articles.
In your JavaScript, hide the Body field by default and then add a click event to your Title field, so when users click on it, the following Body field slides down or up.

$('#title-one').click(function() {
    $('#body-one').slideToggle();
});

Of course, this is just a starting point and one way of doing it. Good luck!


If ECK doesn't define the entity and property types for views, you will have to do that yourself using either hook_views_data or hook_views_data_alter.


How do I add a class to the HTML "body" tag programmatically?

The preprocess functions can be implemented from modules, and themes.

The preprocess function that you need is hook_preprocess_html() and the variable to set is $variables['classes_array'], which is an array containing all the classes set for the  element.   The content of the html.tpl.php file that is used by default by Drupal (if the theme doesn't use a different template file) is the following one:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>

<head profile="<?php print $grddl_profile; ?>">
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>

<body class="<?php print $classes; ?>" <?php print $attributes;?>>

    <?php print t('Skip to main content'); ?>

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

In your module you just implement the preprocess function as follows:

function mymodule_preprocess_html(&$variables) {
  $variables['classes_array'][] = "new-class";
}

template_process() then uses $variables['classes_array'] to populate $variables['classes'] with the following code:

$variables['classes'] = implode(' ', $variables['classes_array']);

Using a preprocess function in a module is preferable if your site uses more than one theme, or if the theme set for your site is not the one you created. In this case, you are able to set your custom CSS classes, and not lose them when updating the theme, or simply changing the default theme used by your site.  If your site uses just a theme, and that theme is a custom theme you created, then you can implement the preprocess function in your custom theme. As you maintain the theme, the CSS classes are not lost when updating your theme.


Perhaps not the most elegant, but I used the following on the date field:


Related Content Block for a Views Page, Not a Node Page

You created views block which display current node images - right? What images you want to display on views page?

You can create another views block where display images from some nodes(add some term to nodes to mark them) or images from recent nodes which views shows.


Let custom module access private files via file_get_contents

"Use the file system path rather than the url" - Thanks @Clive, this is the solution.


Render a menu differently based on region

You can add template suggestions. Because menus don't know their region, you first have to add a helper variable in block preprocessing:

function YOURTHEME_preprocess_block(array &$variables) {
  if (!empty($variables['elements']['#id'])) {
    $variables['content']['#attributes']['data-block-id'] = $variables['elements']['#id'];
  }
}

After that you can alter the menu template suggestions

function YOURTHEME_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
  if (isset($variables['attributes']['data-block-id'])) {
    $block = \Drupal\block\Entity\Block::load($variables['attributes']['data-block-id']);
    if ($block) {
      array_unshift($suggestions, 'menu__' . str_replace('-', '_', $block->getRegion()));
    }
  }
}

Now you can use twig templates like menu__REGIONNAME.html.twig for all menus in a given region.


Interesting question/challenge (+1 from me ...). What you described about the "is group content" makes those webforms indeed unreachable for anybody who is not part of that group (so that's a "works as designed" ...

However, how about using the Rules module to complete your puzzle? Haven't looked at all the details (yet), to see if it can actually be done (I'm pretty sure it can ...), but I'm thinking of using a rule that looks more or less like this:

Event: when Webform is submitted

Condition: If membership for group is requested in the submitted form

Action: Send eMail to an authorized user to accept / reject the request


Show English when there is no translation

Language fallback module

I haven't tried this module but it seems to do what you're asking for. You can edit bg, de, it etc languages and set English as the fallback.

Drupal 8 also has one extra module for this: Entity Language Fallback

Automate with Rules

You could probably come up with a Rule that automatically saves translation nodes of an English node under certain circumstances, with some custom code.

Quickly fill in translations

If you can't do custom code for what ever reason, you could enable Synchronize translations (which is a submodule of i18n) on your Content types. This way when you go to translate other languages you'd already have the English text filled in, images kept etc so you just Save the node and see English text on an Italian node.


Adding alt/title attributes to uploaded images

The tutorial you are referencing states this, "On the next screen just press Save field settings."  This is where the issue starts. You have to edit the image field he tells you to create and, instead of hitting 'just save' you have to enable the options for ALT and TITLE fields, about 3/4 down the page.

Then, when you upload image, each image will display a place where you can fill these out.

Then, in views, you will have two more options - Content: Image (some_field) ALT, and Content: Image (some_field) Title. You can then select these as fields and theme them as needed to be part of your image gallery


Copy nodes of content type into Commerce Products

There is no direct option or module which can convert a content type nodes to commerce products. But there are few ways you can do it.
You can export your nodes to CSV via node export or views bulk operations and then import those products using commerce feeds module.
Another way is to create a custom module and do db_select of all nodes of your particular content type and then create commerce products programmatically. You can use batch process to do this so that php execution time don't break your script.


You can refer this article Remove Duplicate Views Results. Yo can use second option from that article.

Generally, it is done by the Enabling Aggregation: Yes under Views UI. This all has been mentioned at that link. Hope it will help.


How to add a class to the site logo of the system branding block

You don't need to dig into $variables['element']. In a block preprocess function, the content of the block is available in $variables['content'], so you could use the following code.

$variables['content']['site_logo']['#attributes']['class'][] = 'svg';

Edit:

Altough this is generally valid for blocks, it doesn't work for the system branding block. The branding block overrides the block template with block--system-branding-block.html.twig, where the output of {{ content }} is removed, which breaks the normal rendering of the block. Instead the template contains the html markup for the  tag directly:

{% extends "block.html.twig" %}
{#
/**
 * @file
 * Theme override for a branding block.
 *
 * Each branding element variable (logo, name, slogan) is only available if
 * enabled in the block configuration.
 *
 * Available variables:
 * - site_logo: Logo for site as defined in Appearance or theme settings.
 * - site_name: Name for site as defined in Site information settings.
 * - site_slogan: Slogan for site as defined in Site information settings.
 */
#}
{% block content %}
  {% if site_logo %}
    <a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home">

  {% endif %}
  {% if site_name %}
    <a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home">{{ site_name }}
  {% endif %}
  {{ site_slogan }}
{% endblock %}

To reinstate the correct behavior you could override block--system-branding-block.html.twig in your theme and replace the  markup with the render array:

{{ content.site_logo }}

Then the changes made in preprocess are effective again.

Or simply go along with the template as it is now and add the attributes to the html markup of the template.


Using #markup is ok, you want to use theme_item_list to easily build your list and add html attributes to it:
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_item_list/7


You can do it by adding an expression to the query:

db_update('a_table')
  ->expression('count', 'count + 1')
  ->condition('field1', $some_value)
  ->execute();


Use the panel for layout with multiple columns

I would use panels for layout of a page which contains various bits and pieces from other pages. For layout of the display of a single page or node type I would edit the templates page--content-type.tpl.php and node--content-type.tpl.php.

In node--content-type.tpl.php you could then do something like:

<?php
  // Hide fields so that we can render them later.
  hide($content['field_image_main']);
  print render($content);
?>

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


Can I use hooks in a template for views?

The API reference at http://drupalcontrib.org/api/drupal has all of the Views hook in it: http://drupalcontrib.org/api/drupal/contributions--views--docs--docs.php/group/views_hooks/6

That said, the views documentation is a little sparse.  The best thing to do is look through the list of hooks, then search on the various hook names for examples.

I suspect you need to use hook_views_query_alter but I don't think I have ever had to add a JOIN to a view before.

EDIT:

Notice another of your questions: Join a custom table on a View.

In your case, if you want to properly make a custom table Views aware, implementing hook_views_data is the correct solution.  But you still need to do this in a custom module, and not in your theme files.


How to unpublish all nodes of a user after is assigned a role?

I would instead create a Views Loop using the Views Rules module. You can create a view and have the rule loop through all the rows that the view outputs.

Edit:

  For Example, I want to send an e-mail to all user's attached to a node
  registration. So I needed to do the following:

  Create a view with a Rules Display. Field: User E-mail. Contextual Filter: NID (Screenshot: http://i.imgur.com/rcvdMyn.jpg).
  In the Views Rule Settings - Parameters: I specified the parameter's label and name, that wil need to match the Views Loop Data
  selector (Step 4) for the Views Contextual filter. (Screenshot:
  http://i.imgur.com/MFA7mxk.jpg)
  In the Views Rule Settings - Row Variables: I specified which field should be enabled for Rules, and how it should be passed back to
  Rules. (Screenshot: http://i.imgur.com/U7fkzjj.jpg)
  I then created a Views Loop in my Rule matching the Parameters and Row Variables in my view (Screenshot: http://i.imgur.com/hGziOtK.jpg)
  I then created the action "Send mail" under the Views loop using the now available token that was specified in the View. (Screenshot:
  http://i.imgur.com/chlKc7x.jpg)

And that's it. If you want to test your output rather than your unpublish action. I would recommend using the action "Show a message on the site".

In your case your contextual filter is most likely your UID and NID as your field. I used my example as a proof of concept.

Edit 2:

Exported View:

$view = new view();
$view->name = 'waiting_list_user_list';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'users';
$view->human_name = 'Waiting List User list';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access user profiles';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['default_row_class'] = FALSE;
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: User: Registration */
$handler->display->display_options['relationships']['registration']['id'] = 'registration';
$handler->display->display_options['relationships']['registration']['table'] = 'users';
$handler->display->display_options['relationships']['registration']['field'] = 'registration';
$handler->display->display_options['relationships']['registration']['label'] = 'User Registration';
/* Relationship: Registration: Registration to Node */
$handler->display->display_options['relationships']['registration_related_node']['id'] = 'registration_related_node';
$handler->display->display_options['relationships']['registration_related_node']['table'] = 'registration';
$handler->display->display_options['relationships']['registration_related_node']['field'] = 'registration_related_node';
$handler->display->display_options['relationships']['registration_related_node']['relationship'] = 'registration';
/* Field: User: E-mail */
$handler->display->display_options['fields']['mail']['id'] = 'mail';
$handler->display->display_options['fields']['mail']['table'] = 'users';
$handler->display->display_options['fields']['mail']['field'] = 'mail';
$handler->display->display_options['fields']['mail']['label'] = '';
$handler->display->display_options['fields']['mail']['alter']['trim_whitespace'] = TRUE;
$handler->display->display_options['fields']['mail']['alter']['strip_tags'] = TRUE;
$handler->display->display_options['fields']['mail']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['mail']['element_default_classes'] = FALSE;
$handler->display->display_options['fields']['mail']['link_to_user'] = '0';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['relationship'] = 'registration_related_node';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: User: Active */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'users';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Registration: State entity */
$handler->display->display_options['filters']['state']['id'] = 'state';
$handler->display->display_options['filters']['state']['table'] = 'registration';
$handler->display->display_options['filters']['state']['field'] = 'state';
$handler->display->display_options['filters']['state']['relationship'] = 'registration';
$handler->display->display_options['filters']['state']['value'] = array(
  'waitlist' => 'waitlist',
);

/* Display: Rules */
$handler = $view->new_display('views_rules', 'Rules', 'views_rules_1');
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['rules_parameter'] = array(
  'nid' => array(
    'enabled' => 1,
    'type' => 'integer',
    'label' => 'nid',
    'name' => 'nid',
  ),
);
$handler->display->display_options['rules_variables'] = array(
  'mail' => array(
    'enabled' => 1,
    'rendered' => 0,
    'type' => 'token',
    'label' => 'User: E-mail',
    'name' => 'mail',
  ),
);

Exported Rule

{ "rules_waiting_list_e_mail_after_registration_deletion" : {
    "LABEL" : "Waiting List E-mail after Registration Deletion",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "REQUIRES" : [ "rules", "rules_i18n", "registration" ],
    "ON" : { "registration_delete" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "registration:state:name" ], "value" : "complete" } }
    ],
    "DO" : [
      { "entity_fetch" : {
          "USING" : { "type" : "node", "id" : [ "registration:entity-id" ] },
          "PROVIDE" : { "entity_fetched" : { "node_id" : "node_id" } }
        }
      },
      { "VIEW LOOP" : {
          "VIEW" : "waiting_list_user_list",
          "DISPLAY" : "views_rules_1",
          "USING" : { "nid" : [ "node-id:nid" ] },
          "ROW VARIABLES" : { "mail" : { "mail" : "User: E-mail" } },
          "DO" : [
            { "mail" : {
                "to" : [ "mail" ],
                "subject" : "test",
                "message" : "Test",
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}


How do I link fields of a 'user content type' to the actual logged in user?

In Drupal 7, the simplest way to associate fields with a specific user is via Admin => Configuration => People => Account settings => Manage fields.

Because of its simplicity, I recommend this approach as a starting point. If it's not flexible enough, consider the contributed Profile 2 module.


Drupal7 multistep module - how to skip validation on previous

I'm not familiar with the multistep module, but in Drupal 7 this functionality can normally be accomplished by using #limit_validation_errors. It would probably be best to alter the form(s) that you need with hook_form_alter (or a variation of it) in a custom module. A basic untested example of what I described:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'THE_RELEVANT_FORM_ID') {
    $form['THE_PREVIOUS_BUTTON_KEY_NAME']['#limit_validation_errors'] = array();
  }
}


Commerce form refresh: 500 error on /en/system/ajax

Answering my own question so my stupidity is saved for all to learn from.

More details can be found in the "Reports" section of the site.

I have now resolved my issue, and it was a line of code in a custom module we made.


How can I point to a site in a not common directory path?

If I have an unusual directory structure I tend to use symlinks to get the folders into the correct place on the system.

If your site is running a standard drupal install you could install that to /var/www as normal

and create a link to your directory

ls -s /path/to/my/default/dir /var/www/default


Need to enter title before I make blog entry

Seems like an issue with the OG field permissions Configuration\Organic Groups\OG field permission overview.

Edit the node type and check the 'Edit Body field' and 'View Body field'.


how do i alter comments and comment form

To put this in my module I actually just did put the following code in my module:

function mymodule_preprocess_comment(&$vars) {
$vars['submitted'] = $vars['created'] . ' — ' . $vars['author'];
switch( $vars['node']->type )
 {
 case 'myContentType':
 $vars['title'] =FALSE;
 $vars['content']['links']['comment']['#links']['comment-reply'] = FALSE;
 $vars['content']['links']['comment']['#links']['comment-edit'] = FALSE;
 $vars['content']['links']['comment']['#links']['comment-delete'] = FALSE;
 break;
 }
}


You did not tell it to hide $node->field__iap_dl['und'][0]['url'].

The field probably did not show up in the rendered content, but it will still appear if you tell the template to print the information directly from the node object.

The simplest way to hide a field is to go to /admin/structure/types and under manage fields for the content type, mark the field as hidden.

EDIT:

Is this a cut and paste of your code? If so the fields names are different. field__iap_dl is not the same as field__ipa_dl.


if(!empty($profile->field_photo)) {...}

Should be able to work for you.


Views XML Backend, Render URL as MP3 player

Guess you should have every mp3 path wrapped by a player instance somehow. jPlayer has a nice field formatter which maybe works with your Views setup. Otherwise you'll maybe have to try to accomplish this on template level.


The solution is pretty simple.
Here is the code:

 class PersonViewsData extends EntityViewsData implements EntityViewsDataInterface {

  /**
   * {@inheritdoc}
   */
   public function getViewsData() {
   $data = parent::getViewsData();

   $data['person']['table']['base'] = array(
   'field' => 'id',
   'title' => $this->t('Person'),
    'help' => $this->t('The Person ID.'),
   );

 $data['person']['id'] = array(
'title' => t('Medecin tag test'),
'help' => t('Medecin tag test '),
'relationship' => array(
   // Views name of the table to join to for the relationship.
  'base' => 'person_tag_field_data',
  // Database field name in the other table to join on.
  'base field' => 'person_id',

  'id' => 'standard',
  // Default label for relationship in the UI.
  'label' => t('Test field'),
   ),
 );

 return $data;
 }
  }

Then you go in UI of the view:  Advanced-> Relation -> add a new relation.
You can see your new relationship there. After selecting it, go to "Add field ", you can then, find you new field that you can add to your view.

NB: There is no need to use hook_views_query_alter as mentionned in the question above.


Your code only work for Drupal 7. As you are using Drupal 6, please pass the current url as argument.

print drupal_get_path_alias($_GET['q']);


Ok, localhost replaced by $_SERVER['name'] value is only for presentation purposes. More info here: https://www.drupal.org/node/2512986

I had other issue with SOLR, so that's why it didn't work


How to use unique taxonomy term for nodes in Drupal 7?

You can install Pathauto module and set template for your node's path as you want on page admin/config/search/path/patterns

In this case You can use all this tokens with taxonomy term names, something like that:
[node:taxonomy-vocabulary-1:name] etc. List with all this tokens is on admin/config/search/path/patterns page


When I change theme, I can't see my sidebars

Because themes haven't the same region names, after changing your theme you must go to admin/structure/block and re-assign blocks to regions.


Adding js and css from a module but only to node view, not node edit

A quick, dirty way would be to check the current path for 'edit':

$node = menu_get_object();
if (!empty($node) && $node->type == 'my_node_type' && arg(2) != 'edit') {
  // ...
}


How do I implement access checks based on referring nodes in the grants system?

Given that we don't have an exhaustive list of requirements & Q&A isn't suited well for long discussions, it will be impossible to definitely say yes.

The grant system isn't designed around any sort idea of hierarchy. Is it possible to rewrite? It depends if you can refactor your existing logic around what the grant system supplies.

You've framed your question as a dilemma, but you really need both hooks to use the grant system:

hook_node_grants need to assign realm/gid grants that correspond to the $user and the available lesson nid they can access.
hook_node_access_records needs to fire against a lesson $node

So if you can:

Map the realm/gid grant keys to match to courses the user has access to (e.g. mymodule_course_realm/123 where 123 some group identifier that maps to a group of users that have course access, thus lesson nid access)
Trigger lesson save events upon course updates (e.g. using hook_node_update, hook_node_insert, etc. to look for update courses, then doing dummy saves on the lesson nodes) so that hook_node_access_records can fire against lesson nodes that have a changed relationship. (or build custom logic where you insert grants directly via NodeGrantDatabaseStorage::write())

You can probably refactor around the hooks the grant system provides.


Invalid CSRF token using flag.link_builder service (Flag module)

I created an example. You can check it and find the solution there.
https://github.com/Mykola-Veryha/ajax-flag-link


Gif animation and responsive image styles are not working

There's now imagemagick for Drupal 8. I've been using it with D8 responsive image styles and it works well, the gif animation stays intact.

You'll need to have imagemagick installed on your server and will need the path to the convert binary as well. Typically it's usr/bin or for example with MAMP, it's /Applications/MAMP/Library/bin/


Removing required attribute on user entity fields not working

Drupal has element_children() to help you safely loop over render arrays. Looping over such arrays manually will inevitably causes problems. Your code should look more like this:

foreach (element_children($form) as $key) {
  if (strpos($key, 'field_') !== FALSE) {
    $form[$key][LANGUAGE_NONE]['#required'] = FALSE;
  }
}

Incidentally, your current code doesn't work because you're modifying a variable that has only ben declared within that function's private scope.


After selecting "My billing information is the same...." an Edit button is shown

Figured it out - The commerce Autosku module had a bug which is fixed here:
https://www.drupal.org/project/commerce/issues/3086575
I decided to remove it entirely though as it doesn't work as well in D8 as it did in D7.


$term = Term::load($_tid);
$term->field_league_id->setValue('ID value');
$term->Save();

Additional info (requested in comments):

If you print out the object, you'll see that fields use the class core/lib/Drupal/Core/Field/FieldItemList.php.

By browsing through the methods, you'll see a few functions for interacting with the FieldItemList object, such as setValue(),

When I'm developing in Drupal 8, in order to learn the API, I use the

dump() function a lot to see what type of object I'm dealing with, and to inspect it's methods.

dump($term); die();

In fact, in my settings.local.php file I have an include

include 'my_settings.php';

and in there I have this function:

function nprint($obj) {
  dump($obj);
  die();
}

This is something I've been using for years to inspect objects.  Now that drupal is much more object-oriented, printing out objects to find what class they use is essential.

Another essential tool for me is using an editor that allows searching by file name (I use the free software Aptana Studio 3).

So if you see you're dealing with a "FieldItemList", you can do "command + t" to search by file name and type in "FieldItemList".  This saves a lot of web-based research.  And it helps you learn the code base.


How to add a Rules Condition to only allow voting for users with at least 30 user points?

You should try to implement the hook form alter Drupal API: hook_form_alter

Within the hook_form_alter you can validate, if the current user has more then 30 Points and disable the voting widget if the value is below 30.


What is the picture field in the node object?

This is the profile picture of the author of that node. You can upload that in your edit profile form and you can display it using theme('user_picture', $node);.

If you want to be able to attach images to nodes, have a look at CCK and ImageField..


You've got a logic error in your PHP. You're doing the following and setting some variables:

$variables['elements']['#cache']['max-age'] = '0';
$variables['elements']['#cache']['contexts'][] = 'url.path';
$variables['elements']['#cache']['contexts'][] = 'url.query_args:r';

But then in the next line you're redeclaring $variables['elements']['#cache'] as a new array of  ['tags' => ['my_paragraph']]; So everything you were doing previously in the
$variables['elements']['#cache'] is now gone

So your max-age declaration doesn't exist now. Try with just these 2 items and that should be all you need. The first to tell drupal not to cache the paragraph. The 2nd to disable anonymous page caching as setting max-age 0 doesnt disable the page cache:

$variables['elements']['#cache']['max-age'] = '0';
\Drupal::service('page_cache_kill_switch')->trigger();


Selecting First Name of Billing Address in Rules with Data Selector?

The solution likely depends on the billing customer profile's address field using a split first and last name field instead of the combined "full name" field. I've noticed on my Commerce site that there appears to be a bug in Address Field (hope to fix soon) that prevents a full name field from being split up into first and last name fields or vise versa.

Assuming your customers are entering first and last name separately, then all you have to do is drill down from the order through the profile to the first name on the address field. To do this using a Rules data selector, you'd first need to add two "Entity has field" conditions - one to ensure the commerce-order entity has the commerce_customer_billing field and a second to ensure the commerce-order:commerce-customer-billing entity has the commerce_customer_address field. IF those are in place, using the data selector you can drill down to the following token:

commerce-order:commerce-customer-billing:commerce-customer-address:first-name

The problem comes when you actually want to embed this value in the body of an e-mail. Right now, as far as I can tell, there is no chain of tokens (replacement patterns in Rules UI parlance) that will drill down to the first name using that same pattern. Looking in the code for addressfield.module, I don't see any token related code. This may just need to be opened as a feature request for the Token module.


How do I create a rule to prevent a user from sending a message via the Privatemsg module?

I don't think you can use the Rules module directly for this, because the only action that is provided by Privatemsg is called when a message has been sent. Therefore, I suggest you write an easy piece of code.

When a user hasn't set a profile picture yet, the field is empty or displays the default picture if you picked one in your configuration. In both cases, $user->picture has value 0. You could use this fact by hiding the sending form for a private message with the following code in a custom module:

function MYMODULE_form_privatemsg_new_alter(&$form, &$form_state, $form_id) {
  global $user;
  if ($user->picture==0) {
    hide($form);
  }
}

As suggested in the comment below, you can also use $form['#access'] = FALSE; instead of hide($form);. You can add a line of code that, for example, displays a message Please add a profile picture! or whatever you want in the if statement.


What controls the documents shown in the initial caller views? Is it a list of IDs, certain Taxonomy, some custom field, etc?

This is important as it will control how the view page lists the documents you want from the caller view.

If the initial view was displaying documents based on any option that was not ID, then you could easily create a link in the footer and include a parameter. The link should go to the URL of the View Page and include the arguments needed to filter the results shown on the page. It would look something like this:

http://www.example.com/documents/all?argumentname_here=[thiswouldbeatoken]

The token would be the value of the category, taxonomy, etc. that you used in the initial view.

The view page would need to be setup to not use AJAX, so it can use the URL arguments, and should have an exposed filter matching the filter of the caller view (you could then hide this with CSS so it can't be changed later, but let's leave it alone for now).

If you need help figuring out what the URL should look like, try filtering the View Page and clicking Apply and looking at the structure in the URL then mimic this in your initial caller view.

Hope this helps!


try to follow best practises:
as no need to render anything on your get the twig template as drupal core handles this.

module structure:

mymodule

mymodule.module
mymodule.info.yml
mymodule.libraries.yml
templates (dir)
-- templates/accesscode.html.twig
src (dir)
-- src/Plugin/Block
----- AccessCode.php

in mymodule.module

/**
 * Implements hook_theme().
 */
function mymodule_theme($existing, $type, $theme, $path) {
    return [
      'accesscode_block' => [
        'variables' => [
          'test' => null,
         ],
         'template' => 'accesscode',
//no need for full accesscode.html.twig as drupal knows.
      ],
    ];
}

then in your src/Plugin/Block/  AccessCode.php

 /**
 * {@inheritdoc}
 */
public function build() {
  $build = [];
  $build['my-block'] = [
      '#theme' => 'accesscode_block',
      '#test' => 1234,
  ];
  // Attach js or css easier.
  $build['#attached']['library'][] = 'mymodule/mymodule-accesscode';

// Could even add a form element like ..
 $build['some_field'] = [
   '#type' => 'textfield',
   '#title' => 'My Field:',
 ];
  return $build;
}

then in your accesscode.html.twig you can use the twig var {{test}}


How can I distinguish dynamic pages on a hook_menu?

You can tell if you're on a node page with menu_get_object(), but other than that it's difficult. menu_get_object() can return other objects than a node, but you need to know the type of entity before you call it (not much help in your situation). There's no generic solution that I know of in Drupal 7.

There is the drupal_match_path() function though, which you can use with wildcards, e.g.

if (drupal_match_path(request_path(), 'user/*/edit')) {
  // On a user edit page
}


The Features module is designed for this sort of database content to code version control. You could create your content type and export it as a Feature. That feature could then be version controlled like any other source code (using Git, SVN, etc).

If you just wanted to duplicate content types, the CCK module in Drupal 6 has a Content Copy sub-module that allows just that. In Drupal 7, I'm not sure if this is built into core. I would accomplish this task using Features.


Your problem might be because of the "language detection" configuration.

So check this configuration via Configuration -> Languages -> detection and selection: the order should be 'URL, Default, User', and not something like 'Default, URL, User'.


Drupal Console Installation: The "phar.readonly" setting needs to be off to create Phars

Add this to your php.ini:

phar.readonly = Off

It won't affect the console's operation (unless it needs to create phars at some point, in which case it now can, whereas it couldn't before).


You are supposed to put your templates into a /templates subfolder of your theme.

I'd recommend you find out how to enable debugging for Twig templates during development. Here is a how-to on DO: https://www.drupal.org/docs/8/theming/twig/debugging-twig-templates

By that you'll get template suggestions printed as HTML comments directly inside the markup of your page. It will suggest you certain file namings which then must be placed inside the /templates subdirectory of your theme.

And last but not least: Flush caches as often as possible. And find out how to disable caches completely during development. Here is another how-to on DO: https://www.drupal.org/node/2598914


Issues with regions using the Spaces Dashboard module

In case anyone still cares about this ...

You cannot drop blocks into empty regions, because they are empty. You can tell the dashboard settings to show all regions always, and then use CSS to hide the regions you dont want to be droppable ever via display none in CSS i think. Thats what I did.

The save button issue you would have to debug with Firebug and maybe a php profiler. You need to be sure the zen theme has allllll the html and css needed by the Gingko theme as lined out in that blog post above for the various JS actions to get processed correctly for the dashboard editor.

I followed the same tutorial for a Zen subtheme, spaces, dashboard and spaces_node and got it all working -- migrating to D7 looks like a pain in the future.


Geofield From another field showing only after saving from form

Geofield runs geofield_field_presave() before saving the data, and calculates various values for the field. Use the devel tab, and check whether the 'geom' array of the geofield is populated and the others are empty. That was my case, and I am using geofield_compute_values() to calculate these data, but afterwards I repopulate the 'geom' array again, because I think it converts it into WKB.
You can take a look at my code. There might be other, better solutions too.


redirecting to url that will never complate

The biggest issue is that the query string should be passed in separate from the base URL itself, eg, it should be part of the $options array argument to drupal_goto().  Otherwise, as you've noticed, drupal_goto() doubles up a lot of times.  If you fix that, I am fairly confident that you will get it to work.

Check out http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_goto/7
and
http://api.drupal.org/api/drupal/includes%21common.inc/function/url/7
for more information on this.


I think you can do it with drupal_add_js(); it seems that the scope key option is your friend!


How do I show an image using a relative or external url?

Sure, assuming Drupal 7, you can create your own field formatter for this in a custom module:

/**
 * Implements hook_field_formatter_info().
 */
function YOURMODULE_field_formatter_info() {

  $info = array();

  $info['image_source_formatter'] = array(
    'label' => t('Image Source Formatter'),
    'description' => t('Display the image sourced in this field.'),
    'field types' => array('text'),
  );

  return $info;

}

/**
 * Implements hook_field_formatter_view().
 */
function YOURMODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {

    case 'image_source_formatter':
      foreach ($items as $delta => $item) {
        $element[$delta] = array(
          '#theme' => 'image',
          '#path' => $item['safe_value'], // you can also set '#height', '#width', '#alt', '#title' and '#attributes' here as well, see theme_image() for more details
        );
      }
      break;

  }

  return $element;

}

Clear your caches to be on the safe side, and then you can use this new field formatter for this field, eg, you can go to the Manage Display in your Content Type and select this:

for the plain text field and instead of outputting the text, it will theme the text as the path to an image.

In this field, you can have sites/default/files/foo.jpg if you want and it will source it locally, or you can have http://www.example.com/foo/bar/baz.jpg and that'll work as well, as this will call theme('image', $variables) with the path set to the value of this field.

ADDITION:  The URL Formatter and Simple Field Formatter modules appear to do this for you if you don't want to create your own custom module.


How do I mirror a database from remote Linux into Windows localhost?

Step 4 is enough, they both will be in sync until you change data on one or the other instance.

As a bonus tip, you can ease this procedure by using drush to sync your environnements, via the use of drush aliases.

More details on this here.

Good-luck friend, happy coding.


In Views, you can add multiple Filters for the same field/column, and configure each one separately. So you can add one filter for "age is greater than 0", and "age is less than or equal to 10". Filters use an AND operator by default, so you should be all set with that, but FYI you can also change the operator to OR (you can also mix operators).

The only limitation may run into is whether or not "is greater than" and "is less than or equal to" are available options in the filter handler for the particular field you're filtering on. Number fields can do that, as far as I know... but strings can't (for example).


Why is a template being looked in a theme and not in my module?

Try like this:

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'mymodule_settings' => array(
      'variables' => array(
        'role' => NULL,
      )
      'template' => 'mymodule-settings',
    )
  );
}

You are missing to define template.


how to display sales volume for a product or a product variation in drupal commerce?

Look at https://drupal.org/project/commerce_reports and edit your product list View to do what it does in its product sales report.


Display rendered node in view mode X in self node in View mode Y

If you  want to do this job the one way is achieve  in node.tpl.php (and sub tpls like yourcontenttype--node.tpl.php ), and according to  variables in node tpl
 you can use both  teaser or full mode of node .also you can add your desire variable in theme preprocess ... , there is another  ways to do this with more developing solution


Separating contextual-links CSS, out of the CSS of menus and other associated markup

All contextual links are wrapped in a div.contextual, whereas navigational menu items are usually wrapped in a li.menu-item.


Geofield (geocode from another field) - database entry not created

So in the end the problem actually had two causes, which made it more difficult to solve than it should have been:

a bug in the geocoder codebase (solution: apply this patch)
the Google Maps API key used in the geocoder configuration was actually invalid for this type of operation, and so I had to generate another key specifically for geocoding operations. (I noticed the problem via a geocoder error saved in the recent log entries pages.)


How to specify a Rules condition related to select list values?

Below is a sample of a rule (in Rules export format) that should allow you to specify a Rules condition relation to a specific value selected via a selection list (and when a new node is created):

{ "rules_new_node_with_special_optionlist_value" : {
    "LABEL" : "New node with special optionlist value",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_optionlist" } },
      { "data_is" : { "data" : [ "node:field-optionlist" ], "value" : "C" } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "A new node got created with option list value = Custom" } }
    ]
  }
}

Some more details to further explain the above above sample:

The Rules event I'm using is "After saving new content".
In my case I have a selection list field with machine name field_optionlist.
This field actually has 3 possible values, like so:

A (=Advanced).
B (=Basic).
C (=Custom).

As a sample, I decided to use as condition "The selected value must be Custom".
If that value is selected, then (as Rules action), a message is shown like A new node got created with option list value = Custom (feel free to change that to whatever Rules action, this is how I often "unit test" new rules I write).

The "clue" to make this rule work is the condition Entity has field. That's also what is mentioned in the Rules UI when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')". I wouldn't be surprised if that is what you are missing in the rules conditions you tried so far ...

Note that I've not added a Rules condition here about selected content types, that's probably an extra condition you might want to add also. But if the selection list field is only used for the content types you're interested in, then the Entity has field condition should be sufficient already.

For a video tutorial that illustrates the importance of this Entity has field
condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in that video.


how to identify when a user is viewing their profile?

You can try 'title callback' attribute of hook_menu function.

$items['user/%user/gallery'] = array(
  'title callback' => 'get_title',
  'title arguments' => array(1),
  'page callback' => 'drupal_goto',
  'page arguments' => array('gallery'),
  'access callback' => 'user_access',
  'access arguments' => array('access content'),
  'type' => MENU_LOCAL_TASK,
);

And now you can call the function

function get_title($user_id) {
  global $user;
  $currentUser = $user->uid;
  //get profile url for that you can use $user_id as user id
  $profileUrl = arg(1);
  // compare usernames to determine whether the user is on their own profile.
  if($currentUser == $profileUrl) {
    //user is on their profile, display link
    $profileUrl = "i'm home";
  }
  else {
    $profileUrl = "away";
  }
  return $profileURL;
}


How to have postings in blog with custom teaser length and read more links

Can you use "Rewrite the output of this field" on the teaser (or the body) to limit it to a certain length? You can break on a word and show an ellipsis, and you will also be able to show the Read More link as usual. You have to use a row style that will let you use Fields for this, though. Otherwise, you could try to find the function that Views uses to do the same thing and add a template file and preprocess function to alter the teaser length in the same way.

Check the "Information" setting on the bottom-left of the Views 2 UI to see the available templates. You basically copy the base version of one of these to your theme directory, name it as specifically as is needed, and then change it to match your needs. In this case, you wouldn't change it, but you would implement THEMENAME_preprocess_PATTERN (<--- depends on which one) to style the field value appropriately.


What are my alternatives to disable update notifications but without using module Update Notifications Disable?

The method below will stop the "available update" emails Drupal admins receive.

Go here: http://yourwebsite.com/admin/reports/updates/settings
Remove your email(s) from the textarea: "E-mail addresses to notify when updates are available"
Save

Note: If you want to stop the "available updates" emails and the update alert messaging then simply disable the update module from http://yourwebsite.com/admin/modules


Simplest way to add a custom icon to a Navbar menu item

You can try to create custom module and implement hook_navbar() - for new items and hook_navbar_alter() - for already created items. In this hooks you can set custom css classes for items and attach you custom css file.

check /navbar/navbar.api.php file.

Looks like links came from navbar_menu_navigation_links(), they already have css class navbar-icon-<item_title>. You create custom css file in you module and add in hook_init(). Example of css styles you can get from navbar/css/navbar.icons.css or even copy it to your file and change if needed or add css for new items.


MiniOrange SAML SSO Drupal Module – Multilanguage Support

I figured it out.

The solution to this problem is so simple that i feel a bit embarrassed posting the solution. However, here it goes for those who may stumble upon it. This only needs to happen during the initial configuration and revert back once this step is completed (Based solely on my experience).

Drupal cache for anonymous users needs to be disabled during initial IdP and SP metadata and certificate negotiation
Drupal language negotiation needs to be turned off during initial IdP and SP metadata and certificate negotiation

Victor
"Patience and perseverance have a magical effect before which difficulties disappear and obstacles vanish"


How does Drupal handle concurrent user creation?

How is it possible that Drupal uses no transaction management?

It's not. The code you're querying is part of user_save(); the very first line in that function is:

$transaction = db_transaction();

The rest of the function is wrapped in a try...catch that explicitly rolls back the transaction upon exception. The same is true for node_save(), and plenty of other core functions that require transactions.

See the db_transaction() docs for more info.


How to sort node resource in index call in ascending order the in service module

It currently isn't possible. I have an issue and patch filed to make this a possibility. If you use the patch, it is possible using this query string:

?q=endpoint/taxonomy_term.json&fields=tid,name&options[orderby][name]=asc


Creating entity fields based on the fields from another entity

Sounds like you want to "listen" for the creation of entities of type Services, and upon creation, you want to programmatically create another of type Services Info. For that, I'd recommend adding the hook_ENTITY_TYPE_insert hook into your custom module. Replace hook and ENTITY_TYPE with your custom module name and entity type, of course.

The function signature will include $entity as a variable, so you can do any sort of tests you want to do on it (for example, make sure the corresponding Services Info entry hasn't already been created, to avoid a possible infinite loop if you ever decide to write the sync for both entity types).

This method will look something like:

function my_module_services_insert($entity) {

  // If desired, add code here to check for pre-existing mathing Services Info; this will depend on your implementation.
  // For example, if name is unique, run an entity query for services_info entities with a matching name.

  $new_entity_fields = [
    'name' => $entity->getName(), // This assumes you want the entry to have the same name as the Services entry; change if desired
    // Other fields as desired
  ];
  $storage = \Drupal::entityTypeManager()->getStorage('services_info'); // replace 'services_info' with your entity type
  $entity_new = $storage[$content_type]->create($new_entity_fields);
  $entity_new->save();
}

That should do the trick. Good luck!


Though they seem rather simple, "back" links on pages are rather tricky.  For the sake of this post, lets assume that you have a shopping site with a search page, and item detail pages.

One complication arises from the fact that users can arrive on the item detail page from multiple paths, including from Google and other pages that aren't in your site.  The back link really only makes sense when they have come from the search results page.

Another complication comes from how Drupal handles page caching.  You could potentially render a back link on a page, but unless you take some URL parameter into account (to have a different $cid), users may see the wrong cached page.  However, if you do tack on a back= to the URL parameter, you now severely lower the probability that a user will actually get a page from the cache.

I have mostly settled on Javascript based solutions.  There are two main options.  All are real variants on each other.  On the detail page, you jQuery in a link that goes back to the search results.

One way is to jQuery some logic on the search results page that sets a cookie with the exposed filer values, URL, or something similar.  Then on the detail page, you use this to go back.  However, this does not work cross-window / cross-tab, and there are security implications with building links this way.

The second way (and the way I have been using lately) just jQueries in a link on the item detail page that calls window.history.back().  This also isn't ideal, but it tends to be the least bad solution.


There are a few things affecting the difference in results. I'm sure you noticed the queries differ slightly.

The first and core issue is that the search module's main table is search_index, so each row is built around entries in that table and then joined outward to get more information. Your view is built around the node table and joined the other direction to search index.
The core search uses inner joins to get node data, which will be more limiting in its result sets (see this answer.)
The search_dataset table isn't joined from the Views search (see this answer for an explanation of why.)
Core search multiplies the search scores by relevance, which shouldn't affect their ranking, but looks confusing. See line 496-500 of search.extender.inc.

I know I only answered the first half of your question, but I hope this helps. I'm not sure it's possible to get a View to exactly mirror your search results without considerable customization.


Can I still update them through composer?

No, Composer can only manage packages that have been installed through Composer.

You could always add it to the "require" section of your existing composer.json (manually or by executing composer require), then Composer will know about it.


Highlighting primary link for specific content types

For Drupal 6 you have the choice of using the Menu Trails module, or the Menu Position module, which is available for both 6 and 7.

Both modules let you define criteria for where nodes should appear in the menu structure (eg, based on node type, and taxonomy).