Show a discount field in the Product display page

I found the answer,with the use of this module https://www.drupal.org/project/commerce_saleprice


How to enable both passwords at registration AND email confirmation together?

All you need to use is the user registration password module

Let users register with a password on the registration form when
verification mail is required.
By default, users can create accounts directly on the registration
form, set their password and be immediately logged in, or they can
create their account, wait for a verification e-mail, and then create
their password. With this module, users are able to create their
account along with their password and simply activate their account
when receiving the verification email.


The Forum Access module works in Drupal 7, so I'll stick to this for now.

  This module changes your forum administration page to allow you to set forums private. You can control what user roles can view, edit, delete, and post to each forum. You can also give each forum a list of users who have administrative access on that forum (AKA moderators).

  This module requires the ACL module in order to function. The D7 version also requires the Chain Menu Access API module.


Equivelant of node_type_load() for entity bundles

You can use entity_get_property_info() for example

var_dump(entity_get_property_info('node'));

Bundles are a keyed array within the result and they contain a keyed array of the fields and their settings.

Other information about the bundles other than field properties, such as menu callback etc, can be obtained using entity_get_info() where the bundles as keyed array within the result contains other non-field info.


What's this strange error during entity_creation?

Argh, it seems the two different entity modules (core & contrib) have confused me once again.

The EntityAPIController I chose as controller class has no method save(). It uses entity_save($entity_type, $entity); instead.

So the function had to be:

function my_entity_provision() {
  $a = entity_create('entityType', array(
    'pid' => NULL,
    'aid' => 1,
    ...

  ));
  entity_save('entityType', $a);
}


In this case, it looks like you need to do

drush rf    # pm-refresh

before you do

drush up drupal

This will refresh the list of available updates so Drush knows there is a new release for Drupal.


Finding a node with a time closest to the current time without being past

Absolutely!

Add a filter to your view, that is based on your date field and choose the operator as 'Is greater than or equal to'.

You have as an option to enter a relative date for the comparison and then enter in any variety of relative times and dates.  For your purpose just choose 'now' as the comparison.

That will pull up all nodes with a date field that is greater than or equal to now: i.e. all the future ones!

============= EDIT ===============

If you don't need all of the future ones, just limit the results to 1 and order by the date.  That will give you just the next one coming up.

Let us know if that works for you!


Solved running SQL query in phpMyAdmin

UPDATE field_data_body  SET body_value = REPLACE(body_value,'src="/olddirectory','src="/newdirectory');

Source article: http://www.coolestguidesontheplanet.com/downtown/changing-image-paths-drupal-subdirectory-installation


How to validate field in inline entity form referenced field

Inline entity form only makes the connection to some structure and displays it, it doesn't change it. In your case the Inline entity form is showing the Create node form of a certain type (you haven't mentioned which type is in your case), but you can't change the structure through the Inline entity form.

If you want to add a User reference field to that node type you have to go through Structure > Content types > [Your type] > Manage fields.

There you can add a new field (or use an existing one if it makes sense to your structure) of the type Reference > User.

Once you add that field when you go to created nodes that reference that node type through the Inline entity form, you will see the User reference field among the fields after clicking on "Add new node".


Does Drupal have a collaborative editing module?

The answer from knowledges33ker is a good start.

However the workbench module - https://drupal.org/project/workbench
 - might also help with this and add further functionality.

Particularly in that it offers good tracking of edits that have been made to content and you can revert content to previous revisions etc.

With the user reference field set up, you could also, if you wanted, use the Rules module - https://drupal.org/project/rules - to fire emails or notifications to users when the content is edited/updated.


How to use articles attached images as background of a div

Contrib module

What you are describing can be done easily with a contrib module. You could try background_image, bg_image_formatter, bg_img_field perhaps there are others.

Use image in node.html.twig or variant

If you MUST DO IT WITH CUSTOM CODE and you want my_image in node.html.twig or node--article.html.twig you need to prepare it in hook_preprocess_node

function THEMENAME_preprocess_node(&$variables) {
    $node = $variables["node"];
    if ($node->hasField('field_image')) {
      $variables["my_image"] = file_create_url($node->field_image->entity->getFileUri());
      // can set more variables
    }
}

Use image in page.html.twig

If you want to include it in a div inside your page.html.twig you should use hook_preprocess_page and note that $node has to be extracted from the ROUTE

function THEMENAME_preprocess_page(&$variables) {
  // get the current node
  $node = \Drupal::routeMatch()->getParameter('node');
  if ($node instanceof \Drupal\node\NodeInterface) {
    if ($node->bundle() == "article" && $node->hasField('field_image')) {
      $variables["my_image"] = file_create_url($node->field_image->entity->getFileUri());
      // can set more variables
    }
  }
}

Use image in field.html.twig or variant

I can't see the use case but if you want to use it in field.html.twig or a variant such as field--node--field-image--article.html.twig you can access it directly

{% set my_image = file_url(element['#object'].field_image.0.entity.uri.value) %}

or can set my_image using a hook_preprocess_field

