HTML email containing selected node content

If you mean to sending whole nodes, than from my lookup, this might be a solution for you.

If this solution doesn't satisfy you, an alternative would be to send the user a link to the printing version of that given node. This shouldn't be very much complicated in PHP I guess.

A print version can be made with this module (Make sure the printing-versions have HTML canonical tags referencing to the main node).


How do I add a class to a section in omega?

This is untested, but I am pretty sure you just need to put this in mytheme/preprocess/preprocess-section.inc:

function mytheme_alpha_preprocess_section (&$variables)
{
  $variables['attributes_array']['class'][] = 'my-custom-class';
}

If you look at section.tpl.php, just $attributes gets printed out.  alpha_process() flattens $variables['attributes_array'] into $attributes.

Though, given that the header, content, and footer sections are unique, you probably don't need to explicitly add a class.  You can also add classes to the zone and zone wrappers inside each section directy with the UI at admin/appearance/settings/mytheme, or just replace "section" with "zone" in the code above.


How to create a chart system with Date ranges like Google Analytics?

Consider looking at the Comparison of Charting modules. Here is a quote from it:

  There are a variety of modules that facilitate the creation of charts. When it comes to charting in Drupal, the saying "There's a module for it" doesn't really apply. In this case, it's more accurate to say, "There are plenty of modules for it" ...

  These modules support for various charting libraries that may be desirable based on a site's desired appearance, feature-set, and licensing needs.

Using the Charts module is one of the options to consider. Here is part of what's currently included in that link (its project page):

  Transform Data into Information. Charts are a very good way to visualize a lot of data in a way that can be quickly digested.

  Features

  Wide chart type support: Pie, Line, Bar, Column, Area or Scatter charts.
  API: A Drupal-friendly syntax for creating charts easily, regardless of the underlying library.
  Views integration: Display the Views results as charts.
  Examples: The module includes lots of example charts for you to reference when building your own charts or chart library integration.
  Supported charting libraries: out of the box, you may use either (the new) Google Charts (GC for short) or Highcharts  (HC for short) as the charting library.

For 'documentation' about the charts module, you may want to start from its community documentation.

There is an issue also that might be worth looking at, about Graph node input over time (support date formatting on a continuous axis). In Comment #3 of that issue is stated: 'The trouble here is that neither Views nor Date modules provide aggregation options for date-based fields'.

Disclosure: I'm the author of the comparison (+ co-maintainer of the charts module), I hope this does not violate the site's policy on self-promotion.


Is Drupal scalable across multiple geographical locations?

I'll address your two points one by one and then discuss suggestions. This is a massive question in scope so I'm doing the best I can with what we've been provided.

WAN-wide cluster

Galera would be your best option if you wish to do an Active/Active setup. It's a tricky setup though and only the best hosts have figured it out (platform.sh comes to mind). Your other option is, by far, the most common. i.e. Master-Slave replication. You may find support for that in the Drupal community is more prevalent and that is worth its weight in database queries. :)

Content sharing between locations

You have some options when it comes to this. If your editors are to be collocated into a single geographical space, then sharing content isn't a problem. If you have a need to allow editors access from many geographical locations, you can do this in a two primary ways:

Active/Active using a Galera cluster as you indicated.
Active/Passive sites using a content deployment model using the Deploy module, Migrate module, Feeds module, or some combination of those.

Suggestions

Start thinking in terms of a single site, not sites. Ultimately, you'll employ a CDN of some kind to deliver content across regions. You had mentioned a concern with freshness of content but there are many ways to achieve the balance. i.e. Look to the Drupal modules Purge, Cache Actions, and Rules.
Consider Edge Side Includes which will allow the static serving of some content on a page but assets served from the edge for others.
I can't stress the importance of dedicated Memcache servers enough.
CDNs, Varnish and a module such as Boost are not mutually exclusive concepts. They can all be employed to keep things fast on the anonymous side. Bear in mind, however, the more layers you add; the greater the possible complexity.

Hope this is helpful.


modal window "loading" not loading in SCALD

Fixed it: the problem was that after going through the SCALD installation process the CKEditor was activated and the plugins declared in two locations:

under WYSIWYG Profiles
under CKEditor Profiles

This also corresponds with the error message I had in FF console:

uncaught exception: The editor instance "edit-body-und-0-value" is already attached to the provided element.

I simply deleted the WYSIWYG Profile and the problem was gone – modal window loading as it should. The detailled documentation of the process finding the error can be found over here: https://www.drupal.org/node/2454845#comment-9749453


Your version string is wrong, and shouldn't be manually included anyway, but that wouldn't cause this issue.

Drupal searches recursively for modules. I just recreated the same set-up that you had, and after a cache clear (do this by visiting admin/config/development/performance and clicking "Clear all caches").


List Nodes/Content Type Items with same tags as current

There's a module that does that for you: Similar by Terms. But you can also do this with Views using Contextual Filters & Relationships. This comment on Drupal.org explains it quite well:

  Its really easy in D7. Coding is not at all required.

  Taxonomy is a field in D7. I will explain how to create a Related
  Content block using Views.

  Create an argument by adding the taxonomy field on which you want to
  find the related nodes. Select "Provide default argument". Argument
  type = "Taxonomy Term ID from URL" Remove tick from "Load default
  argument from term page" Tick the "Load default argument from node
  page, thats good for related taxonomy blocks." To remove duplicates
  you have to follow the following points.

  Open "Query settings" in the "Advanced Settings". Tick "Distinct".
  This gives you a perfect "Related Articles" or "Related Nodes" using
  Views.


If you're using the filtered HTML input format, that would be stripping it out.

If not, it sounds like your markup is weird. The way you describe it, what might work if it read
 (not that I recommend this) reads
. I think WYSWIG editors tend to prefer classes to putting styles right in the markup, so I'd do something like
 and add .centered-text{ text-align:center } to your stylesheet.

I would double-check your site with a DOM inspector to make sure your style on your
 isn't being overridden by a stylesheet. If nothing else works, you could use a different editor. jWYSIWYG, openWYSIWYG, Whizzywig, and nicEditor use align="wherever" instead of style="text-align:wherever" which might work (again, I don't recommend this, but it's a potential short-term solution. For reference, MarkItUp and WYMeditor don't offer alignment buttons, and CKEditor, FCKEditor, TinyMCE, and YUIeditor do it the "right" way, using style="")


How to create a scheduler for updating a boolean value using Rules?

It's defined in node.module like follows

define('NODE_NEW_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);

AFAIK, you can't redefine this value. I think you need to change and use your value in all the places.

I'll check and If I found better option I'll update my answer :)


help me understand the drupal way to develop this module

Yes it would be easier to develop as you have in your example. To make it so that anyone can update let's try to do it a Drupal way. This way may not be the quickest/easiest but it will give you an idea of Drupal and make it easy to update the content.

There are many distros that help make Drupal easier I would suggest Panopoly to start with. Or you can use core and install the modules as you go (I will probably miss several modules that I am just really used to always being there that are actually contrib).

1. Custom Content Type
Create a 'sessions' CT and add the fields and fieldset that you need i.e. 'Read it' and 'Do it'. You can use file fields and field_collections.

2. Create View Use the Views module to create a view of Content Type: 'sessions'. You can create an exposed filter for the drop down.

3. Create a Basic Page and add the view block to it (personal preference to suggest views block and not views page for expandability, etc.).

No code this way all GUI. The user would just have to create new content of this type and it would appear on the page.

Tip: Use Features to save your work and provide an exportable default.


Is there a way to make a view's content shown right-to-left without manually changing CSS styles?

An alternative way so you don't have to change css all the time.

You can probably setup a generic RTL css rule in your theme (one time)

.rtl {
    direction: rtl;
}

and use this rule in each of your views under advanced > css class as you see fit.

Alternatively as Leymannx points out you can add global text area in the header of your view and add the following css

<style>.view {direction: rtl;}</style>

using Full HTML format as shown in the screenshots below

NOTE: view class is included in all views so this solution could potential affect all views on the page


Starting batch operations from hook_node_update()

As pointed in kiamlaluno's answer, there is no execution context information passed to hook_node_update() implementations. So we ended up using debug_backtrace() to look up for the currently processed form (if any). If a form is processed, drupal_process_form() will handle batch processing for us. If not, we can't safely start a progressive processing of the batch. But we can run the whole batch in a single pass. This can lead to timeout and should really be replaced. Either by delaying operations execution (queued operations) or by starting progressive processing of the batch after all update hook have been run (but how ?).

function _MODULE_get_currently_processed_form() {
  $backtrace = debug_backtrace();
  while ($frame = next($backtrace)) {
    if (isset($frame['function']) && $frame['function'] == 'drupal_process_form') {
      return array(
        'form_id' => $frame['args'][0],
        'form' => &$frame['args'][1],
        'form_state' => &$frame['args'][2],
      );
    }
  }
  return FALSE;
}

function MODULE_node_update($node) {
  if (some_condition_on($node)) {
    $batch = array(
      'operations' => array(
        // ...
      ),
    );
    batch_set($batch);
    $currently_processed_form = _MODULE_get_currently_processed_form();
    if (!$currently_processed_form) {
      // We are not currently processing a form, the batch processing won't be
      // automatically started. But we cannot start processing it because it
      // will end the request and prevent any other post node update code to
      // run. So we process the batch in a single pass and hope for the best.
      // FIXME: Start progressive processing of the batch after node update
      // processing (using hook_exit?) or use other delayed execution (using
      // queued operation?)
      $batch =& batch_get();
      $batch['progressive'] = FALSE;
      batch_process();
    }
  }
}


In Drupal 7, how do I display my taxonomy term fields while creating content when using a checkbox field?

I don't think there's a way to do this using the UI, but you should be able to do this using template_preprocess_field().

Store the full version of each acronym as the description on each of your taxonomy terms. The acronym would be the title.

Then you'll want to do something like:

*note that this is all pseudo-code as I don't have a version of Drupal handy to test this, but with some kpr() or var_dump() calls you should be able to debug it for your needs*

<?php
function my_theme_preprocess_field(&$vars) {
  $element = $vars['element'];
  // Modify the output of the taxonomy term field
  if ($element['#field_name'] === 'field_my_taxonomy_term') {
    // Get the title and description
    $item = $vars['items'];
    $acronym = $vars['items'][0]['title'];
    $description = $vars['items'][0]['description'];

    //create the html you want
    $html = '<span>'.$acronym.' - '.$description.'</span>';

    //now replace the default field markup with your new markup
    $vars['items'][0]['#markup'] = $html;

  }
}
?>


I just followed the dependency chain of the example module:

ExampleNodeMigration extends DrupalNode6Migration
DrupalNode6Migration extends DrupalNodeMigration
DrupalNodeMigration extends DrupalMigration
DrupalMigration extends Migration

That means that as long as your class, like ExampleNodeMigration, extends a class down the chain from class Migration, your team implementation should be as in the example you gave.

In light of the changes you made:

  How do I modify DrupalMigration class properties so that I can set the team's properties and have all the children classes inherit this property?

You insert your own custom class that extends the lowest class in the chain that has what you need, then have your migration modules extend it. So if you are migrating users, you would extend DrupalUser7Migration in some custom class, then have your various user migration classes extend DrupalUser7Migration, and so on for each variety of thing that migrate_d2d can migrate. That may be the best you can do because PHP is single-inheritance.

There is another way to get around single-inheritance and not repeat yourself. You can create a trait, called, for example, MyMigrationSettings.

trait MyMigrationSettings {
  function setTeam() {
    $this->team = array(
    new MigrateTeamMember('Liz Taster', 'ltaster@example.com',
                        t('Product Owner')),
    new MigrateTeamMember('Larry Brewer', 'lbrewer@example.com',
                        t('Implementor')),
    );
  }
}

Then, use the trait in your migration classes:

class ExampleNodeMigration extends DrupalNode6Migration {
  use MyMigrationSettings;
  public function __construct($arguments) {
    parent::__construct($arguments);
    $this->setTeam();
    // ...
  );
}

I have not tested this code and I am just literally typing it into the comment box.


Have you tried the Postal Code module?

It seems to support dutch postal codes as well.


Is it possible to alter html_head using hook_page_attachments_alter() per node?

Yes, when you get the current node.
/**
 * Implements hook_page_attachments_alter().
 */
function MYMODULE_page_attachments_alter(array &$attachments) {

  $node = \Drupal::routeMatch()->getParameter('node');

  if ($node instanceof \Drupal\node\NodeInterface) {

    $attachments['#attached']['html_head'][] = [
      [
        '#tag' => 'script',
        '#value' => 'alert("' . $node->getTitle() . '")',
      ],
      'MYMODULE_foobar',
    ];
  }
}

If this really should be in a foreach, you need to ensure to give each tag an unique key.
foreach ($nodes as $node) {
  $description = [
    [
      '#tag' => 'script',
    ],
    ...
  ];
  $page['#attached']['html_head'][] = [$description, 'description_' . $node->id()];
}


Boost - Ignore url variables but still cache the page

i just saw you in this issue :D

have you tried:

2 options to solve this. Create a rewrite rule at the server level to strip userID=1234 or in setting.php strip it out & use hook_boot to add it back in.

  A more interesting solution proposed in this thread by mikeytown
  (maintainer of several high performance Drupal modules like Boost and
  Advagg), is to remove specific query parameter at the server level or
  in settings.php, thereby tricking Drupal into getting and setting the
  page cache using a cleaner URL string.  This will almost certainly
  have unintended consequences, however, and should be implemented with
  extreme caution.

Found here: http://www.asmallwebfirm.net/blogs/2012/07/page-cache-vs-landing-page-performance


Is there a module? Or: How to alter the Drupal pager to get this?

You need to look at the code above and understand what it is doing. Where does li.pager-last come from? Notice that the last line uses theme('item_list') to build the result and it passes in $items. Just above that you'll see the code which adds an item to the $items array with 'class' => 'pager-last':

if ($li_last) {
  $items[] = array(
    'class' => 'pager-last',
    'data' => $li_last,
  );
}

If you want to add another item after li.pager-last, you might try duplicating these 5 lines and modifying them to do what you want.


The easiest way would be to use a helper function to provide your positions which you can then reference back to. For example

// In the form function
$form['layout']['body_image_position'] = array(
  '#type' => 'select',
  '#title' => t('How should Body Image be Positioned'),
  '#options' => MYTHEME_position_settings()
  '#default_value' => 'body_image_position_right'
);

function MYTHEME_position_settings() {
  return array(
    'body_image_position_right' => t('Image on Right'),
    'body_image_position_bottom' => t('Image on Left'),
    'body_image_position_left' => t('Image Below'),
  );
}

// In the retrieval function
$key = theme_get_setting('body_image_position');
$settings = MYTHEME_position_settings();
$friendly_name = $settings[$key];

The form submission will essentially ignore the label for checkboxes/radios/select lists as it only deals with the key so you'll need to implement some sort of mechanism like this to get at your original labels.


How to build a dynamic hyperlink within a Page (Panels)?