function THEMENAME_preprocess_field(&$variables) {
  if($variables["element"]["#field_name"] == "field_image"){
    // get parent node
    $node = $variables['element']['#object'];
    if ($node->bundle() == "article" && $node->hasField('field_image')) {
      $variables["my_image"] = file_create_url($node->field_image->entity->getFileUri());
    }
}


Error with drush clear-cache: Base table or view not found

Here is how to reset your cache_rules table, using a stable Drupal installation.

Get cache_rules structure from clean database

You can get SQL text to drop/add the cache_rules table via the following steps:

Log in to phpMyAdmin on a functional Drupal site.
Click on the columns section under the cache_rules table
Click the Export button
Click 'Custom' to show all options
Under 'Output' click 'view output as text'
Under 'Format-specific options' choose 'structure'
Under 'Object creation options' check 'Add DROP TABLE / TRIGGER statement'
Copy the text displayed, or see below (sorry for the formatting)

Here is the SQL code to drop and add the table (thanks duckx!).

DROP TABLE cache_rules ;
CREATE TABLE IF NOT EXISTS `cache_rules` (
  `cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
  `data` longblob COMMENT 'A collection of data to cache.',
  `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
  `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
  `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
  PRIMARY KEY (`cid`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cache table for the rules engine to store configured items.';

Drop/add the cache_rules table

Now navigate to the other database, using phpMyAdmin.

Make a full backup of the database
After the backup has been saved, click the SQL tab
Paste the text into the text box (removing any existing text)
Click 'Go'


How should I validate field values against an external service?

As you want the field value to be validated, I would use a constraint, This ensures that the value is validated regardless of how the field value is saved - whether through a Form, an API (REST/JSON etc) or programatically.

As you didn't create the entities and fields yourself (I'm assuming you mean they're provided by a module or core, and not just that a former developer created them), you'll have to attach your constraint in hook_entity_bundle_field_info_alter() as explained in this post: How do I add a custom validation handler to an existing form/field?

Note however that this will mean anytime your entity has saved, and this field value has changed, your remote API will be called. If this is going to happen regularly, you may want to create some kind of caching system that caches the responses from the remote API.


You can use Views for looping throug nodes. Just build Views that show list of certain nodes, then call it into your template file, like this: print views_embed_view('VIEWNAME', 'DISPLAY_ID');
But creating for each page one node template file is not good way for this (you will got many count of this page-node-XXX.tpl.php files, for serving all of these you will take more time, even you want to change something little), node-TYPE.tpl.php will better with more common page.tpl.php.

p.s. Also customizing page via Panels without template have better UI.


Avoiding content-type overkill: 5 slightly different pages = 5 different content types?

Answer is it depends.

How often is the content in these nodes being updated? Does the content in the different fields need to be used in tokens, views, etc?

If it's never updated OR if you can use wysiwyg to edit the body to position things where they need to go and make it easily editable then use one node type.

If the info needs to be put into fields so views/tokens can pull bits out of the nodes then creating fields for those values is important.


Select fields in multiple tables / change output value / compare fields

I suspect this is what you are looking for

db_query("SELECT * FROM node LEFT JOIN url_alias ON url_alias.alias=concat('node/',node.nid)");


How to load and render a webform with Ajax

You might want to look into the Ajax links API.
Sadly, there is an issue with the Webform module and BigPipe that needs to be fixed.


Organic Groups let users with a particular role Edit/Delete content only in the group(s) they belong to

Mark a content type as og group and the rest as og group audience


I think what you are looking for is https://www.drupal.org/project/global_filter. There is a good README on how to use it: http://drupalcode.org/project/global_filter.git/blob_plain/refs/heads/7.x-1.x:/README.txt


At user creation set different default timezone

Try visiting admin/config/regional/settings to set default timezones.

I've also created a module called Timezone Detect that will detect and set user timezones automatically using javascript.


Feeds Importer Xpath import where guid is at the top of the context

I just did a quick test of this, with your sample data, and it works correctly.

In the debug options you can enable error reporting, as well as, show the outputs of various queries.


To change the structure of the Serializer output you should create a custom Serializer here is the steps of your use case:

Create CustomSerializer extends the Drupal\rest\Plugin\views\style\Serializer and update the render method to your needs.

Create MY_MODULE/Plugin/views/style/CustomSerializer.php

namespace Drupal\MY_MODULE\Plugin\views\style;

use Drupal\rest\Plugin\views\style\Serializer;

/**
 * The style plugin for serialized output formats.
 *
 * @ingroup views_style_plugins
 *
 * @ViewsStyle(
 *   id = "custom_serializer",
 *   title = @Translation("Custom serializer"),
 *   help = @Translation("Serializes views row data using the Serializer
 *   component."), display_types = {"data"}
 * )
 */
class CustomSerializer extends Serializer {

  /**
   * {@inheritdoc}
   */
  public function render() {
    $rows = [];
    // If the Data Entity row plugin is used, this will be an array of entities
    // which will pass through Serializer to one of the registered Normalizers,
    // which will transform it to arrays/scalars. If the Data field row plugin
    // is used, $rows will not contain objects and will pass directly to the
    // Encoder.
    foreach ($this->view->result as $row_index => $row) {
      $this->view->row_index = $row_index;
      $row_render = $this->view->rowPlugin->render($row);
      $iot_integer = 0;
      if (isset($row_render["field_iot_integer"]) && $row_render["field_iot_integer"] instanceof \Drupal\Core\Render\Markup){
        $iot_integer = (int) $row_render["field_iot_integer"]->__toString();
      }
     $rows[] = [
        $row_render["created"]->__toString(),
       $iot_integer
      ];
    }
    unset($this->view->row_index);

    // Get the content type configured in the display or fallback to the
    // default.
    if ((empty($this->view->live_preview))) {
      $content_type = $this->displayHandler->getContentType();
    }
    else {
      $content_type = !empty($this->options['formats']) ? reset($this->options['formats']) : 'json';
    }
    return $this->serializer->serialize($rows, $content_type, ['views_style_plugin' => $this]);
  }
}

Clear Cache:
Go to your view and change the format from Serializer to Custom serializer like

The result:


Controlling/selling node access by node reference?

Why not go custom access the main thing is relating your "Class" or Item to the product the person buys aka on the product you could create a entity reference to the node or class or whatever  ...

you can do some thing like the following

use Drupal\Core\Access\AccessResult;
/**
* Implements hook_node_access().
*/
function mymodule_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account){
// Note thes checks do not work on admin (user 1). and clear cache each time.
$type = $node->bundle();
if ($type === 'your_content_type') {
  if ($account->id() !== 0) {
    $user = $account->getAccount();
    $uid = $user->id();
    // Ok we know is trying to access and the node type.
    $storage = \Drupal::entityTypeManager()->getStorage('commerce_order');
    $orders = $storage->loadByProperties(['uid' => $uid]);
    if (count($orders) != 0) {
      $has_bought = FALSE;

      // CUSTOM FIND Your Corse .
      $corse_type = $node->field_corse_type->value;
      foreach ($orders as $order) {
        $order_items = $order->order_items->referencedEntities();
        foreach ($order_items as $item) {
          // Do better than this lol ...
          // dump($item);
          if ($item->title->value == 'SOME Course' && $corse_type == 'SOMETHING RELATED TO PRODUCT') {
            $has_bought = TRUE;
        }
      }
    }
    // final check.
    if ($has_bought === TRUE) {
      return AccessResult::isAllowed();
    }
    else{
      // Kick them. as not bought.
      return AccessResult::forbidden();
    }
  }
  else {
    // Kick them. as not paid.
    return AccessResult::forbidden();
  }

  }
  else {
  // kick them.
  return AccessResult::forbidden();
  }
 }
 else {
  return AccessResult::neutral();
  }
}


Views support for custom entity with base table in seperate database

Further research has led to the conclusion that this is a current limitation in views. Special characters are not escaped correctly in table names, specifically the "." separator notation in dbname.tablename. It could be framed as a bug depending on what sources views officially supports in core. I've opened an issue with more details:

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


Search module is not working with all content types

Default behavior of search module is, it search all the content type contents. If you tried to search with content type name then it is not working, because it is not the search module functionality.


For some reason that table was never created in the database (this site started on an early version of 7, so perhap the Panels module didn't use a cache table back then???).  You can fix this by creating one that's identical to all the other cache_* tables:

CREATE TABLE `newco`.`cache_panels` (
  `cid` varchar(255) NOT NULL default '' COMMENT 'Primary Key: Unique cache ID.',
  `data` longblob COMMENT 'A collection of data to cache.',
  `expire` int(11) NOT NULL default '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
  `created` int(11) NOT NULL default '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
  `serialized` smallint(6) NOT NULL default '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
  PRIMARY KEY  (`cid`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT 'Panels cache, manually created because Panels module would not upgrade without it'

Then you should be able to successfully upgrade the panels module:

$ drush up panels


How do I query entities to get all fields values - including referenced ones (INNER JOIN)

No, there is not.

Entity query only returns IDs, you need to load those and then from there access the referenced entities.


Instead of print_r try:

<?php print var_dump($node);?>

Look at your source, find the video field you've setup, then copy and paste the complete path the the CCK variable you've setup. The problem is your outputting the entire body field where as it sounds like you just need two fields "$node->title" and "$node->MyVideoField" but without knowing the complete variable path I can't really help.


show specific number of posts on front page for mobile d7

I ended up just redirecting the mobile devices to mobile front page(view),
I was trying to avoid this, but it does not seem to be much trouble.

Add this code near the top of MYTHEME/page.tpl.php

<?php if ($is_mobile == TRUE && drupal_is_front_page()):
drupal_goto('/mobile');
endif;
?>

Then you can adjust the pager, number of posts etc. I suppose this
is a workaround not an answer.


How to dynamically redirect user from /foo/X to /bar/X?

Since passing context for token's replace method didn't work as expected, I've defined a new token in my custom module to return the specific components of the Drupal path (using the following guide).

my_redirect.tokens.inc

<?php

/**
 * @file
 * An include file defining custom tokens.
 */

use Drupal\Core\Render\BubbleableMetadata;

/**
 * Implements hook_token_info().
 */
function my_redirect_token_info() {
  $type = [
    'name' => t('Custom URL token for redirect'),
    'description' => t('Tokens helpful for redirect pages.'),
  ];

  $node['url-arg'] = [
    'name' => t("URL Argument"),
    'dynamic' => TRUE,
    'description' => t('Returns a component of the current Drupal path.'),
  ];

  return [
    'types' => ['my_redirect' => $type],
    'tokens' => ['my_redirect' => $node],
  ];
}

/**
 * Implements hook_tokens().
 */
function my_redirect_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {

  $replacements = [];

  if ($type == 'my_redirect') {
    if ($argTokens = \Drupal::token()->findWithPrefix($tokens, 'url-arg')) {
      foreach ($argTokens as $arg => $original) {
        $current_path = \Drupal::service('path.current')->getPath();
        if ($arg === "first") {
          $value = explode('/', $current_path)[1];
        }
        elseif ($arg === "last") {
          $value = end(explode('/', $current_path));
        }
        else {
          $value = explode('/', $current_path)[$arg ?: 0];
        }
        $replacements[$original] = $value;
      }
    }
  }

  return $replacements;
}

So after applying already mentioned patches, and above code, I can use the following Redirect rule:

From: foo/*
To: /bar/[my_redirect:url-arg:2]


Facebook scraper ignores default language

Without knowing exactly how the following tags are generated I cannot provide the exact solution to your issue, but only to point out what causes the Facebook to grab EN version.

1. <link href="https://www.example.com/node/581?lang=en" rel="alternate"
> hreflang="en" />

2. <link href="https://www.example.com/task/581"
> rel="alternate" hreflang="de" />

Tags 1 & 2 have rel attribute set to alternative, which tells facebook that both links from tag 1 & 2 can be used for fetching info. Therefore it grabs the first one in line.

Each page should have rel="canonical" tag that will tell facebook and all other crawlers, that it is a primary url for that page that should be used for fetching info.

I do not know if you have a link tag with rel="canonical" in your source code, as you only copied a portion of your meta tags. I suggest you check if it is present, and what page version it points to. If it is not present, add it.

Also, meta tag og:url should point to the right version of the page.

<meta property="og:url" content="https://www.example.com/task/581" />

Test your tags by fetching new meta info via Facebook Open Graph Debugger.


Where do you store arbitrary home page data?

If its all editable why not creating a content type "homepage"?
There will be only 1 node of this type(so what...)


Kind of a "big"/multiple question(s), that is hard to answer. Try to ask more specific, single questions in the future.

About hook_page_alter(). In a theme, you should customize the output by overriding default templates. IMHO, that hook is more meant if modules want to alter the output of other modules, especially if they return render arrays instead of arbitrary strings.

Speaking of render arrays, that is one of the main things I do with my modules now, instead of arbitrary templates. I've already replaced quite a few specific "page callback templates" by building and returning a so called render array. The advantage is that, if you for example want to change the order of the table rows, or add/hide a table row, you can do that without duplicating a template with maybe 100 lines of code. And, multiple modules can add/change things.

Two examples:

userpoints_admin_transactions()
user_relationships_page()

Edit:

And for your last question: Regions in "Theme-speak" are places where blocks can be placed. Regions are defined in the .info file of a theme. The node template itself is more or less a block (The "Content" block, which is the output of the executed page callback). Since it is not possible to nest regions within regions/blocks you can also not place regions in a node template.

That said, you can make your node template as complex as you want, and split the content up into "visual regions" for example.


Deleting User Picture changes the password of user?

Yes it does. This works as designed, but you made mistake. When you obtain user object, it does not contain a password. It contains a password field, but it's not populated with actual password as it is impossible by design to know it. So you are feeding all fields to user_save, including field for password, but without password in it.


Replacing theme() with render() in a block_view

How about:

...
$rdr = array(
  '#theme' => 'opendtp_slide',
  '#module_path' => drupal_get_path('module', 'mymodule')
);
...


Having trouble printing my theme from a custom module


How we can define constant in template.php for our theme

In the preprocess function (hook_preprocess_THEME), you can use this:

$variables['theme_path'] = drupal_get_path('theme', 'xyz');

Which you can then use as $theme_path in your template.


Redirect user to previous page after registration

You could use Rules module to achieve that..


How to exclude a hook function from the hook list?

You can implement hook_module_implements_alter(). For example to remove the cron hook from the system module:

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'cron') {
    unset($implementations['system']);
  }
}


Redirecting a user to a different home page

You can do this with a combination of the themekey module and the login destination module. For both, you would start by creating specific user roles for the your three user types, ex

userrole1
userrole2
userrole3

Then setup these two modules and have all users with userrole1 redirect to a specific page after logging in:

  The Login Destination module allows you to customize the destination that a user is redirected to after logging in, registering to the site (7.x), using a one-time login link or logging out (7.x). The destination can be an internal page or an external URL. It is possible to specify certain conditions like referring pages or user roles and make the destination depend upon them.

And then use themekey to switch the theme / output based on the specific user role:

  ThemeKey allows you to define simple or sophisticated theme-switching rules which allow automatic selection of a theme depending on current path, taxonomy terms, language, node-type, and many, many other properties.


How to direct a specific role to a specific page

In rules you could select "when a user logs in" and then as the action, select "custom php code" and fiddle with something along the lines of:

if (in_array('ROLE_TO_CHECK', array_values($account->roles))) {
  drupal_goto('PAGE_TO_GOTO');
}

ADDITION:

D'oh!

Rules can do this....

Select 'Add a new rule'
Name it whatever and select 'User has logged in' as the event
Add a condition: User has role(s)
Select the role you want
Add an action.
Select Page Redirect
Enter the path you want ADDITION:  check both Force Redirect and Immediate Issue check boxes
Save


How do I get the UID in user-profile.tpl.php?

I found the uid under the elements >> #account object:

$elements['#account']->uid;

Good luck!


How to make all images in Views display at same dimensions

You have to chose an image style for your images. Set up your grid image style first under admin/config/media/image-styles


How to get a mini-calendar as a block on sidebar?


Drupal 8 Ajax Callbacks misbehaving when form element in table

It's hard to tell without seeing some code of the table. There is probably an error in the structure of the form array. All form elements must have the correct key in the array, which correspondent with the #name. And this keys and names must be unique in the whole form. If you put a form element in a table, use an extra layer to give the element the right key.


Solution from Chris (original post):

It worked to me.

"
Only solution that worked for me was the following:

go to your content type/vocabulary
add a weight field (label: weight | machine name: weight | field type: integer
edit your sorting view and add sort criteria for your newly added weight field
edit your draggable views field and change "Handler" from Native to FieldAPI
under Field select your weight field
-go to your content view and add the new weight field as you sort criteria

This is the only thing that worked for me. If it doesn't work immediately, just reorder a few items on your draggable view so that the ordering values are reset.

Hope this works for you too.
"


Item pagination - fatal error: allowed memory exhausted

I'm not sure what theme_activit_item_list_block() is but I suspect you want this:

theme('pager', array('quantity' => count($items)));

instead of this:

theme('pager', array('quantity', count($items)));


Download Views Bootstrap and create a view for the menu you want to display as accordion. For your view format choose Bootstrap Accordion


That is because, when you visit a page that is not a node page, menu_get_object() (when called without arguments) doesn't return any value. The function could not return any value in other cases too, or not return an object, if the load function returns FALSE, as the code executed from the function is the following one.

  $router_item = menu_get_item($path);
  if (isset($router_item['load_functions'][$position]) && !empty($router_item['map'][$position]) && $router_item['load_functions'][$position] == $type . '_load') {
    return $router_item['map'][$position];
  }

Your code should be similar to the following one:

$node = menu_get_object();

if (arg(0) == 'forum' || (!empty($node) && $node->type == 'forum')) {
  print $breadcrumb;
}


Does not sound like a multi-threading issue to me?
If you have two childs having the the same new parent in the entity reference field (BTW, what approach do use for creation, this is rather tricky ..), it will be probably created "twice", but with different ids - no?
Why don't you create the parent entity first and assign it afterwards to the entity-reference field target_id or entity property (if you are controlling it yourself)?


Difference between views handler and views plugin?

The difference is summarized in the first sentence on About Views plugins:

  In Views, a plugin is a bit like a handler, but plugins are not directly responsible for building the query. Instead, they are objects that are used to display the view or make other modifications.

A view handler is implemented using a class derived from the views_handler class, which has methods to build the query, or to alter the result obtained from a query, such as:

views_handler::get_join()
views_handler::pre_query()
views_handler::sanitize_output()
views_handler::post_execute()
views_handler::placeholder()

On the other hand, the views_plugin class has only a method that is related to the query: views_plugin::query().


problem with page count in pressflow & varnish

This module should take care if it for you
http://drupal.org/project/jstats

For other options see the Performance wiki and look (ctrl-f) for Statistics
http://groups.drupal.org/node/187209


How can I programmatically import configuration?

You should save the config like $config_storage->save(); :
As @4K4 mentioned :

  The important thing is not simply store config, but create and save config entities and so run CRUD methods/hooks like https://api.drupal.org/api/drupal/core%21modules%21field%21src%21Entity%21FieldStorageConfig.php/function/FieldStorageConfig%3A%3ApreSave/8.7.x


Assign Node To Other Menus Besides Main Menu

Restricting the menus to which a Content Type can be added is configured on the Content Type itself (Structure -> Content Types -> Edit or admin/structure/types/manage/[content-type]) within the "Menu settings" tab:

By default, only the Main menu is selected. Simply check off additional menus to make them available on the node add/edit page for that Content Type.


How do I the add vocabulary name or the ID to the  CSS classes?

The vocabulary id is not a route parameter, unless you have a route to view/edit a vocabulary, but these are all admin routes. So you need to get the information from the term:

function mytheme_preprocess_html(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical') {
    // load the term entity and get the data from there
    $term = \Drupal::routeMatch()->getParameter('taxonomy_term');
    $variables['term_id'] = $term->id();
    $variables['vocabulary_id'] = $term->bundle();
  }
}

bundle() returns the vocabulary of the term. This is the same as a content type of a node. Or a block type of a custom block. All are fieldable bundles of entities.

So if you use bundle() on a node you'll get for example the machine name article.


Can I relate a node with a taxonomy term via its description and not its name?

If you use drupal 7 you add a term reference field to the content type, and choose which taxonomy terms are related to the node on the add/edit page for the node. There refs are done by term id (tid) not by name/description


First, you should use Views Slideshow to do this.

On Drupal 7, add 2 more text fields in your content type; then add them to the view using Content: [your text field name].


What are folders within sites/default/files for?

They're created by different parts of the system, when they're required, for pretty much anything at all that a module needs to store file-wise.

It would be pointless to try to list them all, as core/contrib/custom modules can place files/folders there arbitrarily; Drupal doesn't place any restrictions on what can/can't be stored there, it's up to each bit of code as to how and when it uses that folder to read/write.


Why doesn't loading a form in the view header work?

sEntity forms should be built using the entity.form_builder service. You'll need an entity to work with, for a node your code might change to something like this:

$node = \Drupal::entityTypeManager()
  ->getStorage('node')
  ->create(['type' => 'page']);

$form = \Drupal::service('entity.form_builder')->getForm($node);

print \Drupal::service('renderer')->render($form);

As noted in the comments, this won't actually work in the context you're using it, regardless of how you render the form. The views_php area handler renders the output of the custom PHP using #markup, which will strip out the <input> and other form tags. You'll need a custom or contributed module, or to alter the views_php module directly, to make this work.

Here's a simple area handler that adds support for common form tags:

<?php

namespace Drupal\foo\Plugin\views\area;

use Drupal\Component\Utility\Xss;
use Drupal\views_php\Plugin\views\area\ViewsPhp;

/**
 * Views area PHP text handler with support for common form tags.
 *
 * @ingroup views_area_handlers
 *
 * @ViewsArea("foo")
 */
class ViewsPhpForm extends ViewsPhp {

  public function render($empty = FALSE) {
    if (!$empty || !empty($this->options['empty'])) {
      $content = $this->renderViewsPhp($this->options['content']);
      $form_tags = ['form', 'input', 'select', 'fieldset', 'option', 'button', 'textarea', 'optgroup'];
      $allowed_tags = array_merge(Xss::getAdminTagList(), $form_tags);

      return [
        '#type' => 'inline_template',
        '#template' => Xss::filter($content, $allowed_tags),
      ];
    }

    return [];
  }

}

This code should be in src/Plugin/views/area/ViewsPhpForm.php and will need updating for the name of your module.

You'll also need to make views aware of it with a hook either in your .module file, or foo.views.inc:

/**
 * Implements hook_views_data().
 */
function foo_views_data() {
  $data['views']['php_with_form'] = [
    'title' => t('PHP with form'),
    'help' => t('Use PHP code with support for form tags.'),
    'area' => [
      'id' => 'foo',
    ],
  ];

  return $data;
}

After a cache rebuild you'll be able to add a new area handler, PHP with form, and your form should be rendered.


How to omit form's validation at AJAX button click?

You can use the #limit_validation_errors property:

  Provides an array of sections which are parts of $form_state['values'] which should be validated, implying that sections which are not listed should not be validated. This is normally used in multistep forms in the case of a "back" button, for example, where '#limit_validation_errors' => array() would mean not to validate anything as form values on the current page are to be discarded anyway. #limit_validation_errors does not have any effect if #submit is not set. More discussion is in the form_set_error() documentation.

e.g.

'ajax_button' => array(
    '#type' => 'button',
    '#value' => t("Scan for tags"),
    '#ajax' => array(
      'callback' => 'ajax_tag',
      'wrapper' => 'dynamic-tags-fieldset',
      'method' => 'replace',
      'event' => 'click',
      'prevent' => 'submit click mousedown',
    ),
    '#limit_validation_errors' => array(), // No elements will be validated
    '#submit' => array('custom_function'), // An explicit submit functions array is required for this, but may be empty
  ),

However, each validation function is free to respect '#limit_validation_errors' or not. If you want your validation functions to respect this parameter, you need to:

Obtain #limit_validation_errors value from clicked button using $form_state['clicked_button']['#limit_validation_errors']
Pass it as a third argument to each form_set_error() call


Drush was not able to start (bootstrap) the Drupal database - MySQL Access denied error

The answer to the problem was that I had a file .my.cnf in my home directory which I used a while back. It contained the user=username and the password=old_password. This was the cause of problem as it contained the correct username but an old password.

Previous drush versions (< 7.x) did not use the mysql option --defaults-extra-file=/tmp/mysql_credentials to connect to database and that's why the problem didn't exist when I used an older version of drush.

I would have thought that the '--defaults-extra-file=/tmp/mysql_credentials would supercede the .my.cnf in my home directory but it doesn't seem to.

One thing which would be useful to help debug this issue it to make drush not delete the /tmp/... files when you select the -d option.


It looks like the $object variable doesn't exist, or isn't in scope. Check the arguments your function receives for the proper node object.


Autocreating new node based on non-existing node reference

You can use Node Reference Create module.

It will create the node automatically without having to fill in the node fields.


How to hide purchased commerce product with Panels visibility rules?

I solved this by using the flag module and rules.

In summary: When the customer buys access to the hidden content, a rule is triggered that flags the content author on behalf of the customer. Panels can set visibility of a pane based on whether this flag exists between author and current user viewing the page.


How can I reduce the cache_default table?

You might try compressing the data before sending it. There's a module for that: compressed_cache


When setting up the Drupal 7 database (mySql/mariadb) what database user accounts should be created?

You just need one user allowed to create, drop tables, and mysql basic operations (INSERT, SELECT, UPDATE, DELTE, ALTER, INDEX...). In drupal installation tutorial you have more info.


Remove required field in validation form

Use states to style the input as required. This won't actually perform any validation but will add the required asterisk to the field when field B has a certain value.

$form['FIELD_A']['#states'] = [
  'required' => array(
    ':input[name="FIELD_B"]' => array('value' => 'foo'),
  ),
];

Then use custom validation to actually check FIELD_A has the correct value depending on the value of FIELD_B.


View items content type as css class in view template

You need to adjust the template (tpl) file that's being used to generate the markup for the Views output. I think everything you'll need as well as a bunch of related and equally important info can be found here: Mustardseed -> Views Theming


How to speed up node add form with around 50 fields?

Have you considered using multistep forms for your node creation?

Given that you have a lot of fields, you can do it at multiple page loads via various logical steps. There are lots of tutorials for multistep form implementation in Drupal and the example module ships with one.


How to set the url alias of a node created by Rules?

It is probably because you have not "made that field available yet to Rules".

To do so, add a "Rules condition" like "Entity has field", and use that "[node:og-group-ref]" in that condition to be added.

Not sure if it is the ONLY problem you have, but for sure something you should add to your rule.


drupal 7.35 .htaccess: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration

The current iteration of the PHP buildpack uses Apache HTTPD 2.4.  The message that you're seeing is caused because you're using configuration that is specific to HTTP 2.2.

There are two ways to correct this.

1.) Update your configuration to use HTTP 2.4.  Instructions for migrating can be found here.

2.) You can enable the mod_access_compat module for HTTP 2.4.  This will allow you to keep using the older configuration style.  To do this, you should copy this file from the build pack, place it in the root of your project directory under .bp-config/httpd/extra/httpd-modules.conf and uncomment line #27.  Then when you push, the build pack will detect all the enabled module, include mod_access_compat from the configuration file and enable them.

If you have any trouble modifying the build pack configuration, see here for more details.


Custom breadcrumbs from a breadcrumb builder disappear until I clear Varnish cache

Pretty sure I found the root cause. I found some errant code here in the else condition.

/**
 * Implements hook_preprocess_block().
 */
function mytheme_preprocess_block(&$variables) {
  if ($variables['plugin_id'] == 'system_breadcrumb_block') {
    if (...) {
      $variables['attributes']['class'][] = 'hl__breadcrumb--light';
    }
    else {
      if (!empty($variables['content']['#links'])) {
        if (count($variables['content']['#links']) == 1) {
          $variables['content'] = [];
          $variables['elements']['content'] = $variables['content'];
        }
      }
    }
  }
}

Deleting the entire else block seems to have corrected the issue, unable to replicate it now.


Add administration menu item for one role only

I can get a custom menu item showing up in the admin bar, but how do I get it to redirect to another page, and how to I stop users without the role from seeing it?

You can set the page callback to drupal_goto, pass the redirect path and other arguments as page arguments, and use the access arguments to set permissions.

I love admin menu, but I'm not sure it's something I particularly like putting in the hands of the clients. It's easy to find yourself giving too many perms to the client, and you can't use the menu module to add items to it. I've not used it yet, but on my next project I'm going to try something like SimpleMenu.


With Drupal you are not supposed to manage the cache backend by yourself. Once memcached is set as your cache backend, you can just use the cache functions cache_set(), cache_get(), etc. and this data will go to cache.


How to add "load more" link to comments?

Views Infinite Scroll and many similar modules allows you just that.

  Views Infinite Scroll provides a Pluggable pager that enables views infinite scrolling ( autopaging, depaging, endless pages ...you name it) by using jquery.autopager plugin. using this module with views page display will load another page whenever the user reaches bottom of the page.

Views Load More is other example.

  Yes, this is indeed, Yet another load more pager for views.

And you can show anything with Views. Comments too.


Create several form in a same module or function in Drupal 7

There's nothing limiting you to a single form, your page callback just needs to return a render array containing all of the ones you need:

return [
  'form_1' => drupal_get_form('MYMODULE_form_1'),
  'form_2' => drupal_get_form('MYMODULE_form_2')
  'form_3' => drupal_get_form('MYMODULE_form_3'),
];


Drupal doesn't invoke a hook function until I don't clean the cache

The reason why clearing the caches fixed the issue is because all hooks are cached in Drupal 7 via module_implements(). My guess is something odd happened to your cache and thus your hook went missing from the cache.


Display parent term based on child term in views

You need to add Taxonomy term: Parent term in RELATIONSHIPS of the view.

Then in the field section select the Relationship

That's it. Whatever term you enter in the contextual filter it fetches the parent term of it.

Here is entire exported view (example).

$view = new view();
$view->name = 'tag_relation';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'taxonomy_term_data';
$view->human_name = 'Tag relation';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Tag relation';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Taxonomy term: Parent term */
$handler->display->display_options['relationships']['parent']['id'] = 'parent';
$handler->display->display_options['relationships']['parent']['table'] = 'taxonomy_term_hierarchy';
$handler->display->display_options['relationships']['parent']['field'] = 'parent';
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'parent';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE;
/* Contextual filter: Taxonomy term: Name */
$handler->display->display_options['arguments']['name']['id'] = 'name';
$handler->display->display_options['arguments']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['arguments']['name']['field'] = 'name';
$handler->display->display_options['arguments']['name']['default_action'] = 'empty';
$handler->display->display_options['arguments']['name']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['name']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['name']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['name']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['name']['limit'] = '0';
/* Filter criterion: Taxonomy vocabulary: Machine name */
$handler->display->display_options['filters']['machine_name']['id'] = 'machine_name';
$handler->display->display_options['filters']['machine_name']['table'] = 'taxonomy_vocabulary';
$handler->display->display_options['filters']['machine_name']['field'] = 'machine_name';
$handler->display->display_options['filters']['machine_name']['value'] = array(
  'tags' => 'tags',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'tag-relation';


How (and Where) to store downloadable commerce files outside the file system..?

You can configure the "Private file system path" to be outside your Drupal installation by changing it in the admin/config/media/file-system. and you configure your commerce files there. this should do the trick. either way Drupal do not provide direct url access to the private files.


How can I defer parsing of Javascript on my Drupal 7 site?

Given that nearly everything in Javascript for Drupal is triggered by a $(document).ready() in jQuery, I don't see any real advantage to using defer.  In fact, I recently had a real headache1 from some code I inherited that mixed the two.

One recommendation (I think YSlow suggests it) that you can do is to move scripts to the end, right before the closing </body>.  This would mean moving the <?php print $scripts; ?> in your html.tpl.php.  While not deferring the parsing, it does delay the loading so your page renders out quicker, and I have never had any problems in Drupal doing this.

If you do want to add the defer, you need to implement hook_js_alter:

function mymodule_js_alter (&$javascript)
{
  $javascript['misc/drupal.js']['defer'] = TRUE;
}

If you want to defer everything, you could try

function mymodule_js_alter (&$javascript)
{
  foreach ($javascript as $key => $value) {
    $javascript[$key]['defer'] = TRUE;
  }
}

Otherwise, most of the normal Pagespeed fixes don't have much to do with Drupal itself.  As long as you deploy with JS and CSS aggregation enabled you should be good.  Configure Apache to use compressed responses and decent cache lifetimes and I don't think PageSpeed will complain about much and give you all A's and B's.


Alternative to libraries_get_path() to get a JavaScript file path

You can get the same data using drupal_get_library(), but it's not in a friendly format so you'll have to dig into the array yourself. For example, the following code will get the same path as your current code but in a much less less satisfying manner (in my opinion anyway):

$lib = drupal_get_library('soundmanager2', 'soundmanager2_debug');
$sm_path = array_shift(array_keys($lib['js']));

As I understand it this is actually the reason there's a need for the Libraries API to exist...so this sort of thing can be managed in a structured manner.


If I'm understanding correctly, I'd recommend doing "Shared Hosting - Package A" as one product, and "Shared Hosting - Package B" as another, rather than a single product called "Shared Hosting" that has two attributes. (You can add the time period as a single attribute to each product.)

You can still style the matrix as you have done above (on a pricing page) and include links to purchase at the bottom of the column for each package.


"Invalid argument main.js" Gmap error in IE

i solved this problem.
in Gmap Module setting and Google Map Initialize check default center and enter valid  coordinates.
in my case default center was setted to 0,NAN. problem was with NAN.
at now it works in IE.


how to react on file save using rules module

You can use Entity Rules I believe for this.
From the module page:

Entity Rules provides a page for selecting and creating Rules components that will be executed when different operations happen to an Entity of a particular bundle. This provides an alternative method of triggering Rules. Instead of adding entity related events to Reaction Rules you are able to select which Rules will fire from the bundle management page.
Currently the operations supported are create, update, delete, validation and form access. You are also able to pass different arguments to the Rules per bundle.

In Drupal 7 the de facto module is typically file_entity used alongside the media module so if you are using those then the above should work but if you are not you may at least need the file_entity module.
I also noticed an issue in the Entity Rules issues page that listed a bug with file_entity but has been fixed in dev, so if the normal version does not work I would try the dev version to see if that works.
Hope that helps!


Warning: Illegal string offset '#access' in views_handler_field_field->set_items() line 862 views_handler_field_field.inc

I found the answer, I realised that as well as the error, I was also seeing a "1" appear after the grid items.

This bug is related to the Grid Field Display module, and the answer and patch can be found at https://drupal.org/node/2046435


How to make a display mode of the current user on the home page?

In a Twig template you can get the current user id with user.id.
With the help of Twig Tweak you can use it to render the user entity:
{{ drupal_entity('user', user.id, 'full') }}

As discussed in the comments this only works if your template has already a cache context for the current user.


Disable submit button if none selected using #states

The "#empty_option" will not give a value, which is needed for #states, a workaround is to add the default as an actual option:

$field_type_options = array( 0 => '- Select a field type -');

$form['type'] = array(
  '#type' => 'select',
  '#title' => t('Type of new field'),
  '#options' => $field_type_options,
  '#description' => t('Type of data to store.'),
  '#default_value' => isset( $form_state['values']['type'] ) ?  $form_state['values']['type'] : 0,
  '#required' => TRUE,
  );

  $form['save'] = array (
   '#type' => 'submit',
   '#value' => t ('Save field'),
   '#states' => array(
     'disabled' => array(
       ':input[name="type"]' => array('value' => 0),
      )
    )
  );

This allows #states to test the value and disable the item


Proper with "Executing Custom PHP Code" Action

Okay I solved it, It turned out to be very simple. Facepalm

I had misconfigured nodejs which was causing a javascript error. Which meant the textbox which should've appeared didn't.

I reconfigured nodejs and it worked fine :)


Attaching libraries to specific controllers

You are not indenting parts of the yml file that you need to indent.

Look at this example from token.libraries.yml at /modules/contrib/token/token.libraries.yml:

jquery.treeTable:
  remote: 'http://plugins.jquery.com/treetable/'
  version: 3.2.0
  license:
    name: MIT
    url: https://github.com/ludo/jquery-treetable/blob/3.2.0/MIT-LICENSE.txt
    gpl-compatible: true
  js:
    js/jquery.treetable.js: {}
  css:
    component:
      css/jquery.treetable.css: {}
      css/token.treetable.theme.css: {}
  dependencies:
    - core/jquery

Also, pay attention to colons, since they are part of YAML syntax.

use:

remote: 'remote: https://developers.google.com/chart'

not

remote: remote: https://developers.google.com/chart


How to create a node in Drupal 7 with a custom nid

http://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_save/7

I believe node_save() takes all the node edit form input and builds a new node with a node->id for you.

node_save() either tries to update an existing node, or give you a newly saved one. You want to set what NID it gives you back.

Assuming an SQL storage engine for Nodes. You'd have to pick a NID greater than the current SQL MAX(id) FROM {node} ...

You could then make a new node entity with entity_create( See Creating and Editing Entities Documentation ) just passing the bare parameters you want: NID, type, bundle.

Then you could do a node_load() and then a node_save() with your code above to actually build out the rest of the node ...

That's what I would try.


Relate data in a custom sql table to a regular drupal field using views

I assume you will be associating your "Attribute number" field to a node type, and that your view will be showing nodes. So, what you need to do here is describe your custom table (I call it "custom_an" here) to the views API and provide a way to join it when displaying node data. Here is a way to do that:

function YOURMODULE_views_data() {
  // Assign a group for the custom table:
  // can be an existing group - e.g. t("Content") -
  // or, like I  do here, a new custom group.
  $data['custom_an']['table']['group'] = t('Extended content');

  $data['custom_an']['table']['join'] = array(
    // This table will be available for join for any 'node' view.
    // 'left_table' is the referenced table,
    // i.e. the one that contains your field's data
    // 'left_field' is the join key in the referenced table.
    // 'field' is the foreign key in the custom table.
    'node' => array(
      'left_table' => 'field_data_field_attribute_number',
      'left_field' => 'field_attribute_number_value',
      'field' => 'attribute_number',
    ),
  );

  // here we describe the field(s) in the custom table
  // that we want to show in the view.
  $data['custom_an']['response'] = array(
    'title' => t('Response'),
    'help' => t('Response field.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE, // This is use by the table display plugin.
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  return $data;
}

Please be aware that this is only a proof of concept, and that it's meant to get you started but in no way you should use this code as is for a production site.
Two major issues to be addressed would be:

testing this code against a node type which does not contain the "Attribute number" field (and possibly find the right way to avoid that adding the custom data to that view results in a corrupted view), and
if attribute_number in your custom table is not unique, the view could output duplicate rows. The join key in the custom table should actually be a primary key, according to hook_views_data() documentation.


How to combine two batch operations for views data export into one?

I suppose you should be able to merge them into one module by first checking if the view is available in the batch (stop otherwise) and provide the filename within this check. Code has not been tested though.

function dvm_reports_views_data_export_batch_alter(&$batch, &$batch_redirect) {
  // Check for Denmark.
  if ($view = views_get_view($batch['produkty_denmark_xml'])) {
    $filename = 'denmark.xml';
  }
  // Check for Sweden.
  elseif ($view = views_get_view($batch['produkty_json'])) {
     $filename = 'producty.json';
  }
  // Check for Norway.
  // ... Code goes here

  // Leave if nothing was found.
  else return;

  // Proceed if something was found.

  // Add in another operation that will store the file on the server in a location
  // of our choosing.
  $batch['operations'][] = array(
    'dvm_reports_views_data_export_batch_finish', array($batch['eid'], $filename),
  );
}

function dvm_reports_views_data_export_batch_finish($eid, $filename) {
  $export = views_data_export_get($eid);
  $view = views_data_export_view_retrieve($eid);
  $view->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler->outputfile_path();
  file_unmanaged_copy($temp_file, 'public://'. $filename, FILE_EXISTS_REPLACE);
}

There might however be a bigger problem with your module. I cannot see your hook menu implementation, but if anonymous users are also able to access domain.com/denmark they could DDoS your site. Prevent that.


Drush automatically defines the alias @self to refer to the currently bootstrapped site.  So, if you have identified a site via cwd (that is, cd /path/to/sites/mysite, where sites/mysite is the folder that contains settings.php), then you could run:

drush sa @self

This will tell Drush to print out a site alias for the current site. You can then copy this to an alias file and give it a handy name for later use.  If you're doing this for a remote site, try adding --with-db if you'd like to include the database record inside the site alias.  You're better off leaving out the database information for local sites, though, as you can get inconsistent results if the db info in your alias does not match the db info in settings.php.

If you want to disable cwd-based site selection, then define 'root' and 'uri' in any drushrc.php file:

$options['root'] = '/path/to/drupal';
$options['uri'] = 'http://mysite.org';

There is no way to specify an alias in a Drush configuration file, but you could use the site-set command from the command line:

$ drush site-set @stage

If you wanted this command to be persistent, you could run it from your .bashrc.


How to hide a content type on the node add page?

Two possibilities:

admin/structure/menu/manage/navigation move/delete menu item that you don't want.
Cleanest way: use roles and permissions. If the user can't create a content type the link will not appear in any menu.


You may not use the js injector module. Colorbox integrates seamlessly well with views. If you are displaying content as fields in the view (which I think you are) you can use the :

Fields -> Add

option to introduce a colorbox trigger.

For example, Lets consider the below fields :

The first item "Content : Gallery Image Upload"  has the following settings

The second item "Content : Gallery Image Upload"  has the following settings

and you set up your colorbox trigger like below :

The replacement pattern is all that matters here. If you are
confused what to put for popup, scroll all the way down
to Replacement Patterns and select appropriate field and paste
it in the popup box. Here the trigger field is the the first
"Content : Gallery Image Upload" field and when somebody clicks
it we are introducing a colorbox trigger to start the colorbox
slideshow configured for the second "Content : Gallery Image Upload"
field.

In short, we are setting up a Gallery here. :)


Anyway. You can back up the database with the back up and migrate module and import to your live site. The other tool can be drush cex for exporting configuration and drush cim for importing it.


If you want to find the label for a specific field then you can use field_info_instance()

https://api.drupal.org/api/drupal/modules!field!field.info.inc/function/field_info_instance/7

<?php
$field_instance = field_info_instance('node', 'field_body', 'article');
$label = $field_instance['label'];
?>

However, the titles are available in the rendered node if they are not hidden in your view mode, and can accessed like :

<?php
$node  = node_view(node_load($nid));
$label = $node['field_body']['#title'];
?>


You can get the current language through the global $language var:

$current_lang_code = $GLOBALS['language']->language;

With that in mind you just need to make whatever changes are necessary to your PHP classes (XmlWebformGenerate/XmlSource/etc), to add that data to the document.


If you are running Drupal in subdirectory named "dev". Then you need to put $base_url = 'http://www.example.com' in your settings.php. You may need to put RewriteBase /dev in your .htaccess but generally that isn't necessary for me.

If you want to run Drupal at http://dev.example.com that is purely an issue of configuring Apache correctly. Your likely need to change your httpd.conf or similar file to setup virtual hosting. Drupal won't need any changes.


How to proceed towards MySQL performance testing for Drupal?

First tool, that can be used, is Devel - it will show there's long calls have been made.
And there's many tools for perfomancing and tuning mysql in internet.


how to create a taxonomy Views combining terms from 2 different vocabulary

By default, Views Taxonomy page allows you to select multiple terms.  If you click on the Contextual Filter "Content: Has taxonomy term ID (with depth)", one of the first choices you see is whether to allow multiple values.
Let's say that these categories have the following term IDs:

Destination Vocab:

dest1 [25],
dest2 [26],
dest3 [27],
dest4 [28]

Category Vocab:

cat1 [35]
-- subcat1.1 [37]
-- subcat1.2 [38]
cat2 [36]
-- subcat2.1 [39]
-- subcat2.2 [40]

If you want a page to show you all items in category 2 for destination 3, you'd have a url like this:  http://www.example.com/taxonomy/term/27+36.
To limit the allowed Vocabularies, open that same Contextual Filter "Content: Has taxonomy term ID (with depth)" and scroll down to the section "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED".  There is a validation section where you can check off the vocabularies that you want included:

taxonomy validation http://www.emijayne.com/sites/default/files/linked/taxonomy.jpg


You need to attach your Feed display to one of your Page displays (within the same view).

To do this, in Feed settings click on Attach to: None and tick one of previously created Page displays (or create one first if you haven't already done so). Only then the RSS icon will be displayed on the page your feed is attached to.

Here's a screen shot for anyone who (like me) can't see the wood for the trees.


How to Display popup block when user scrolls down to the bottom of node

You could do It without modules using some CSS and javascript.

You can create the block with the content you want to show, keep it hidden by CSS and, once the user scrolls down enough, trigger a js event that toggles the blok class to a visible one.

Here You can find how to trigger an event when scrolling to a certain point:

https://stackoverflow.com/questions/21561480/trigger-event-when-user-scroll-to-specific-element-with-jquery

Using the example code, you could use something like:

$(window).scroll(function() {
   var hT = $('#scroll-to').offset().top,
       hH = $('#scroll-to').outerHeight(),
       wH = $(window).height(),
       wS = $(this).scrollTop();
   if (wS > (hT+hH-wH)){
       $('#yourblock').toggleClass('visible');
   }
});


DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data()

You can solve this by setting up temporary path i.e.

Goto :

  Home » Administration » Configuration » Media and fix temporary
  directory.

or Goto to the path & add temp url :

config/media/file-system


How to retrieve view row attributes when in twig template

The views-view.html.twig template is at a higher level. To manipulate data at that level, you'll need to use template_preprocess_views_view().
You used template_preprocess_views_view_unformatted() which allows you to manipulate the data in views-view-unformatted.html.twig. This seems like the correct approach given your case.
Here are the contents of views-view-unformatted.html.twig from the views module in core.
{#
/**
 * @file
 * Default theme implementation to display a view of unformatted rows.
 *
 * Available variables:
 * - title: The title of this group of rows. May be empty.
 * - rows: A list of the view's row items.
 *   - attributes: The row's HTML attributes.
 *   - content: The row's content.
 * - view: The view object.
 * - default_row_class: A flag indicating whether default classes should be
 *   used on rows.
 *
 * @see template_preprocess_views_view_unformatted()
 *
 * @ingroup themeable
 */
#}
{% if title %}
  <h3>{{ title }}</h3>
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  <div{{ row.attributes.addClass(row_classes) }}>
    {{- row.content -}}
  </div>
{% endfor %}

You can see that if you loop through the rows variable, each row has an attributes property - the classes you added in template_preprocess_views_view_unformatted() will be part of it.


how to give the id of image in drupal 7 views?

If a unique class is acceptable, you can add a class to a field using built-in features. Under the field settings:


How to incorporate the body field back into a content type from which it has been previously deleted?

In a hook_update_n(), module_install(), module_enable(), or devel module eval php code:

$types = node_type_get_types();
node_add_body_field($types['my_content_type_name']);

giving it the machine name of your content type, and optionally you may provide a label for what you want the human readable label for the field to be (defaults to 'Body'). see node_add_body_field() API documentation


Turns out it was because of a module called commerce_variation_cart_form.
After uninstalling it, everything worked as expected.


How can I make db_select recognize an empty field?

Just do a left join on 'files_managed' table

$query = db_select('node', 'n');
$query->join('users', 'u', 'n.uid = u.uid');
$query->leftjoin('file_managed', 'f', 'f.fid = u.picture');
$query->fields('f',array('uri'));
$query->fields('n',array('nid'));
$query = $query->execute();
dpm($query->fetchAll());


There should be at least a block, as the "Main page content" block is always associated with a region. You always need to select a region for that block, as the "-None-" option is not available when selecting a region for it.

The list of blocks can be altered from modules. If a module is removing the "Main page content" block from the list, it doesn't appear in the list, and the list would be empty, if there aren't any other enabled blocks. _block_load_blocks() contains the following code.

$block_info = $result->fetchAllAssoc('bid');
// Allow modules to modify the block list.
drupal_alter('block_list', $block_info);


Ordering by taxonomy field ascending but leaving those node without taxonomy at the bottom

My suggestion is to modify your main view to list only Product nodes with a taxonomy term selected, then use an attachment to your main view that lists Product nodes with no taxonomy term. The attachment would be displayed after your main view.

Steps

1. Filter your main view to list only Product nodes with a taxonomy term value

In your main view's configuration, under Filter Criteria, add a filter for your taxonomy term field (choose either dropdown or autocomplete), and select "Is not empty (NOT NULL)".

2. Create the attachment that lists Product nodes with no taxonomy term value

Add an Attachment display to your view.

Under Attachment settings, set Attach to to your main view display (in this example the main view is Page), and set the Attachment position to After.

In the attachment display's Filter Criteria, change the taxonomy term filter to "Is empty (NULL)". Make sure to override this setting for the attachment display only or it will apply to the main view as well.

Note about the attachment header

Your attachment view will be displayed right after your main view, so you may want to add a Header to the attachment (make sure to override to the attachment display only).

In this example I used a Text area.

Alternatively, you could add a label to the taxonomy term field. Make sure to override this setting for the attachment display only or it will apply back to the main view.

Results

Your main view should now list your Product nodes by taxonomy term in ascending order, and your Product nodes with no value selected for the taxonomy at the bottom of the list.


How to display a percentage for a pie chart label using the Charts module?

This is a typical request for the Charts module ... There is currently no out-of-the-box solution available in the Charts module. But since you're using Highcharts, there is a patch available that may help somehow. The patch is attached to Comment nr 4 of issue #2209467. Be aware of the current status of this issue, i.e.:

the patch only works for Highcharts (as charting engine), the Google Charts counterpart of it is still missing (and prereq for adding this feature to the Charts module).
it is related to the Charts API (which is different from the Views integration). So after the Charts API feature gets delivered, some more (minor?) work is needed to also make it available within the Views integration of the Charts module.

The child issues of this issue contain some more variations, which may also help.

So only considering the Charts module as an alternative, and applying the suggested patch is not sufficient. But at least it should help somehow to understand what the missing pieces are. And maybe inspire somebody to submit 1 (or more) additional patch(es) to make it complete?

Note: The issue about "Views field as data label for better tooltips" is somehow related to this issue, and specific to the views integration. Comment # 6 in it contains an interesting patch for it also.

Disclosure: I'm a maintainer of the Charts module, I hope this does not violate the site's policy on self-promotion.


How to make one node relate to another node?

I'd look into Node References or Taxonomy depending on what version of drupal you are using and whether or not you are trying to create a hierarchy structure in your site.


Try adding a "display: relative" to the outer div that wraps the slideshow.


Something like:

$current_user = \Drupal::currentUser();
$roles = $current_user->getRoles();

will return an array like:

Array
(
  [0] => authenticated
  [1] => administrator
  [2] => some_other_role
)

where the array values are role IDs (equivalent to the machine name of the role in Drupal 7).  In OO code, use the appropriate mechanism get the current user from the container, eg

$current_user = $container->get('current_user');


How to order a node's taxonomy terms hierarchically?

No they are not ordered hierarchically by default...

In order to do it yourself you could take a look at the following functions: taxonomy_get_parents() and taxonomy_get_children().

Here is a great article with nice examples: http://davidherron.com/content/improving-navigability-drupal-taxonomy-hierarchies


Automatically load the URL from link field into a script

You could use a field template in your theme.

Call it something like field--field-linkedin-url.tpl.php (whatever you have called your field. I'm assuming field_linkedin_url for my example. Notice the _'s are converted to -'s in the file name.

In the template put the following html:

<script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/MemberProfile" data-id="<?php print render($items); ?>" data-format="hover"></script>

It shows something like this:


Restrict block to specific pages is broken when using view pagination

It turns out since my block was itself a view, it received the page param from the url, and since pagination was turned on, it just went to other pages, which happened to be empty.

I fixed it by turning off pagination on the block view.


Changing upload_max_filesize inb Drupal 7

Personally I would change it in the /etc/php.ini file as it won't be overwritten. You will need to restart apache to see the changes


How to use jquery accordian in side bar first

As I understood you want to make it Collapsible.  If yes try below mentioned module

https://drupal.org/project/facetapi_collapsible

https://drupal.org/files/project-images/collapsible_facets_0.png


I want to call a mymodule.functions.inc file

You need to use the module_load_include function.

EDIT: As @Darvanen mentions this needs to go in your .module file preferably inside a suitable hook. Have you seen the Including code section of the Coding standards page?


Controlling a dependent field in a multi-instance paragraph

I managed to make it work using a different approach; instead of overriding the NodeFrom, I used hook_field_widget_WIDGET_TYPE_form_alter and edited the subform array there.
Example:

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function MY_MODULE_field_widget_entity_reference_paragraphs_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context)
{
  //Logic to exclude other Paragraph types
  if ($element['#paragraph_type'] !== 'YOUR_PARAGRAPH_TYPE'){ //e.g. cities
    return;
  }
  $element['subform']['field_places']['#states'] = [
    'visible' => [
      [
        //It worked for me with the ID of the select, I think you can use the name also
        '#edit-field-cities-0-subform-field-city' => array('value' => 'Cairo'),
      ]
    ]
  ];
}

When I add another paragraph, the ajax is fired and the selection is still preserved.
I haven't tried with other Ajax fields present though.


Given that Search API/Search API Solr use Drupal core functions for retrieving entity data in order to be database agnostic, and the MongoDB module just adds another database backend for storing items like fields, there wouldn't be a conflict. As long as you stick with Drupal core functions in your custom integration, you should be fine.


the first attempt doesn't contain t() function in set message function... hence it's failing...


What is the difference between the Trigger and Rules modules?

Loosely speaking, Rules is much more generic than triggers. As Johan Falk mentions, "you could say Rules is an extended version of Triggers.. it is technically true, but does not really cover at full extent."


You need not to create different roles for each user but one user role will serve the purpose with help of SUBUSER module.
Though it's in alpha stage for D7 but it has served me well for a project where I am handling organization as users.
You will need to give proper permission though, I hope you can play with that.


How to be able to use a content once in a content field?

Assuming you are using an entity reference (default reference in Drupal 8, and provided by the Entity Reference module for Drupal 7). You can do this with an entity reference view:

Create a new view that lists content of type Country. Then take the following steps:

Make sure to add a new Entity Reference Display.
Enable the title field as Search field in the formatter settings. (Behind drop down menu.)
Add a relation of type Content using field_country.
Filter content that has no value for ID using the relationship.
(optional), if you reference country from more content types than National Anthem, filter also for the Content type to be of National Anthem; again using the relationship.

This view will select all countries, which are used on nodes with no ID. (Thus are not referenced.)

Finally, make sure you enable the view in the content type's field settings:


Why is it considered improper to directly add an `onclick` attribute to an HTML element?

There's a good answer in the JavaScript subreddit on reddit here. To summarise, here are the reasons provided:

  tight coupling between presentation and behavior
  code runs in the global scope
  makes testing and debugging difficult
  defies progressive enhancement
  quickly becomes hard to maintain
  also it will unbind any previously assigned click handlers which might be an unwanted side effect

Maintainability and testability are the major killers for me here.

There's not much more to add to give a Drupal specific answer. The only two things that comes to mind are the following:

Behaviours are automatically re-applied to any content loaded via AJAX, so if you have an AJAX powered view the click handler will be rebound for you without having to have the function in the global scope.
You don't have to try and locate templates, or hack away at anything just to add a new attribute to an element. For example, if you want a click handler on a node title link, you have to update the template. If you then add a new view mode, but still want to have the click handler listening, then you need to ensure the onClick is on that element as well - this increases the maintenance time and risk of error. If you just use a behaviour, then you can hook onto the title link class and it'll work everywhere.


As the module page desription says development of this module has been stopped in favour of @font-your-face

@font-your-face is widely used now and has decent documentation, so you should use this one instead of Google font.

Module page description,

  IMPORTANT: I've decided to combine forces with @sreynen, the
  maintainer of the magnificent @font-your-face module. That modules
  does not only support Google Fonts, but also several other font
  providers and combines all those fonts in a very user-friendly
  interface. I will not improve the Google Fonts API module anymore. So
  please switch your site to (the 7.x-2.x version of) @font-your-face in
  favor of Google Fonts. Thanks ;)


I want to show a progress bar during form is submitted and processed until submission is created

The easiest way would be to use the managed_file field type and set the #progress_indicator property to 'bar'.

More details are given in this Drupal Answers answer...


Facebook Comments Widget disappears for logged in users

This bug, in the end, was a MODERATOR specific bug in the Facebook Commenting widget itself. FB has now fixed it.


Check out Subscriptions.

  This module enables users to subscribe to be notified of changes to nodes or taxonomies, such as new comments in specific forums, or additions to some category of blog. Once enabled, all nodes will have an additional link that allows the user to change their subscriptions. Users have tab on their user screen to manage their own subscriptions. Users can also set an auto-subscribe function which notifies the user if anyone comments on posts they have made. Admins can turn this on by default.

It provides a very powerful and flexible subscription framework, and there are many ways to configure subscriptions with this module.

One that probably will match your use case is to use taxonomy terms for the type of movie (comedy, horror, action, etc.) and let the users subscribe to the type of movie they're interested in by taxonomy term.


How to force Drupal search.module find "111-222" page by searching "111 222"?

Looking at the API for search, it would seem that hook_search_preprocess will allow you to alter the way keywords are extracted, something like this:

function mymodule_search_preprocess($text) {
  return preg_replace('/(\d+)-(\d+)/', '$1 $2', $text);
}

I haven't tested this code, it's purely meant as a sample. It assumes your "words" are all digits as per the question.


A module or solution to build first time user walkthrough?

The jQuery Joyride module would certainly be an option

  This module provides Drupal integration with Zurb's Joyride Jquery plugin in order to provide a tour of different html elements on your Drupal site. Drupal integration is done via the Context module, which provides a way to control conditional calling of the joyride plugin and copy-and-paste method for adding specific tour code.

It wraps around the excellent jQuery Joyride plugin


How to hide a Fivestar field in a comment when the user didn't vote?

You could try an approach like this (untested) but may work

/**
 * Implements hook_comment_view
 */
function hiderating_comment_view($comment) {
  if($flag = flag_get_flag('reaction_on_own')){
    // Debug comment to find field to hide, check dblog / watchdog
    debug($comment);
    if (!$flag->is_flagged($comment->cid)){
      unset($comment->field_stars);
    }
  }
}


How do I alter a way node is rendered so I can add custom links/buttons?

The easiest way to do this would be to use Content Templates!

Using this module you can have some fine-grained control over how templates and individual fields are displayed without actually creating a new .tpl.php file for that node (which is another pretty good much more laborious solution)


Programmatically Set Default Text Editor

Below code is used in wysiwyg_profile_form_submit() at wysiwyg.admin.inc. You can make use of it.

// Insert new profile data.
db_merge('wysiwyg')
  ->key(array('format' => $format))
  ->fields(array(
    'editor' => $editor,
    'settings' => serialize($values),
  ))
  ->execute();
wysiwyg_profile_cache_clear();

Another approach is using drupal_form_submit() to submit its settings form programmatically. But it would be more compliated.

Also, before settings the profile, you need to check if tinymce is existing.

if (wysiwyg_get_editor('tinymce')) {

  // set profile.

}


Came across this question trying to resolve a similar migration error -- try using the Drush command line tools instead of the UI and use the -d flag so it shows all of the errors during a migrate command, ex:

drush -d migrate:status


How to display all values of List (text) instead of just the selected ones?

Even if no one here says they have needed to do that you can pretty much bet others out there have, so it's good that you have your code on drupal.org where other can use it if they need it.

I had a quick look over your code and your solution is the way I would do it: create a new field formatter for text list fields using hook_field_formatter_info() and hook_field_formatter_view().

A couple of things I notice though are:

The name of the module is very long. If you can make it shorter while still being somewhat descriptive I think that would be good (also better for you as the coder).
The markup you are outputting is not themeable, so if other people start to use the module and want to override the markup in any way it is harder for them. See image_field_formatter_view() as an example of creating a render array with a specific theme function. Also see hook_theme() for defining your own theme functions.
Text that gets displayed to the user that is hard coded into the module should be run through the t() function so that others can write translations for your module. See the drupal 6 version of that t() api docs page for better and more thorough information. t() is not currently used is for $form['instructions'].
This one is a bit more of a personal choice but I would probably make the  markup options a lot less than 500 characters. I would also quite possibly not allow HTML markup and just allow them to enter characters that would then display in a span. If the user wants something fancy they can override the theme function (as per point 2). Also, the instructions encourage users to use inline styles, which are not recommended. Users should use the classes you provide to add any css in their theme's css files.


Taking a blind guess: Your context matches the entire parent container, so you can't filter by "new ones only" with context. But as a workaround you could specify a more explicit find to filter only new ones:

This will add .i-was-here-first to every views row present on document ready:

 $(document).ready(function($) {
    $('.views-infinite-scroll-content-wrapper').find('.views-row').addClass('i-was-here-first');
});

Now use that class to filter sub-sequent behavior calls by using a more explicit find():

Drupal.behaviors.testing = {
    attach:function (context, settings) {
      $('.views-infinite-scroll-content-wrapper', context).find('.views-row:not(.i-was-here-first)').addClass('i-was-here-second');
    }
};

Side note:
I'd recommended not to use $(document).ready() at all in Drupal because this might cause problems when using BigPipe module, which is active by default. Drupal will initially trigger all behaviors with document as context, so you should use something like this instead:

Drupal.behaviors.instead_of_document_ready_do_this = {
  attach: function (context, settings) {
    $(document, context).once('my_unique_name').each( function... );
  }
}


How to render author custom fields info on comment and node twig template?

For Node:

{{ node.getOwner.field_first_name.value }}
{{ file_url(node.getOwner.user_picture.entity.fileuri) }}
{{ node.getOwner.uid.value }}

For Comment:

{{ comment.getOwner.field_first_name.value }}
{{ file_url(comment.getOwner.user_picture.entity.fileuri) }}
{{ comment.getOwner.uid.value }}


Saving existing node doesn't update automatic alias

Have you checked your settings at "admin/config/search/path/settings"?
There you can config what to do with your alias, when an entity is updated.


How can I get $_POST data in a callback?

They access $_POST in the same way other functions do.

Take file_ajax_upload() as example; it contains the following code.

  if (empty($_POST['form_build_id']) || $form_build_id != $_POST['form_build_id']) {
    // Invalid request.
    drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
    $commands = array();
    $commands[] = ajax_command_replace(NULL, theme('status_messages'));
    return array('#type' => 'ajax', '#commands' => $commands);
  }

The function is a page callback defined in file_menu().

  $items['file/ajax'] = array(
    'page callback' => 'file_ajax_upload',
    'delivery callback' => 'ajax_deliver',
    'access arguments' => array('access content'),
    'theme callback' => 'ajax_base_page_theme',
    'type' => MENU_CALLBACK,
  );


You can use the Commerce Migrate  and import your orders, and Feeds to import users.

From Commerce Migrate project page:

  Commerce Migrate is a general-purpose migration framework extending
  Migrate Module for bringing
  store information into Drupal
  Commerce.

Also, there is a thread about this here.


Edit the "Content" view.
Add "User - Content revision" in Relationships under "Advanced" tab.
Add "Name - User" in the fields using the Revision user relationship. You can set a label for this field as "Last modified by".


Exposed filters do work in 8.0.2, although there are limits of to how well you can format or alter them.

But you want to do should work fine.  Looking at your uploaded image, though, suggests you don't quite have it configured right for what you want to do.  I'd recommend that you leave "Value" blank, and choose "Contains" as the operator. Under "Advanced", check "Use AJAX". Once you "Apply" to the display, you'll see a preview at the bottom of the view edit window.  If you start typing the name (i.e., title) of one of your nodes, you'll see that the list of nodes at the bottom of the window indeed updates as you type.


Menu item with update text (title) in real time

This is how I solved a similar problem:

You need implement the hook_menu() and use the 'title callback'

function YOUR_MODULE_menu() {
    $items = array();

    $items['perfil-usuario'] = array(
        'title' => 'perfil',
        'description' => t('User Profile'),
        'title callback' => 'change_title_profile_link',
        'page callback' => 'go_to_profile',
        'access callback' => 'user_is_logged_in',
        'expanded' => TRUE,
        'weight' => 100,
        'menu_name' => 'main-menu',
        'options' => array('attributes' => array('class' => array('perfil-usuario'))),
        );

    return $items;
}

In this function you can change the link title

function change_title_profile_link() {
    return rand();
}

Here you can redirect to the desire url, if the url change you can implement this function

function go_to_profile() {
}


Get the user location during registeration process

In Drupal 6, the obvious answer would be use the Location and Gmaps or OpenLayers module. I've used it on many many sites and it generally works well. Another very good alternative in Drupal 6 that I just found now is HTML5 user geolocation, that looks awesome and its what drupal.org uses!

However if I was using Drupal 7, I would definitely use the Geolocation Field module. I've tried it out and its really awesome and easy for users.


Content type permissions are not working

make sure you have proper permissions assigned.Try rebuilding the site permissions.

If it still does not work try disabling individual permission based modules and rebuild site permission each time you do so and check.

You can also try using the devel node access module which gives a block which is placed below each content.


You have to delete those duplicate alias by going to the alias list at admin/config/search/path (in Drupal 7). It's not an automatic task, I'm afraid.
Or you can delete all alias and bulk recreate them using the Bulk Update function. That would be an automatic process.

As a last step, you should check Alias Settings at admin/config/search/path/settings. I think you should change the "Update action" to "Create a new alias. Delete the old alias.".


I'm assuming this question is about D7 ...

Step 1

Start with creating an extremely basic Rules Component with a Rules Action to unflag (using the Flag module) a user, whereas you specify the user to be unflagged as a parameter for that Rules Component. And you pick one of the 3 flags you want to process (eg the "annoying"-flag).

Optionally include whatever Rules Conditions you might need (if any, eg to check if the user is flagged). FYI: this is really like a getting started with Rules ...

Step 2

Use the view of flagged user that you already have and transform that view into a view that uses Views Bulk Operations, and use the technique documented in "How to use Rules to create a custom bulk operation for a VBO view?".

In doing so, you'll then be able to use Rules Components (using the Rules module), in which you can then include the required logic to unflag a single user. I.e the Rules Component from Step 1.

Step 3

Use the checkmark in front of each user in your VBO view as the "button in front of each user to clear that flag" (as in your question), and select the custom VBO action that you created in Step 2.

Step 4

Repeat the previous steps for your additional flags, i.e. the "offensive"-flag and the "fake"-flag.


Follow the following steps to add the bootstrap:

1. Put the bootstrap theme in the theme folder.
2. If you want to create a sub theme then copy the cdn folder from starterkits and rename. (themename)
3. Rename .info.yml , .libraries.yml and .theme files with your themename.

Include the CSS in theme.libraries.yml file. Like below

global-styling:
 css:
  theme:
    css/style.css: {}

global-scripting:
 css:
  theme:
   js/script.js: {}


if migration sounds too hard ...

install and config
https://www.drupal.org/project/default_content_deploy

then

"drush default-content-deploy:entity-list"

to see a list then:

"drush default-content-deploy:export taxonomy_term"
"drush default-content-deploy:export node"
"drush default-content-deploy:exportcomment"

copy the exported files to your next site, make sure the nodes taxonomy_terms and comments have same field structure (can do this by exporting / importing config or look at features module)

after that import your content.

   "default-content-deploy:import"

again make backups of your "new" database before this though !

extra bonus use version control on the exported content .. that way developers / live sites can share the content easily.


Using '#type"=>'container' to create a div wrapper around nested elements?

I was able to obtain what you wanted using the following code.

  $page['page_bottom']["notices"] = array(
    '#type' => 'container',
    '#attributes' => array(
      'id' => array('notices'),
    ),
  );

  $page['page_bottom']["notices"]['notices-placeholder'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'id' => array('notices-placeholder'),
    ),
  );

  $page['page_bottom']["notices"]['notices-tab'] = array(
    '#markup' => '
NOTICES &nbsp;10
',
  );

The output I obtain using that code as implementation of hook_page_alter() is the following.

NOTICES &nbsp;10

I tried using your code, and setting $page['page_bottom']["notices"]['#tree'] to TRUE, or setting $page['page_bottom']["notices"]['notices-placeholder']['#type'] to 'markup', but I always obtained the same result as you.

The only explanation I have is that, using your code, theme_container() (the function defined as theme wrapper for the "container" element) doesn't get any value for $element['#children']. That would explain why the container HTML output doesn't contain any children element, as the code executed by theme_container() is the following one.

  $element = $variables['element'];

  // Special handling for form elements.
  if (isset($element['#array_parents'])) {
    // Assign an html ID.
    if (!isset($element['#attributes']['id'])) {
      $element['#attributes']['id'] = $element['#id'];
    }
    // Add the 'form-wrapper' class.
    $element['#attributes']['class'][] = 'form-wrapper';
  }

  return '
' . $element['#children'] . '
';

References

system_element_info()
drupal_render_page()


Patch a contrib module with a patch that contains new files

I would recommend you consider switching to composer and composer-patches. I don't think drush make is still actively maintained?

Quick google search pointed me to http://www.anexusit.com/blog/how-to-apply-patches-drupal-8-composer for example. That works fine, also for patches that add new files. The only case where that is a problem is core, due to different path structures in drupal/core and then it doesn't apply it correctly.


Seemingly random  being added into views node header for content type

<h3> in the views-view-unformatted.tpl.php is outputted only if you use Grouping setting in your view. So commenting that out is a bad idea.

Looking at your markup I can say with confidence that h3 is produced by either one of the following templates:

node.tpl.php
node--news_story.tpl.php
node--product.tpl.php

Good point was made by rhuffstedtler, about checking which template is producing the markup.

find settings.php file and uncomment the line (usually last line) that says:

$conf['theme_debug'] = TRUE;.

Then refresh your page and check the source HTML code. You'll figure out from there which template you should be modifying.


Views filter has taxonomy term in whole vocabulary

I've reached this question while looking for something similar and couldn't find anything relevant. Yet, after searching trough views options, I've managed to achieve something I think is the easiest workaround to our mutual issue, which is why I'm resurrecting this question.

First things first, I've created a View to show all the  taxonomy terms of certain vocabulary and replaced the output as a link to, say, /disciplines/[Term ID]. Afterwards, I've created a view to replace the taxonomy display page and defined the term id as a contextual filter to the url(using the % replacement). Now every time the admin creates a new taxonomy term, the first view will always redirect to the second one with all the good stuff Views can offer.


You can change the way the language is added to the url. For the Russian language (your default language), you can remove it completely from the url by setting the path prefix to empty value.

This can be done under admin/config/regional/language/edit/ru, set empty value on Path prefix language code.

Theoretically you don't need to have custom code the generate URL (with language checks), just let Drupal handle the url generation.


The date format was being set via the Operating System. OS X's default language and text preferences was re-formatting all dates I type.

With OS X 10.8.3 the preferences are on "System Preferences >> Language and Text >> Region >> Dates >> Customize." There, you can enter your preferred date format.


drupal removes language key from variables in templates

Once you are logged in, another language is requested and the 'und' key no longer works:
https://www.deeson.co.uk/labs/programatically-access-field-data-using-entitymetadatawrapper-drupal
Try replacing your use of $vars['und'][0]['value'] with Entity metadata wrappers. More examples here: https://www.drupal.org/documentation/entity-metadata-wrappers