You would want to override the template for the content type you're using, in your theme. If you're using a base theme, copy the node template into your theme and then change it there (don't change the base theme directly). More info on phptemplate and theming is on Drupal.org.

If you don't code, doing this in a View would work. Here's what I would do:

Create a content type with plain text fields for all the things you need to make dynamic (if you haven't already done this)
Create a View that only displays one item at a time.
I'm not sure what your setup is exactly like, so it may take some creativity to filter it to display the right one. You might want to try something like References to relate an Event node to your particular node of your new content type, or configure some contextual filters to pick the right values based on the URL of the Event page, or something.
Have your View create a Block and have that Block display on Event nodes
Configure your View to rewrite output of a field and make all other fields excluded from display. Views seems to have the peculiarity of only allowing you to use tokens from fields that were added to the display before the field being rewritted so use the last one added.
????
PROFIT

But that's a ton of work. You're better off going with the phptemplate option.


Execute a custom function on 'user register' or 'login'

You can do this using the following hooks in your module.

hook_user_login
hook_user_register (In D7 we had user_insert hook.)

Examples:

User Login Hook:

function mymodule_user_login($account){

   //your code here
}

User Register Hook:

function mymodule_user_insert(Drupal\Core\Entity\EntityInterface $entity){

   //your code here

}


Migrate content based on publish date content

Have you had a look at the "Highwater mark" part of the migration documentation? this may be what you are looking for.
http://drupal.org/node/1223936


Field group horizontal tabs are displayed as accordions in small screens

Perhaps try out the patch to make this setting configurable as proposed for field_group module in this issue

Users have reported that it applies cleanly and allows for the setting to trigger based on a custom breakpoint.

Testing it out and reporting success/failure on that issue gives a better chance for this feature to be incrorporated into the module itself.

NOTE: the patch probably needs to be applied to the dev version of the field_group module


I am unable to install module for my Drupal 7

The alternate way to install module is to download the module and untar/unzip the files under /drupal/sites/all/modules/

Using Admin UI you can enable the module.


In drupal 7, go to your content type in:

/admin/structure/types/manage/yourcontentype/fields/

Edit your field and check if it is validating your URL. I have attached a picture for better explanation.


How do I create anonymous emails sent by users and allow other users to reply back to the anonymous email?

You could use the following components:

an email server you control to create temporary email accounts, or a mail relay service.
use Relation or a custom user field for a user's anonymous email thru user02193213@yoursite.com. Enforce uniqueness of this field. Relation can do alot of this for you as a developer (create a user <-> anonymous email relation, attach category tags to the Relation Entity itself and use relation_query to build reusable lookup functions.
store a mapping of Drupal uid to anonymous emails. In general this is outlined here: https://stackoverflow.com/questions/8179047/email-piping-in-php-like-craigslist-how-do-i-associate-real-emails
upon content submission use Rules to lookup anonymous email addresses of content owner to logged in user and send the email. Your email server you control can then forward to real addresses.

Questions regarding email setup are not drupal setup and inappropriate here. I've just outlined an approach for the Drupal side of things.


Adjust a view so there is one image of size normal and other images are thumbnails

Check out the View Nodes Split module.

This module allows site administrators or builders to have a different view mode for the first nodes of a view result.
If you ever had (or currently have) this scenario: you have a view of nodes but you want that the first node (or first X nodes) to have a different view mode, then this module is for you. The module can split the results from a view into 2 lists. It actually does not make 2 separate lists, it just uses a a different view mode to render the first X nodes from a view.

You can also use a view attachment to display a node and attach more nodes to it. Make sure you offset your attached view by 1.


How to hide certain items in a term reference field?

You can use the Entity reference module to achieve this goal.

Install Entity Reference module.
Create a view of terms, with a display type of Entity Referance, and your filters/conditions
Create a field of Entity Reference type.
In field settings: Choose its target type is Taxonomy Term.
In entity selection mode choose 'Views Filter by an entity referance view'. Choose the view you created above in 'View used to select entities'.
Now save it.


If your question is "How do I add theme javascript to the footer instead of the header?", I have this snippet in my starter theme's template.php file:

/**
 * Add a custom, theme-specific JS file. Added here so it can be placed in the
 * footer instead of the header which is where the info file places JS.
 */
$options = array(
  'type' => 'file',
  'scope' => 'footer',
);
drupal_add_js(drupal_get_path('theme', 'bootstrap_starter') . '/js/theme.js', $options);

Change bootstrap_starter to the name of your theme and make sure the folder js contains a file named theme.js within your theme folder.

See drupal_add_js() for more info.


How do I access a taxonomy term's field(s)?

If you are going to be accessing the content of what drupal call entities (data objects, like nodes, users, taxonomies etc), you might considder using the entity module. It adds some nice helper functions. What Nikit writes is not possible, you would do something like this:

$term_id_1 = $node->field_term['und'][0]['tid'];
$term_id_2 = $node->field_term['und'][1]['tid'];

Then you would have to load the terms etc. Instead with the entity module you can do.

$images = array();

$node_wrapper = entity_metadata_wrapper('node', $node);
foreach ($node_wrapper->field_term as $term_wrapper) {
  $images[] = $term_wrapper->field_image->value();
}

$images will now be an array with the image field object that holds info like uri, fid etc.


You can easily hook into the validation process by implementing hook_form_alter(&$form, &$form_state, $form_id) or it's cousin hook_form_FORM_ID_alter(). There you can inspect the $form variable, find out where the array of validation functions is, and perform array_unshift() on it.

You could also use the form alter hooks to modify the #required property of your title field, therefore preventing further validation errors down the line.

Don't forget that in order for your array_unshift() operation to be successful, the form needs to be passed by reference to your hook, or else you would only be modifying a local copy of the form variable. It's very easy to forget adding the ampersand & in front of $form in the hook implementation. i.e. ...& $form...


Wrap comment replies in a collapsible fieldset

Implement hook_form_alter() or hook_form_FORM_ID_alter() and add the collapsible fieldset to the form field.  For example:

function MODULE_form_comment_form_alter(&$form, &$form_state, $form_id) {
    //Create the fieldset
    $form['custom_fieldset'] = array(
        '#type' => 'fieldset',
        '#title' => t('My Collapsible Fieldset'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
    );

    //Move the field into the fieldset
    $form['custom_fieldset']['comment_body'] = $form['comment_body'];

    //Unset the original field
    unset($form['comment_body']);
}

You can set '#collapsed' => TRUE if you want the fieldset to be closed by default.

If you're looking for a Module based approach, you may want to look into the Field group project.

I'm not sure how well this module will get along with the Comment module though.  You may need to implement hook_form_alter() in a custom module or in your theme.


View outputs Access-Control-Allow-Origin header

You can use the https://www.drupal.org/project/cors module to add the allowed domains to your project.

Or you can alter the .htaccess file or change the headers of the php file like described in https://stackoverflow.com/questions/14467673/enable-cors-in-htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [QSA,L]
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"


How can i add a page.tpl.php for a page type and a language?

It doesn't work because page--type-receipe.tpl.php isn't a valid template suggestion. If you're looking to theme a page by node type & language, you can do something like this to create your own theme suggestions inside your theme's template.php.

function MYTHEME_preprocess_page(&$variables) {
  global $language;

  if(isset($language->language) && isset($variables['node'])) {
    $variables['theme_hook_suggestions'][] = 'page__'.$variables['node']->language.'__'.$variables['node']->type;
  }
}

This will let you make page--en--recipe.tpl.php a valid template file for a page showing a recipe node in english.


It's good you're using Private file system. That is one level of control you need to prevent the files from being freely downloaded.
Other levels of control are the Page (Views list), Node, and File fields.
You could create two different Views, one without the file field, and one with it, and use Role permissions on those pages. In this case you'd have to make nodes not accessible to all, which isn't fortunate if you want to control other types differently. There are modules, though, that you can use to set up different node type permissions.
But in your case I think it makes the most sense to have different File permissions. This way you don't have to duplicate Views or control node access.
You can do this with the Field Permissions module.
All can see the nodes and Views pages, but only special Roles will see the File field that has those special permissions.


How do I speed up `drush test-run` (compared to the SimpleTest UI)?

Consider using "php scripts/run-tests.sh" instead of "drush run-test". The former supports parallel test execution which improves runtime (as long as you have multiple test-classes). Compare:

$ php scripts/run-tests.sh --url http://d45.l User
...
Test run duration: 11 min 45 sec
$ php scripts/run-tests.sh --url http://d45.l --concurrency 3 User
...
Test run duration: 4 min 13 sec
$ php scripts/run-tests.sh --url http://d45.l --concurrency 6 User
...
Test run duration: 3 min 7 sec


There is a setting to flush the image style at admin/config/media/image-styles:

Or you can use drush:

drush image-flush --all (flush all styles)
drush image-flush thumbnail (flush thumbnail style)


Problem with images on a slideshow of product displays (Views Slide, Flexslider)

I added a relationship to "Content: Referenced Product" and this solved the issue.  For anyone who is new to Drupal, it isn't obvious that this is (field SKU), but this is how to link back to the content in the Product Nodes in commerce.


How to apply a custom class to a .field__item in an entity reference display?

You can add classes in the twig template directly, or through a preprocess function.

Preprocess

Docs provide some patterns to follow: https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/template_preprocess_field/8.2.x

function HOOK_preprocess_field(&$variables) {
  $element = $variables['element'];

  switch ($element['#field_name']) {
    case 'MY_FIELD_NAME':
      $delta = 0;
      while(!empty($element[$delta])) {
        $variables['items'][$delta]['attributes']->setAttribute('class', 'custom-class-name');
        $delta++;
      }

      break;
  }
}

This applied the class to the entire entity, alongside field__item.

Template

If you have twig debugging enabled, you can see quickly what's a good template name. I tested with field--node--FIELD-NAME.html.twig. Using the field template from classy for example, just add the class at the end of the list.

{%
  set classes = [
    'field',
    'field--name-' ~ field_name|clean_class,
    'field--type-' ~ field_type|clean_class,
    'field--label-' ~ label_display,
    'custom-class-name',
  ]
%}

This applied the class just to the field, not the label. But you could modify the template to print the classes elsewhere.


How do I remove the “submitted by” text on Views in drupal 7

Since the QA didn't care to explore on his found solution.

Assuming your view displays teaser texts / full posts, go to the content type settings (e.g. /admin/structure/types/manage/page for Basic page) and disable the option "Display author and date information." under Display settings.


Why form redirects to encoded url when having GET params?

You just need to adjust the param value from a string to an array for $form_state['redirect']

It is in the documentation for drupal_redirect_form

  $form_state['redirect'] determines where to redirect the user. This can be set either to a string (the path to redirect to), or an array of arguments for drupal_goto().

Example:

$form_state['redirect'] = array(
  arg(0) . '/' . arg(1) . '/' . arg(2),
  'query' => array(
        'brand' => $form_state['values']['brand'],
        'categ' => arg(2)
  )
);


Not Getting your question exactly.But if you want to add read more link in the block then why are you written the code into node tpl file.No need to writing code into tpl file.If views preview shows the link then it will definitely render on the page.Make sure you checked it as admin. If you check it as anonymous user then it may be an issue of menu permission.


How to create a Hook_Schema for Fieldset Form?

is your schema already defined for a table in MySQL somewhere, did you already make it in like phpmyadmin? ... if so, the Schema module will show you the exact PHP needed for hook_schema

I recommend:

make a table in your drupal database using something like Navicat, phpmyadmin, mysql admin ... whatever. The table columns are your form field inputs and at least additionally a primary key.
install Schema module and goto admin/structure/schema/inspect. Copy + Paste + Profit

// in yourmodule.install
function yourmodule_schema() {
  // ... paste the $schema['your_table'] textarea stuff Schema page auto-generated for you.
  return $schema;
}


How to output the Panel node's template name in the Body class list

Here is what I'm using in my Zen subtheme's template.php

// Add the panel's template name to the page's body classes
if($panel_page = page_manager_get_current_page()) {
  $display = panels_get_current_page_display();
  $layout = $display->layout;
  $variables['classes_array'][] = 'panel-layout-' . $layout;
}

Hope that helps!


Text format dropdown has dissapeared from edit article form

I have experienced this issue when a rich-text editor is enabled. In my experience, the input format box reappears when the rich-text editor is disabled.


How to hide the configure slider in MD Slider?

You probably would need to uncheck the permissions of the MD Slider to administrator. You can do this by going to the admin/people/permissions.


How to rebuild derived plugins after new entities are installed?

Yes you should do that.

Module install is not really a problem as all plugins are invalidated then anyway, but entities can also be changed in the UI.

See \Drupal\block_content\Entity\BlockContent::postSave() for an example that does that in core.


How can I create a new page template for the user registration page?

There are so many ways to theming your registration page.
You can create user-register.tpl.php

To know about how to create user-register.tpl.php refer below links.

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

https://api.drupal.org/api/drupal/modules!user!user-profile.tpl.php/7

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

If you want to know how to create tpl files.

Page template suggestions are not working


You're looking for the _admin_route option:

aggregator.feed_add:
  path: '/aggregator/sources/add'
  defaults:
    _controller: '\Drupal\aggregator\Controller\AggregatorController::feedAdd'
    _title: 'Add feed'
  requirements:
    _permission: 'administer news feeds'
  options:
    _admin_route: TRUE


How do I add a meta tag in inside the  tag?

From different sources I found different way of adding meta tags in Drupal 8, hence compiling all ways.

1. Using THEME.theme file

I think same question has been asked on stakeoverflow: add meta tag to head in drupal 8
 and if you see the answer of @Danielishko, He has provided the following code,

Just add following code in your THEME.theme file, clear cache and you will be good to go. Note: function theme_preprocess_html(&$variables) {...} should be already there in your .theme file, hence do not create new one, otherwise it will give error.

function theme_preprocess_html(&$variables) {

  $xuacompatible = [
    '#tag' => 'meta',
    '#attributes' => [
      'http-equiv' => 'x-ua-compatible',
      'content' => 'ie=edge',
    ],
  ];

  $variables['page']['#attached']['html_head'][] = [$xuacompatible, 'x-ua-compatible'];
}

Output image:

2. Through Template file:

Another Question was asked on this topic: How to set / remove drupal 8 meta tags.

If you read the question in the above mentioned link, Questioner has mentioned that using html.html.twig template file you can directly add meta tags to ....

html.html.twig file you can find at core/modules/sytem/templates/html.html.twig, You can copy and paste that in your theme's template folder and your theme will use that one.

from html.html.twig

<!DOCTYPE html>

    <title>{{ head_title|safe_join(' | ') }}</title>
    <css-placeholder token="{{ placeholder_token|raw }}">
    <js-placeholder token="{{ placeholder_token|raw }}">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    {#
      Keyboard navigation/accessibility link to main content section in
      page.html.twig.
    #}

      {{ 'Skip to main content'|t }}

    {{ page_top }}
    {{ page }}
    {{ page_bottom }}
    <js-bottom-placeholder token="{{ placeholder_token|raw }}">

Output Image:

NOTE: This is my own logic and tried to find reference for this, I did not find any reference regarding this except one line provides by Questioner in above link, but since we edit template file for adding other stuff why we can not use to add  tags. PLEASE PROVIDE COMMENTS IF THIS IS NOT  A RIGHT WAY TO DO, It will also be learning experience for me, Thanks.

3. Create your own Custom Module

If you refer this tutorial of: Adding new HTML tags in the  in Drupal 8, He has described the general way of adding tag to head in Drupal 8. I have modified as per your requirement. You can refer this tutorial: Drupal 8: Create a Simple Module for how to develop simple module in Drupal 8, and following code will go in your module_name.module file, that's it.

for module_name.module file,

<?php
/**
 * Implements hook_page_attachments().
 */
function module_name_page_attachments(array &$page) {
  $xuacompatible = [
        '#tag' => 'meta',
        '#attributes' => [
          'http-equiv' => 'x-ua-compatible',
          'content' => 'ie=edge',
        ],
      ];
  $page['#attached']['html_head'][] = [$xuacompatible, 'x-ua-compatible'];
}

I think, this method and method described in 1st option are quite same.

4. Using Drupal module

I am not sure, how to use this approach, I tried to find. Here I am mentioning because when point of adding meta tags comes this module always pop-up.

I think this approach you should use. In the accepted answer he has describe the module way and you can use, Metatag module for that. This module has dependent modules Token & Ctools, which is very common thing. In that answer whole procedure has been described, so I am not mentioning here.


Your implementation of the block hooks is wrong.  Try the below:

function quick_links_block_info() {
  $blocks['quick_links_staff'] = array(
    'info' => t('Quick Links'),
    'status' => 1,
  );
  return $blocks;
}

function quick_links_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'quick_links_staff':
      $block['subject'] = t('Quick Links');
      $block['content'] = quick_links_get_links();
      break;
  }
  return $block;
}

function quick_links_get_links($department = '') {
  return t('Hi');
}

I've namespaced the block, and changed the status from TRUE to 1, as per the hook_block_info() docs.  I've also removed the assignment of $delta, as this is passed through automatically.

REFERENCES

hook_block_info()

hook_block_view()


Can't import configs on server due to some entities

This is tricky to solve. And with the limited data provided in the question, there are a few steps that I would suggest you take:

Backup!!! No need to emphasize more as this is production environment. The following steps should be carried out on your local setup and not production.
Find out what changed in the entities. The change should most probably be in the field settings for one or more fields in the entity types listed in the messages. Check with the developer if you are not sure about the changes. If the changes are not desired, simply export the current configuration using drush cex and push it. If this is the case, then it will be ideal for all. If not continue to next step.
Since deleting the fields is not an option as it would delete the data, create a new field with exactly the same label but different machine name. These fields could have desired settings.
Write a script (update hook, migration, drush command - recommended, etc) which will copy the data from the original fields' to the new field with the correct settings.
This script could also then delete the field with the older setting which was preventing the config import.

Note: You need to consider the usage of the field at the implementation level and make sure you handle those. Like:

In any view mode for the entities.
In any view.
Any preprocess function.
If the field template has been overridden.

The data is very crucial here. So TEST, TEST, and TEST! Everything would be easy if there are a limited amount of entities with values in the conflicting fields and that the data could be handled manually by deleting the fields.


I would go with Media suite simply because I believe files should be treated like full entities as nodes are. It grants you more options and flexibility in media management and reuse instead of the standard upload field.


Drupal 8 - How to add link & display in twig template

You should add the link in the form builder, something like the following example:.

$forgot_password_link = \Drupal\Core\Link::createFromRoute($this->t('Password link'), 'user.pass')->toRenderable();
$form['forgot_password_link'] = [
  '#markup' => render($forgot_password_link),
];


You can use views , build a view of content type book , then filter them based on taxonomy term , you even can expose the filter and let it to user to decide which genres want to view .


You should use hook_apachesolr_index_document_build in your custom module. This hook helps to extend basic SOLR Document object and adds custom fields for indexing.

If 'Keywords' field has machine name 'field_keywords' hook implementation may be as below

/**
 * Implements hook_apachesolr_index_document_build().
 */
function MY_MODULE_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
  if ($entity_type == 'node') {
    // Adds 'Keywords' field as a separate field to Solr index.
    $document->keywords = isset($entity->field_keywords[LANGUAGE_NONE][0]['safe_value']) ?
      $entity->field_keywords[LANGUAGE_NONE][0]['safe_value'] : '';
  }
}


Get list of custom fields and update their settings programatically

Try this one:

$fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('contact_message', 'personal');

You can change personal to your contact form bundle.


How can I set-up a custom formatter that uses target="_blank"?

OK, found an answer that works for implementing the hook_file_link() function in the theme's template.php file:

Answer at https://drupal.org/node/301234#comment-4764468 - copied here:

function THEMENAME_file_link($variables) {
  $file = $variables['file'];
  $icon_directory = $variables['icon_directory'];

  $url = file_create_url($file->uri);
  $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));

  // Set options as per anchor format described at
  // http://microformats.org/wiki/file-format-examples
  $options = array(
    'attributes' => array(
      'type' => $file->filemime . '; length=' . $file->filesize,
    ),
  );

  // Use the description as the link text if available.
  if (empty($file->description)) {
    $link_text = $file->filename;
  }
  else {
    $link_text = $file->description;
    $options['attributes']['title'] = check_plain($file->filename);
  }

  //open files of particular mime types in new window
  $new_window_mimetypes = array('application/pdf','text/plain');
  if (in_array($file->filemime, $new_window_mimetypes)) {
    $options['attributes']['target'] = '_blank';
  }

  return '' . $icon . ' ' . l($link_text, $url, $options) . '';
}

Simply change THEMENAME to your theme name and place the code in the template file. I suppose I could extract this out into a custom formatter too.


Creating a form thats gives user chance to filter nodes

In Views:

create a new view, page or block limited to that content type, as the display format you want (table, teaser, etc)
create a filter field, choose the Country
click on 'Expose this filter to visitors, to allow them to change it'
Filter: operator - is equal to (you can expose this operator if desired, allowing the user to choose is equal to, is not equal to, contains, etc)
if you want the View empty to start, click on 'required' in the filter field set up
create a new filter field for Category and repeat the same steps

You will want to play around with the settings to get it exactly how you want, but this should get you going in the right direction.


Modify Userpoints List FormTo Show Entity ID?

Do you have the Devel module installed? dpm() won't work without that.


This solves the problem:

namespace service;

use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Url;
use entity\Entity;

class PostTypeService
{
    public static function getEntititiesByPostType($postType, $entities = array(), $nid = NULL)
    {

        if ($nid != NULL) {
            $nids = \Drupal::entityQuery('node')
                ->condition('type', $postType)
                ->condition('status', 1)
                ->condition('nid', $nid)
                ->execute();
        } else {
            $nids = \Drupal::entityQuery('node')
                ->condition('type', $postType)
                ->condition('status', 1)
                ->execute();

        }

        $nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

        $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
        $defaultLang = \Drupal::languageManager()->getDefaultLanguage()->getId();

        $returnValues = array();
        foreach ($nodes as $index => $node) {

            if (!array_key_exists($language, $node->getTranslationLanguages())) {
                $translation = $node->getTranslation($defaultLang);
            } else {
                $translation = $node->getTranslation($language);
            }

            foreach ($entities as $entity) {
                $type = $entity->type;
                $entity_name = $entity->entity;
                if ($type == 'image') {
                    $returnValues[$postType][$index][$entity->entity] = file_create_url($translation->$entity_name->entity->getFileUri());
                } else if ($type == 'url') {
                    $returnValues[$postType][$index][$entity->entity . '_uri'] = $translation->$entity_name->uri;
                    $returnValues[$postType][$index][$entity->entity . '_title'] = $translation->$entity_name->title;
                } else if ($type == 'list') {
                    foreach ($translation->$entity_name as $list_item) {
                        $returnValues[$postType][$index][$entity->entity][] = $list_item->value;
                    }
                } else {
                    $returnValues[$postType][$index][$entity->entity] = $translation->$entity_name->$type;
                }
            }
            $returnValues[$postType][$index]['node_id'] = $index;
            $options = array('absolute' => TRUE);
            $url = Url::fromRoute('entity.node.canonical', ['node' => $index], $options)->toString();
            $returnValues[$postType][$index]['node_url'] = $url;
            $returnValues[$postType][$index]['lang'] = $language;
        }
        return $returnValues;
    }
}


How can I serve js and css from Drupal 7

You'll need a custom module for this (see the Module Developer's Guide if you're not already familiar with creating modules, it's pretty straightforward).

Once you've got your custom module set up you need to implement hook_menu() and define a callback function for your URL:

function MYMODULE_menu() {
  $items['globalmenu.html'] = array(
    'title' => 'Global Menu',
    'access callback' => TRUE, // If you want any source to be able to access this page
    'page callback' => 'MYMODULE_deliver_global_menu'
  );

  return $items;
}

function MYMODULE_deliver_global_menu() {
  print '<div class="nav">...';
  drupal_exit();
}

Since Drupal will only actually apply the theme wrappers to a page if something is returned from the page callback, simply printing your HTML and calling drupal_exit() is all you need to do.

Sorry if some of that is stuff you already know, I thought it best to err on the side of caution.


Against my better judgement, I've used Conditional Fields to control field display. I'll post back here if I have any issues.

To anyone who arrives at this answer from Google, I made at my decision after looking at the module's usage stats, which paints it almost at parity with the stable D6 version:

It's worth checking out http://drupal.org/node/1551504, which is intended to spur a D7 stable release (The author looks a bit overwhelmed by it all, truth to be told.). I've closed any similar questions and pointed them to that, which seems to have the most traffic.

That all said, it's kinda hard to contribute to a project when the maintainer is MIA...


Try the settings in /admin/structure/taxonomy/X/display (label settings)

but it should be done automatically if there is no content


Create a config file inside your_module/config/install/.

Inside SettingsForm.php write,

$form['#tree'] = TRUE;
$form['clients_enabled'] = array(
  '#title' => t('Enable PixelPin OpenID Connect'),
  '#type' => 'checkboxes',
  '#options' => array('pixelpin' => $this->t('Enable')),
  '#default_value' => $clients_enabled,
);

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->config('pixelpin_openid_connect.settings');
  $config->set('clients_enabled_key', $form_state->getValue('clients_enabled'))->save();

}

Inside LoginForm.php, get it :

public function buildForm(array $form, FormStateInterface $form_state) {
$definitions = $this->pluginManager->getDefinitions();
foreach ($definitions as $client_id => $client) {
  foreach ($this->pluginManager->getDefinitions() as $client_name => $client_plugin) {
$is_enabled = isset($this->config('pixelpin_openid_connect.settings')
      ->get('clients_enabled')) ? $this->config('pixelpin_openid_connect.settings')
      ->get('clients_enabled') : false;
    if ($is_enabled) {
      $url = \Drupal::service('path.current')->getPath();

      $find = 'login';

      $pos = strpos($url, $find);

      if ($pos === false){
            $value = 'Register Using @client_title';
        } else {
            $value = 'Log in with @client_title';
        }

      $element = 'clients_enabled[' . $client_plugin['id'] . ']';
      $form['pixelpin_openid_connect_client_' . $client_id . '_login'] = array(
        '#type' => 'submit',
        '#value' => t($value, array(
          '@client_title' => $client['label'],
        )),
        'visible' => array(
          ':input[name="' . $element . '"]' => array('checked' => TRUE),
        ),
        '#name' => $client_id,
        '#prefix' => '<div>',
        '#suffix' => '</div>',
      );
    }
  }
}
return $form;
}


How do I copy a "purchase limit" field from a product to a product line item

You'll need to add a "copy limit" field to the line item first. If you just want to use the standard "product" line item that will work. Add a "copy limit" field at admin/commerce/config/line-items/product/fields

Then you need a rule that says:

Event: "After adding a product to the cart"

Condition: Entity has field: Entity:commerce_product, Field: field_copy_limit
Condition: Entity has field: Entity: commerce_line_item, Field: field_copy_limit

Action: Set a data value. Data: commerce-line-item:field-copy-limit, Value: commerce-product:field-copy-limit

You may then want to add the copy limit to your cart view.

However, If you really want to just validate that the amount in the cart is less than or equal to the copy limit, you may want to do something like this:

Set up as above. The display settings on your product display node add to cart field must be set to "combine like products"
Add a rule like this:

Events:
* After adding a product to the cart
* After saving a new commerce line item
* After updating an existing commerce line item

Conditions:
* Entity has field: Parameter: Entity: [commerce-line-item], Field: commerce_product
* Entity has field: Parameter: Entity: [commerce-line-item..., Field: field_copy_limit
* Data comparison: Parameter: Data to compare: [commerce-line-item:quantity], Operator: is greater than, Data value: [commerce-line-item:commerce-product:field-copy-limit]

Actions:
*  Set a data value: Parameter: Data: [commerce-line-item:quantity], Value: [commerce-line-item:commerce-product:field-copy-limit]
* Show a message on the site: Parameter: Message: No more than [commerce-line-item:quantity] "[commerce-line-item:line-item-label]" may be ordered, so your order has been set to [commerce-line-item:quantity] items.

I put an export of this last rule at http://dl.dropbox.com/u/7350603/stackexchange/commerce_limit_items_in_cart.txt


How to create views of nodes and all revisions in?

Simple step by step instruction:

Try to create view by content revisions.
Remove relation to actual revision (added by default).
Also be sure that filter by published node isn't enabled.
It should work.


How can I remove only submitted time from node view?

Step 1->create a custom date format go to "admin/config/regional/date-time" then click "Add format" link,give appropriate name, in my case i have taken name "new custom", in format string input "l,F d, Y" then save.

Step 2->In your Your_theme.theme file write the preprocess function for node:

function Your_theme_preprocess_node(&$variables) {
// Getting the node creation time stamp from the node object.
  $date = $variables['node']->getCreatedTime();
// Here you can use drupal's format_date() function, or some custom PHP date formatting.
 $variables['date_custom'] = \Drupal::service('date.formatter')-
 >format($date, 'Machine_name_of_created_date_format'); //In my case machine name was "new_custom"
   }

Step 3->Create a twig template of your content type like node--your-content-machine-name.html.twig

replace the following line :
{% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}

with

{% trans %}Submitted by {{ author_name }} on {{ date_custom }}{% endtrans %}


How do I build a dynamic query in Drupal 7 equivalent to this SQL query?

$query = db_select('users', 'u');
$query->leftJoin('node', 'n', 'n.uid = u.uid');
$query
  ->fields('u', array('uid', 'name',))
  ->groupBy('u.uid')
  ->orderBy('total_written', 'DESC');

// Add the COUNT expression
$query->addExpression('COUNT(n.id)', 'total_written');
$results = $query->execute();


How to modify image field in field_attach_preprocess_alter

I've figured out the problem. I should have used field_view_value to render the field and add it to $variables['content'] instead of editing the field directly.

The below code works as expected now.

function custom_event_field_attach_preprocess_alter(&$variables, $context) {
    if($context['entity_type'] == "node" && $context['entity']->type == "event" && sizeof($context['entity']->field_grid_image) == 0){
        $tid = $context['entity']->field_event_type['und'][0]['tid'];
        $taxonomy_term = taxonomy_term_load($tid);

        $values = field_get_items('taxonomy_term', $taxonomy_term, 'field_generic_image');
        $node = $variables['node'];
        $output = field_view_value('node', $node, 'field_grid_image', $values[0], array(
            'type' => 'image',
            'settings' => array(
            'image_style' => 'gridimage',
            'image_link' => 'content',
            ),
        ));

        $variables['content']['group_image_text']['field_grid_image'] = $output;
    }
}


How exactly do I package latest dev snapshot of Commons locally?

I eventually got the answer straight from ezra-g at Acquia. From a unix-like console you can execute these commands (make sure you have drush and git installed locally):

cd ~
git clone --branch 7.x-3.x http://git.drupal.org/project/commons.git ./commons-profile
cd public_html
drush make ../commons-profile/build-commons-dev.make --prepare-install my_Drupal_Commons_site


Cannot print $variables using template_preprocess_views_view_rss() in readable format

My solution was to use kint() and print_r() with array_keys() to locate all the objects for manipulation.  In some cases I was debugging with the kint() display and in others just looking at plain text by using the other mentioned functions.

For note the template_views_view_rss() and template_views_view_row_rss() hooks are located in view.theme.inc (core) and no where in documentation on drupal.org for D8.  I believe they are soon to be deprecated.

// Specific feed filter
if( $variables['view']->id() == 'blog' && $variables['view']->current_display == 'feed_1') {
  // Iterate rows
  foreach($variables['rows'] as $key_1 => $row) {
    // Do stuff
    foreach($row['#row']->elements as $key_2 =>  $element) {
      // Do stuff
    }
  }
}


I need to switch from database logging to syslog

This article explains the whole process into details.

The very bottom line is activating the Syslog module (a core module), and configure it on admin/settings/logging/syslog. It should already work out-of-the-box.

To make sure you can find the log file, you can set it in /etc/syslog.conf and /etc/rsyslog.d/50-default.conf.


File structure of libraries folder and detection of module external plugins

The libraries folder is no longer managed by Drupal. The project Libraries doing this jobs in older Drupal versions seems to be deprecated in favor of a composer based concept. Modules still using the libraries folder use their own logic and you have to follow their instructions on the project page or README.


If I understood you correctly, you want to get a list of the form fields that a user is presented. The isn't really a clean way of doing that, since Drupal forms can be complex. The best solution however would be to generate the form and traverse it. To generate the form, you could do something like this:

$form_state = array();
$fields = array();
$profile = commerce_customer_profile_new('billing');
field_attach_form('commerce_customer_profile', $profile, $fields, $form_state);
// $fields is now the customer profile form.


User cannot edit one custom profile field other users can

Check the text format in use for the field that the user cannot edit.  Even if the user has permission to edit the field, the user will NOT be able to edit the field if the data is saved in a text format that the user does not have access to.

Make sure the user's field format is also filtered HTML.

If that doesn't work, use drush uli to log in as the user directly without changing his/her password and look at the problem with your own eyes-- sometimes users say something can't be done when they simply don't know how to do it.


views exposed filter to have dropdown of entity reference in cutstom entity

As Berdir said, as long as https://www.drupal.org/node/2429699 is not ready, you need to provide your own Views Filter plugin.

I created this plugin, based on TaxonomyIndexTid, for Nodes, see https://gist.github.com/StryKaizer/ae1cb9abc4844a9e7ac12317a9d84a78

You need to place this file in a custom module at yourmodule/src/Plugin/views/filter/NodeIndexNid.php, and also implement hook_views_data_alter in your yourmodule.module file, like this:

/**
 * Implements hook_field_views_data_alter().
 *
 * Views integration for entity reference fields which reference nodes.
 * Adds a term relationship to the default field data.
 *
 * @see views_field_default_views_data()
 */
function yourmodule_field_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) {
  if ($field_storage->getType() == 'entity_reference' && $field_storage->getSetting('target_type') == 'node') {
    foreach ($data as $table_name => $table_data) {
      foreach ($table_data as $field_name => $field_data) {
        if (isset($field_data['filter']) && $field_name != 'delta') {
          $data[$table_name][$field_name]['filter']['id'] = 'node_index_nid';
        }
      }
    }
  }
}


Add extra custom permissions to Field Permissions

With Drupal 8, the module implemented the permission type plugins. To add more permissions, you implement a new permission type plugin, using one of the existing plugin classes as example, such as Drupal\field_permissions\Plugin\FieldPermissionType\CustomAccess or Drupal\field_permissions\Plugin\FieldPermissionType\PrivateAccess.  Drupal\field_permissions\Plugin\FieldPermissionType\Base is used as base class, and simplifies the creation of new permission type plugins.
Note that the module invokes the hook_field_permission_type_plugin_alter() implementations, as described in the field_permissions.api.php file. That hook can just be used to remove a permission type plugin, or change the plugin properties given in its annotation (which doesn't include the permissions exposed from the plugin, for what I can see).


As pjskeptic mentioned, you can build a generic display mechanism using Views (or potentially Panels), but the primary way to establish one piece of content as a product display is to use a custom content type with a Product Reference field using the Add to Cart form display formatter. This has some distinct advantages:

Your product display node gets multiple view modes (i.e. teaser vs. full page vs. RSS) and can receive comments (i.e. user reviews and ratings if you set it up).
Product fields will be rendered and displayed in the node, including the product's Price field by default but also accommodating custom fields you add to products (i.e. an Image field).
A single product display node can reference multiple products through the Product Reference field, which turns the add to cart form into a product selection form and/or an Ubercart style attribute selection form. However, unlike Ubercart attributes, the product attribute selection form here accommodates dependent attributes, only shows valid attribute options based on the products you have referenced, and dynamically updates any product fields displayed on the node to show the currently selected product. This results in allowing unique images based on product or attribute selection, as seen in the mug product on the demo store.

There are some other advantages her, too, but it's worth noting that we understand this introduces complexity into the product display creation process. We made the decision early on to build what we thought was a sound architecture (separating the product definition from its point of display) and to simplify the store administration aspect through the use of installation profiles and contributed modules. To whit, you can use the Commerce Kickstart installation profile to create an installation of Drupal 7 + Drupal Commerce that includes a pre-configured Product display content type and adds an Image field to the basic product type. (Unfortunately, you'll have to know Git to grab this, as installation profile packaging is currently non-functional for Drupal 7 profiles.) Additionally, we're working on projects that allow you to bulk create products / product displays and to add / edit products directly in the node edit form using a custom Product Reference field widget.

To set this up manually, follow these steps:

Add a node type called Product display. Submit using the Save and add fields button.
Add a Product Reference field that uses an Autocomplete text field widget. Make the field required and allow an unlimited number of values (even if you only intend to use a single value for now).
Click over to the Manage display tab and ensure this field uses the Add to Cart form display formatter. You might also want to move around the product fields you see listed here.
Create a Product display referencing one of your products and examine the node's teaser and full page views. You may want to change the way product fields are displayed. To do this, you actually have to browse to your product type's Manage display page and update the display formatter settings there. You can only adjust the sort order and visibility of product fields through the content type edit pages, not the formatter settings.

There's more to it, but this should get you started. This process is actually the topic of an article I wrote for the first issue of Drupal Watchdog. I hope to be a regular contributor on the topic of Drupal Commerce, so I encourage you to get a subscription if you weren't at DrupalCon when the magazine was released. It may be the articles appear on the website eventually after printing.

For further support, I'd encourage you to browse the forum posts and documentation on this topic on DrupalCommerce.org and check out the #drupalcommerce IRC channel on irc.freenode.net. If you find any bugs or want to contribute to the usability discussion, we'd love to get your feedback as a site builder in pertinent issues in our issue tracker.

Oh, and if you're a visual learner, I walk through this process and explain how the architecture works in my session video from DrupalCon Chicago. It's the best video to date, though I'd love to see smaller screencasts targeting specific steps of Drupal Commerce site building get produced in the future.

Best of luck!


Custom Search Page Filtered by Content Type

You can use "custom search" module for filter search by a particular content type


Local drush stops working after changing files and folder permissions

Apparently, you have two Drush instances installed, as you can see in your error log, it tries to run the global Drush which is located at /usr/local/bin/drush-8/vendor/drush/drush first

the reason that you cannot run Drush commands locally after file permission changes is that it's not executable, try this in your installation root:

sudo chmod +x vendor/drush/drush/drush


How to submit form on selecting image in file select widget?

Of course it is possible. You need to take regular managed file and add some JavaScript to the file selection in it. To see how it is done, please see AutoUpload module:

  This module removes the extra button press and hides the "Upload" button via JavaScript for a quicker, automatic file upload. When JavaScript is not enabled, it falls back to the "Upload" button.

The most interesting is line 9, out of it's 22 lines of code:

$('.form-item input.form-file', context).change(function() {

And maybe simply using this module is all you really need?


What's needed to get Views data export working with a Block view?

I'm one of the maintainers of the module - I run the firm that built it https://www.computerminds.co.uk/articles/views-data-exports

I've just done a quick test locally and I can't seem to replicate the issue, I have a view with a single block display to which I add a data export.  I assign a path to the data export display and attach it to the block display - and it all seems to be working fine.

Could I ask which version of the Views Data Export module you are using?


How to translate a node in a custom block?

You need to pass the loaded nodes/countries through the following so that Drupal marks the best available translation as active, then do not use t() in the template. That is a security risk, you must never pass user input to t().

$country = \Drupal::service('entity.repository')->getTranslationFromContext($country).

Do that in a loop on $countries for example, or use array_walk()/array_map().


Depends on why you think you need fields. Fields in Drupal come with their own structure, they are exposed to Views, etc. Lets assume you manage to store a number of fields in a single serialized blob. How would sorting, filtering work?

Perhaps what you are looking for is more along the lines of a custom field widget, that exposes a large number of textfield forms, and stores the data captured in a serialized entry as opposed to 350 individual fields?


My solution was to point the document root of sub.addondomain.com to /public_html/addondomain.com/drupal.  I did this within cPanel, which - if I understand cPanel correctly - is going to directly edit the Apache VirtualHosts directives within Apache's config files for my site (something I wouldn't have access to directly with shared hosting).


Showing unpublished content to the anonymous creator

You can (relatively) safely store per-user data for anonymous users in $_SESSION. So if you intercept the node page view callback and add some extra code in there for the case in question (falling back to the core function), you should be able to achieve what you are after.

To elaborate: when you save the node in question, save its ID and an expiry timestamp in an array in the session, via a hook_node_insert. In the new callback check if that entry exists and has not expired. If present, fetch the node and display it. Otherwise call the regular node view callback.


Site shows themeless and blockless front page

I would check your watchdog logs (/admin/reports/dblog) after refreshing your homepage a few times.

This may give you some clues to what the problem is. For example...

I ran in to a similar issue with my D7 -> D8 migration, where my nodes were imported with a 'filtered_html' input_format. I was storing my node body content as markdown.

My front page had no blocks or theme. When I looked in my logs, I was seeing Missing text format: filtered_html.

I ran the following to update the input_format of my nodes, which fixed my problem.

UPDATE `node__body` SET `body_format`='full_html' WHERE `body_format`='filtered_html';

To then get things displaying properly, I installed the markdown module (and one of the required libraries, I opted for commonmark).

drush en markdown
composer require league/commonmark

I then went to /admin/config/content/formats/manage/full_html and enabled markdown for that content type.


Some code:

$option_delete = array(
        'attributes' => array(
            'onclick' => "return confirm('Delete order?');",
            'class' => "delete"
        )
    );

link:

l('delete', 'admin/orders/categories/'.$node->id.'/'.$page, $option_delete),

this link is showing up in list on administration overlay.


Display the total weight of the order in the basket

You need to add weight as a field to the product entity type first. Then you can see. Then you need to install this module, make a view and calculate the total.

Hope that helps.


Can't Rewrite the output of this field in views 7.x-3.3

SOLUTION Got it. Views 7-3.3 does not work with jQuqery 1.7+. It prevents the box from expanding after clicking the checkbox

Source: http://drupal.org/node/1494860


How to add embedded YouTube video at the end of ViewSlideshow - Drupal 6

One of our Drupal Developers has written an article on the subject of creating Slideshows in Drupal using embedded Youtube Videos. Take a look, maybe it may help you to sole your problem. http://wearepropeople.com/blog/how-to-create-slideshows-with-embedded-youtube-videos-in-drupal-7


How to redirect a user to the profile of the user they just created

Here is Form API solution for that:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function YOUR_MODULE_form_user_register_form_alter(&$form, &$form_state) {
  // Check if user has permission to add new user
  if (user_access('administer users')) {
    $form['#submit'][] = 'YOUR_MODULE_user_register_submit';
  }
}

/**
 * Submit callback
 */
function YOUR_MODULE_user_register_submit(&$form, &$form_state) {
  if (isset($form_state['values']['uid'])) {
    // Redirect to user page
    $form_state['redirect'] = url('user/' . $form_state['values']['uid']);
  }
}

And here is Rules solution:

Add event "After saving a new user account"
Add condition "User has role(s)" — site:current-user has role "Operator". I really don't know how to check permission in Rules, so it is not the best solution.
Add action "Page redirect" — user/[account:uid]


Using FBOauth, only allow existing users to associate a Facebook account

It turns out the FBOauth modules checks for the ability to create new accounts. Since we've limited our system only to User 1 and LDAP, no new FB accounts appear to be created. This leaves the user only to log in with an LDAP/AD account and then associate FB and their Drupal account. That is the exact behaviour for our use case!


How to fix the Feeds import error when trying to import a price field?

you should remove single quotes form decimal value and replace uncheck/check to false/true based on value.


how to change "username" text located in registration form

The way to modify the user registration form is to add a hook_form_alter() function to your theme to change the form variables and add a theme hook to use a custom use-register.tpl.php file. There are numerous tutorials and responses here on stackexchange (for example) that can guide you on this process, but if all you're trying to change is one string, you should try the string overrides module, which allows you to easily replace anything passed through the t() function (ex. "username" --> "organization").


Custom (cck) fields are being ignored during the migration using migration-tools 4.x. Only title and body is imported. How do I fix this?

What version of migrate_upgrade are you using? I see things like

      plugin: migration
      migration:
        - d6_filter_format
        - d7_filter_format

there, but --configure-only should have generated

      plugin: migration
      migration:
        - upgrade_d6_filter_format
        - upgrade_d7_filter_format


This issue is what you look for - currently it has a patch that needs work.
http://drupal.org/node/1450736


How can I extend drush aliases with specific variables?

The Drush rsync and drupal-directory (dd) commands already supports the functionality you desire, without the need for you to extend your alias files.  For example, to copy your files directory:

drush rsync @live:%files @dev:%files

To copy a specific folder from your temporary directory:

drush rsync @dev:%temp/foo @live:%temp

To change your working directory to the location where the devel modulr is installed:

cd $(drush dd @dev:%devel)


Can You Use HOOK_node_builder() to Set Custom Node ID?

There is no HOOK_node_builder, here are the available hooks in the Entity API.

I think hook_ENTITY_TYPE_presave is the one you are looking for.

function MYMODULE_node_presave(\Drupal\node\NodeInterface $node) {
  $node->nid->value = 5;
  $node->enforceIsNew(TRUE);
}

Here is the order of hooks and other events that happen during an entity save:

preSave() is called on the entity object, and field objects.
hook_ENTITY_TYPE_presave()
hook_entity_presave()
Entity is saved to storage.
For updates on content entities, if there is a translation added that was not previously present:

hook_ENTITY_TYPE_translation_insert()
hook_entity_translation_insert()

For updates on content entities, if there was a translation removed:

hook_ENTITY_TYPE_translation_delete()
hook_entity_translation_delete()

postSave() is called on the entity object.
hook_ENTITY_TYPE_insert() (new) or hook_ENTITY_TYPE_update() (update)
hook_entity_insert() (new) or hook_entity_update() (update)


How to share session variables across Drupal sites?

There are two options to do this

Using session

Use a single session table for both the site using settings.php set up

Using Cookie

Use same cookie domain for both site and set cookie available in all pages.


Module that allows visitors to suggest modifications on a node

Apart from the notifications, Workbench along with Workbench Moderation seems to meet most requirements.

Drupal only has two states for nodes: unpublished and published. With Workbench Moderation, you can define your own custom states, e.g. pending, accepted, not accepted, spam.
You can then authorize anonymous users to edit nodes (make suggestions). These edits will create new revisions which will NOT be published until authorized users actually publish the changes.

Workbench Moderation also works well with Diff which allows you to compare different revisions to see the actual changes per field.

Finally, following nodes and notifications can be realized with the Flag and the Rules module.


Centered layout with div borders on left and right (with bg images)

The main problem in your example is that your "border" <div>'s have position: fixed; so they refer to the viewport rather than to the parent <div id="page">.

It's why you observe the right ones behaviour, which is pretty normal.
The left ones seem to refer to #page, only because they have not any left or right property set, so it defaults to auto.

Hence here is the first point: you must set position: absolute; for these "borders".

Additionaly you must remember that, for the absolute positioned element to refer to its nearest parent, this one must not have position: static, or another parent will be looked for as reference... till <body> if none is found, so it will be the same as for a fixed positioned element.

So here is the second point: you must set position: relative; for the parent #page.

From there you have to manage with leftand right properties to get what you want.
You can look at this fiddle, where I added the needed properties to strictly conform to your DIAGRAM exposed wills.


I'm not 100% sure of what your goal is, but I just accomplished something similar and in case it helps you here is what I was looking to do and what I did.

I am uploading all images to the /sites/default/files/images directory and I wanted them to become available via http://images.example.com/filename.jpg and display on the node via ths subdomain.

To do this I setup a virtual host in /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
  ServerName images.example.com
  DocumentRoot /var/www/html/example.com/sites/default/files/images
</VirtualHost>

You can then alter your subtheme node.tpl.php to reference the attached images via this subdomain.

<?php $img = 'http://images.example.com/' . $field_image['und'][0]['filename']; ?>
<img src="<?php print $img; ?>" />

I wanted the convenience of having the variables already present in the node so I used the template_preprocess_node(...) function in template.php.

function MYTHEME_preprocess_node(&$vars) {
  $node = &$vars['node'];
  if ($node->type == 'image') {
    $base_url = 'http://image.example.com';
    $vars['image_base_url'] = $base_url;
    foreach ($node->field_image['und'] as &$image) {
      $image['url'] = $base_url . '/' . $image['filename'];
    }
  }
}

With this I can access inside the node both $image_base_url as well as $field_image['und'][0]['url']

$image_base_url is http://image.example.com
$field_image['und'][0]['url'] is http://image.example.com/filename.jpg


Update core keeping other composer packages

If you have a composer based project, you probably should use composer to update it.  E.g.:

composer update drupal/core --with-dependencies

Make sure to keep the composer.json, composer.lock, and docroot/vendor/composer/installed.json files in your repository.

Note:  It's best to go 'all-in' with composer and use it to add and maintain modules as well as core. E.g.:

Add new module:   composer require drupal/module

Update module:  composer update drupal/module --with-dependencies

To manage patches, see the cweagans/composer-patches project.

You can also include various 3rd party libraries (e.g. chosen, colorbox, and the like) using your composer.json file.


Field Formatter: how to know where "i'm"

A Field Formatter has no awareness of when it's used. It's simply just a unique way to display a field.

You want to use something like Entityreference ViewMode Selector. And create 2 formatters for the Field Collection. 1 formatter is the default output for collections, 1 formatter is the viewed as entityreference formatter.

When you set the entityreference, you would set the formatter as needed.


Why didn't we got rid of primary entity keys in favour of UUIDs?

For context and some related discussions, see #1726734 Replace serial entity IDs with UUIDs in URLs, or even globally?. There is also a related issue about using UUID's for references, which I can't find right now.

So one argument is that all URL's would then become very long, there's no user/1 anymore but user/LONG-UUID.

Another is the database performance, the primary key is the main index of every table, and making that bigger makes every change to that table more expensive. Yes, so does having 4 tables, but there's still the hope that to make that optional for non-multilingual sites. I doubt it will be possible, but we will see.

And you have to keep in mind that the storage would not only be increased by the actual field, but also every reference, so every single field table entry would then have to store the full UUID instead of the considerable shorter primary key.

And related to the issue that I can't find right now is that it would also slow down joins that involve entity tables.

That doesn't mean that it will never happen, but it has been pushed back to 9.x to be re-evaluated there.


repeated results with Views Slideshow results and commerce products

First thing to do is to make sure that the relationship is set to be required, if the duplicate results still coming on .. go to views query settings and check both DISTINCT and PURE DISTINCT


What is the quickest way to dump a node to insert into a test case?

You can use drush:
drush ev "var_export(\Drupal\node\Entity\Node::load(123)->toArray());"

and delete stuff you don't need like uuid, revision_*, ...
By the way if you are wondering why does this output old style array syntax, see https://stackoverflow.com/questions/24316347/how-to-format-var-export-to-php5-4-array-syntax
... or paste the output into your IDE and configure it to autocorrect the format.


Upload an image in a form programmatically

I would strongly suggest to use nodes and one of these modules
Comparison of image cropping and resizing modules

If you dont want nodes then you still should be able to use one of crop modules which works with image fields if you use entities, you can use Entity Construction Kit (ECK) module  to create custom entity types


Boost column allows you to "boost" search results based on certain criteria. You can boost an entity which will make it have higher relevance. The way results are displayed will be by ranking and setting Boost value will add additional ranking to the field.

Currently you can only Boost Full Text fields.


how can i specify certain block for specific content type to get in there?

It sounds like you're looking for the Views module; it's essentially a query builder with a simple-to-use UI.

You can make a View that lists all the content of type 'product', displayed in a choice of different formats (HTML list, table, unformatted list of content, etc.). You can create different display modes for the View, including a block which you can assign to a region in the blocks admin page as normal.

The best part is, though, that you also get the benefit of being able to easily choose the sort order of the list, set filters on certain criteria, add AJAX pagers automatically, and a lot more.

Check out Working with Views to get started; you'll be glad you did!


Profile Completion e-mail to user in Drupal

Use Rules, I actually have the below working for an Intranet site I manage.

ON - Choose your event, maybe "User has logged in"
IF - "Content Profile's field 'field_NAME' has value"
DO - "Send a mail to the user"

Replace the field_NAME with the field you would like to check, In the IF I just check for a NULL value on a required field.

return array( 0 => array('value' => ''), );


I think there is a module for that --> https://www.drupal.org/project/html_title

An other way is probably to use the Body field (or any other) instead of the title and leave the title field as is. You could for example use the Display Suite module for this or alter your content type displays where you need it.


Here are two ways to set up a relationship, depending upon how it is to be applied to content.

It is not clear how you are suing the PID field, so I will ignore it.  You could create a field with a name like 'relate' and you could enter a term there that identifies a name for a relationship that various content types would share.  You would then set up a View to filter for that field with the specific term you want and Views will retrieve all the content that shares that term.  Further filtering could narrow the selection further if you desire.
You could use a module such as Relation to define a type of relationship and link pairs of content eg. a 'friends' relationship could be used to link two users in a specific type of relationship.


what is the URL I should use to edit a user account?

To update a user with Drupal Services, you make a PUT call to:

?q=[my-endpoint]/user/1.json

Replacing [my-endpoint] with the machine name of your Service endpoint. Here's some example JSON to PUT:

{
  "uid":"1",
  "name":"bob",
  "mail":"bob@hotmail.com",
  "current_pass":"secret",
  "pass_pass1":"new-secret",
  "pass_pass2":"new-secret"
}

You must also attach a header to your call with a name of X-CSRF-Token using a value that can be retrieved here: ?q=services/session/token


Go to config >> content >> formats >> filtered_html

In bottom have Filter setting choose Limit allowed HTML tags add in it allowed HTML tags


Integrating Drupal and Non-Drupal Site Content

Hard to say from your post if there is any real content management involved here, but if so - if Drupal is a requirement and your expertise is in JS - maybe look at a decoupled approach?

... in Headless Drupal, the visitor will see pages created with Javascript frameworks such as Angular.js or Backbone.js. They will not see a traditional Drupal theme. That's where the "Headless" name comes from: Drupal's head / theme is missing.
In this situation, Drupal is mainly used as store for data that is then read by the framework. The normal Drupal interface is still used by users to enter the content that will appear on the website.

Source: What is Headless Drupal? (OSTraining)


Registration message after saving password for first time

You can use "String Overrides" module to achieve this. As this message sets using drupal_set_message function and this function stores these messages in session. So the best way to change this message is use of string overrides module. This module can easily replace anything that's passed through t() function. So you just need to put whole string that you want to replace with your own string.


How do I implement the login, register and "Forgotten password" forms?

Here is what I ended up doing in my controllers :

# Login form
public function content() {
  $formBuilder = $this->formBuilder();
  $form = $formBuilder->getForm("Drupal\user\Form\UserLoginForm");
  return [
  '#theme' => 'weber_login_form',
  '#login_form' => $form,
  ];
}

# Forgotten password form
public function content() {
  $formBuilder = $this->formBuilder();
  $form = $formBuilder->getForm("Drupal\user\Form\UserPasswordForm");
  return [
    '#theme' => 'weber_password_form',
    '#password_form' => $form,
  ];
}

# Register form
public function content() {
  $entity = \Drupal::entityManager()
  ->getStorage('user')
  ->create(array());

  $formObject = \Drupal::entityManager()
  ->getFormObject('user', 'register')
  ->setEntity($entity);

  $form = \Drupal::formBuilder()->getForm($formObject);
  return [
    '#theme' => 'weber_register_form',
    '#register_form' => $form,
    '#link' => NULL,
  ];
}


I want to add a field in drupal commerce products by default like commerce_price?

The hook you're trying to use is unrelated to Field API fields, unfortunately. You should look at the commerce_product.module and commerce_product_ui.module files to see how I did it in core for the default price field. Either on module enable or when a new product type is created via the UI, I call the commerce_product_type_configure() function that in turn adds the default price field to the product type. You'll want a similar function that you can invoke when a module is enabled or on hook_commerce_product_type_insert() to add your custom fields.


How do I display my custom menu in administrative menu?

Thats Easy. You need to goto structure >> menus >> Management. From there you can click on add link and add the menu link in that , it will automatically get added to the administrative menu toolbar.

Making that to be visible for specific roles , you need to give permission for overlay in that you need to enable this permission for that role Access the administrative overlay.

That will make your menu appear as administrative menu for what ever role you specified in permission tab of admin.


How to export cck field list from Drupal 6 to CSV files for import in Drupal 7?

I gave up on this approach and ended up using the features module because I could not find a complete or workable solution using csv export/import.


Drupal PHP views - how to reference nested braket array variables?

You're almost there, since the square brackets are part of the string they need to go inside the quotes, e.g.

$var['[path]']


Cannot insert images in body of a basic page

I found a solution. Suggested by Tech-Tonic:

https://www.drupal.org/forum/support/post-installation/2018-08-24/ckeditor-image-button-cannot-insert-images-in-body-of-a#comment-12854570

  Does your content type have other file fields on it?
  If so, try temporarily disabling all file/image fields for the content type in "Manage form display" and save. Then enable them again and save. Worked for me, in Drupal 8.6.3.

As mentioned above, I also had an image/file field in the content type. Under 'Manage form display', I disabled the image field and saved. I then went back to 'Manage form display', moved it back to where it originally was and saved again.

After this the error no longer appears. This worked on the production, staging and development copies of the same site.


Order of search results for exact match content

Database search doesn't support phrases searches as stated here by the maintainer of the module (cf. https://www.drupal.org/node/2043339#comment-7654017) :

  Are you using the Database Search backend? In this case it's clear, because that backend currently doesn't support phrase searches due to technical restrictions.
  However, results should always contain both words, though not necessarily next to each other.

In order to sort your results, see this related question/answer I have no fields available for sorting with Search API sorts module


How to display a field before the title when the title was printed before the node template?

page.tpl.php has a $node variable on all node/%nid pages. So you have two options:

You can use it directly in page.tpl.php (with the help of the field_get_items() and field_view_field() functions).
You can do your messing around with $variables['node'] in a THEME_preprocess_page() function in your theme's template.php, then add your complete data to $variables[] to print the final value in page.tpl.php.

This may also help: Setting up variables in preprocess functions


How to create a custom content-type with template for an "empty" page

By code, if you want a page that display's only content, here's how I would do it.

function module_menu() {
$items['overlay/location']=array(
 'title' => 'Title of page',
 'page callback' => 'module_callback',
 );

return $items;
}

function module_callback() {
 echo 'show what ever!';
 //no return!
}

Take a look at hook_menu()


How to migrate a physical files into Drupal 7

If the site to be migrated has low double digit numbers of pages or has widely varying HTML and document structure among the pages the easiest solution is copy and pasting it by hand. This may be an opportunity to reorganize the site, add taxonomy terms and clear up other minor content issues.

For larger sites there are several options:

The Migrate module provides a framework and API for you to automate content migration. Using it will involve some coding and require a degree of familiarity with Drupal.

The Feeds module is generally used for importing data like RSS feeds but can be used to import site data. For example, it will import a CSV file, converting lines to Drupal nodes. I envision a solution copying pages into a structured spreadsheet with fields for Title, Author, Body, etc. and exporting that to a CSV for import via the Feeds module.

For completeness I'll mention the Import HTML module which only has Drupal 5 and 6 versions available. If you found this module suitable to import your content you could import into a barebones Drupal 6 installation and perform a site upgrade to Drupal 7.


How do I correctly cache a themed menu output?

Okay, so this combination worked...

$variables['#cache']['tags'] = ['node:' . $node->id()];
$variables['#cache']['contexts'] = ['route', 'theme'];
$variables['#cache']['keys'] = ['entity_view', 'node', $node->id()];

I dont see a huge difference to my first attempt but whatever!


How to link views content nodes to custom URL

I don't know if you can get the node link in a custom URL, but you can overwrite the output of the nid field.

Steps:

1. Add NID field

2. Hide field (this might change depending in your setup)

3. Go to the overwrite section and overwrite the NID output

4. The rest is up to you. You can display a field as a link and add the NID field as a replacemente pattern or use it as is.


How to disable "Plain text" for a specific role?

Better Formats module will allow you to select the default input format per role, and disable the formats selection part of the node edit form http://drupal.org/project/better_formats


setting up drush AFTER drupal multisite installed

Drush does not need configuration, as long as you run commands from the relevant site folder such as www-root/drupal-core/sites/mysite it will work.

Do check that your version of drush is compatible with Drupal 8 though.


First you need to login:

$loginData = ['username' => 'yourusername', 'password' => 'yourpassword'];

$ch = curl_init("http://pathtodrupal.com/endpoint/user/login.json");

curl_setopt_array($ch, [
  CURL_OPT              => TRUE,
  CURLOPTRETURNTRANSFER => TRUE,
  CURLOPT_HTTPHEADER    => ['Content-Type: application/json'],
  CURLOPT_POSTFIELDS    => json_encode($loginData),
]);

$response = curl_exec($ch);

$responseData = json_decode($response, TRUE);

Once you send a POST request to login you get the following response back:

  {u'session_name': u'SESScxx45656f30', u'sessid':
  u'mOE9NdG6Bk3EADSvKJHGGy8jgkQ', u'token':
  u'-HVkXhARIynpmJxow5NUIYTRXSc', u'user': {u'status': u'1', u'picture':
  u'0', u'uuid': u'514c987e7-15f0-43cc-9c6f-53279c216f30', u'uid': u'1',
  u'language': u'', u'created': u'1310006971', u'init':
  u'morinfo@dbasepu.com', u'timezone': u'America/New_York', u'access':
  u'1429109927', u'theme': u'', u'roles': {u'2': u'authenticated user'},
  u'signature': u'', u'signature_format': u'1', u'mail':
  u'mor@morinfo.com', u'login': 1429111638, u'data': {u'ckeditor_width':
  u'100%', u'form_build_id': u'form-60703ffc3';lk6c0fe03cebe9',
  u'ckeditor_lang': u'en', u'ckeditor_show_toggle': u't',
  u'last_category_id': 1, u'ckeditor_auto_lang': u't',
  u'ckeditor_default': u't', u'site_access': {u'1': u'1'},
  u'last_site_id': 1}, u'name': u'bewmrn'}}

In your subsequent requests you want set the the set in the header the X-CSRF-Token to $response['token'] and Cookie to $response['session_name'].=.$response['sessid']. This should work.


The closest out-of-the-box option is to use a combination of the public (public://) and private (private://) file system.  Public files can be access by anyone with a url to the file. They're served directly from the server without really having to deal with drupal.  Private files on the other hand require the user to log in.

The downside to the private file system is the files are basically streamed to the end user via php which is slower. There are ways around this but if you're not expecting heavy download traffic then I wouldn't worry about it just yet.

The way access control is handled is via the node.  You can create a single filefield and attach it to a any content type.  Let's just say we're using the 'article' content type for now with a single filefield that supports both public and private storage.  When you add a file to the article you can choose the private file system.  You can then use any of the node access control modules (tac_lite, og, etc.) to control who can see the node.  Those that can see the node can then download the file.


What is the best way to delete or disable ( most expected) the field of a content type?

Here's what I usually do.

Find contents that have data for those fields you want to delete.(You can easily find it in DB)
Delete all contents found in step 1 or remove data from those contents.
Remove the field from content type.


In Drupal 7 how do you output array objects to be view able in watchdog error reports?

You can use watchdog but the message part should be translatable, so any variables should use placeholders defined in the variables array. Check out format_string to see how these should work.

watchdog(
  'my_module_name',
  'Here is the printed variable: <pre>@placeholder_name</pre>',
  array('@placeholder_name' => print_r( $my_variable, TRUE)),
  WATCHDOG_INFO
);

Also, convention dictates that the first parameter, $type, should be the module name calling watchdog.


hook_form_FORM_ID_alter is used to alter the form before it is rendered, if you want to alter the form after being submitted and before being save, you have to use hook_node_presave.
Put this code in a custom.module:

function custom_node_presave($node) {
  if ($node->uid == 0) {
    // Change anonymous node author to uid: 2
    $node->uid = 2;
  }
}


How to create a list of webform submissions for a particular webform

To view the submissions for a particular form you can just click the Results tab on the webform node, and you will have a list of submissions for that form, or go to node/1/webform-results where 1 is the node id.

You can also go to Administration > Content > Webforms (admin/content/webform) and click the Submissions link for the form you want to see the submissions for.

This is for Drupal 7 and Webform 3, but I believe it's more or less the same for the other versions.


My page is in hook_admin_paths(), but doesn't show admin theme

I would suggest you place your admin pages under admin/dvr. In that way you should not need to implement hook_admin_paths() at all.