Your lacking some code.

Try changing your code above with:

 $query_bank = db_select('bank', 't1',array('target' => 'import'));
 $result = $query_bank
   ->fields('t1',array('bankID','bankname'))
   ->execute();

 foreach($result as $value){
      *$options_bank[$value->bankID] = t($value->bankname);
 }

The import keyword above is your database settings. It must be declared in your settings.php. Assuming  you are using an external database where your bank  table is located, It must look like the code below:

$databases = array (
    'default' =>
        array (
            'default' =>
                array (
                    'database' => 'Name of Your Drupal Database',
                    'username' => 'Username of Your Drupal Database',
                    'password' => 'Password of your Drupal Database',
                    'host' => 'Host of Your Drupal Database',
                    'port' => '',
                    'driver' => 'Driver of Your Drupal Databas', //It can be mysql/pgsql depends whether you are using Postgres or Mysql
                    'prefix' => '',
                ),
            'import' =>  // This Part is where your database that contains `bank` table should be declared.
                array (
                    'database' => '',   //Fill it up according to your database settings.
                    'username' => '',
                    'password' => '',
                    'host' => '',
                    'port' => '',
                    'driver' => '',
                    'prefix' => '',
                ),
       ),
);

For more clarification, please refer to this link.


Separating your tpl.php files in that manner won't improve your site's performance in the way that you hope, unless your current base node.tpl.php file is doing something really weird right now.

Loading more tpl.php files in a single page generally makes things slower not faster, as more hooks are invoked for preprocessing, etc...

Chances are, that if you have a 1-pager the tpl.php file being processed is not slowing your site down. It will be something in the database layer or excessing php processing, or incorrect caching setup.

If you still really want to do it, try Nikhil M's link to get the template naming suggestions.


REST response gets cached for guest user requests

This is probably the page cache for anonymous users, which works independently from the dynamic cache.

You can disable it with this command:

\Drupal::service('page_cache_kill_switch')->trigger();

You can trigger this anywhere in your code and it will be valid for any response  you send for the request. So this should also work for a REST response.


How to create a custom table containing data to be rendered using the Views module

Data module helps you model, manage and query related sets of tables.
The Data module provides

an API for dynamically allocating tables for single-row records.
an API for insert/update/delete operations and describing how tables join to each other.
automatic views integration.
a way to export table definitions to code.

Also next patch in "Describe and use external database tables using Data." allow use external DB tables to show on Views.


What's the correct way to install Drupal with Composer if I want to work on core issues?

I am not sure if there really is a correct, or best way.  All of the core devs I have interacted with have their own setup that works best for them.

My general setup is

directory per remote branch: right now I have drupal-8.8.x, drupal 8.9.x, and drupal 9.0.x
git branch for each patch that is in the issue-comment form: 3113284-02, 3113284-04)

I do this because I have a bunch of shell scripts for installing, cleaning, diffing, generating patches, running tests, etc.  All of these scripts get ignored.

As far as drush goes, I keep a global install and checkout a tag periodically.  I then have a .envrc in each branch directory to $PATH everything correctly.  This prevents changes to composer.json.

However, there are some things you can try. A while ago, running tests locally with certain PHP versions meant updating phpunit via a post-composer script.  You then had to restore composer.json and composer.lock before running a git diff ... to generate a patch/interdiff.  You can do the something similar with drush:

git pull origin/8.8.x
composer require drush/drush:^10
git checkout composer.json composer.lock

The above approach is on my short-list for updates to my scripts.


How to call drupal_bootstrap from custom file in subfolder?

take a look at http://drupal.org/project/js they implemented a custom js.php that bootstraps drupal.

/**
 * @file
 * Callback page that serves custom JavaScript requests on a Drupal installation.
 */

/**
 * @var The Drupal root
 */
define('DRUPAL_ROOT', getcwd());

/**
 * @} End of "Required core files".
 */

/**
 * @name Required core files
 * @{
 * The minimal core files required to be able to run a js request
 */
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/includes/module.inc';
require_once DRUPAL_ROOT . '/includes/unicode.inc';
require_once DRUPAL_ROOT . '/includes/file.inc';
/**
 * @} End of "Required core files".
 */

// Do basic bootstrap to make sure the database can be accessed
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);


Instead of returning a single render array (of all or part of your form) from your callback, you will need to return an AjaxResponse that contains a  ReplaceCommand for each piece of the form you want to replace:
For example, in your callback:
$response = new AjaxResponse();
$response
  ->addCommand(new ReplaceCommand('#edit-form-factor', $form_factor_element))
  ->addCommand(new ReplaceCommand('#edit-model', $model_element));
return $response;

See the guide:
https://www.drupal.org/docs/drupal-apis/ajax-api/basic-concepts#sub_form
And the Ajax commands reference:
https://www.drupal.org/docs/drupal-apis/ajax-api/core-ajax-callback-commands


Dynamic Views Pages - How to add in meta tags to these generated pages?

The metatag module comes with 'metatag views'. Enabling this module you with have a metatag settings on the metatag config page (admin/config/search/metatags).

I am not sure what meta tags you are referring to but I will give you an example.

I am using the view that overrides the default taxonomy term pages. To set the description meta tag for this view I put '[view:description][current-page:url:args:value:1]' into the metatag setting for views.

If you are worried about the keyword metatag I would not bother as they ont seem  to impact seo anymore, and I don't know of an easy way to set this dynamically for views.

You may also want to check out the metatag views overview module which has a confusing description but may help you.

Also, take a look in the file 'metatag.api.php' in the metatag module for something that you could use.


Overriding a View table layout in module

The easiest way to theme views is to edit the particular view in question and scroll down to find the link 'theme information'. This screen will tell you exactly what views theming templates that it is currently using and what templates you can make in your theme to override this output.

That essentially all views theming is - overriding the default markup with something to suit you designs.

@see http://www.group42.ca/theming_views_2_the_basics for an excellent tutorial on views theming

EDIT

If you want full control over the markup produced, and for this to be portable across themes, the only option you have is to create a custom module. This custom module could also have themeable components, and could even use a view to perform any heavy SQL (or you could just hand-write the SQL)

Take a look at a similiar module to get you started, and have a read through hook_theme


Your event subscriber is also picking up AJAX requests (e.g. /admin/coffee/get-data is an endpoint the Coffee module uses when it's needed in the client browser) which explains why you're seeing multiple events for a page request.
You can filter out those events with the logic best fits your needs (e.g. a $request->isXmlHttpRequest() call to check for AJAX requests, or a route whitelist as you mentioned).


Found that it's better to clone the view to export it as usual than edit default one.

There's also an "export" button on the view definition page that can be used to copy-paste definition manually.


The way you've structured the logic, your function will return "user is logged in" as long as your credentials are correct, not if the user session was created (i.e. the user logged in). Your subsequent error about an uninitialized session confirms that a session isn't being created (i.e. an entry being inserted into the sessions table) or your session key/cookie isn't persisting on the subsequent logout call.

You need to debug why this isn't happening. Check the drupal_session_regenerate() function call to make sure a session entry is created and that your browser/client is receiving SetCookie header with the newly created session key. If the session is created, you need check why your browser/client isn't storing and persisting the session key made on your subsequent logout call.


Count how many children have a reference to the parent

Second problem: the views results will only include published entities if you add the filter: Published (= True).

It's a lot more difficult if you want unpublished node to show in view results, but not be counted.

First problem:
The easiest way to solve this is by using the Summary option of a Contextual filter.

List the Child nodes in your Views, then add the Contextual filter for the Entity reference field to the Parent, and set it to display the Summary (adjust Validation and other options to your needs).

The Summary will list the Parents links, with the Children count next to them. When you click through the Parent links you will see the original Views Children list (but only for that clicked-on parent).

Don't forget the base path if the Views Display you're working on isn't the first Page Display in your Views.

The Summary also gives you the option to sort according to the Count :)

Your Contextual filter options should looks something like this:

When the filter value is NOT in the URL
Display a summary
Sort order: Descending
Sort by: Number of records
Format: List
Display record count with link

̣̣̣̣̣̣̣_______________

Alternativelly you could count with the Agreggation option (under Advanced settings). You would count the children title field for example, their Entity IDs, while grouping the Parent reference field.


I think you used to have 1 ID before and that you added the second ID after you ran the migrations?

If your migrations aren't in prod, you can simply delete these tables and try again:

migrate_map_recipe_daily
migrate_message_recipe_daily

I think it should work.

If your migration is in prod, you might have to:

Create a sourceid2 column matching with your ID type
Update the table keys to consider sourceid1 and sourceid2 as composite keys

I have tried the first one many times.


How to make submenus appear on hover regardless of what page you are on?

Edit your Menu Link and make sure Show as expanded is checked.

  If selected and this menu link has children, the menu will always
  appear expanded.


How to use EntityFieldQuery with a simple text field?

From the canonical reference on EFQs,

  ->fieldCondition($field, $column = NULL, $value = NULL, $operator =
  NULL, $delta_group = NULL, $language_group = NULL)

  These conditions are specific to a field implementation.

  Looking at the body field in the article node type, a field condition
  would look like this:
  ->fieldCondition('body', 'value', 'A', 'STARTS_WITH')

  field name. Though the field table in the database is named 'field_data_body', the actual field name is 'body'. This is in the
  field_config_instance table.
  column. This is the column in the database that should be matched, with field name prefix removed. For body field, the database columns
  are: body_value, body_summary, body_format, and language. 'value',
  'summary', 'format', and 'language' are the actual arguments you would
  use. Likewise an image field would use 'fid', 'alt', and 'title' as
  column names; an entity reference field would use 'target_id' and
  'target_type' as column names.

So, your syntax is correct, assuming your field name is correct (you want the machiine name), and your column is correct.  Text and Longtext fields both use "value".  You can verify this by looking at the database itself.

If your field name is field_bar, there will be a table called field_data_field_foo.  Look at the columns.  You should see one called field_bar_value.


How may I curtail or minimize the text below CKEditor (while keeping it available for screen readers)?

if you want something interactive, you can do this - this example assumes a field called body working on a node of type article, adjust as necessary:

in css, for .page-node-add-article .field-name-body .filter-wrapper .fieldset-wrapper { display:none; } - this will initially hide the text format
add this JS either in a custom module or in html.tpl.php before , so long as it runs after ckeditor, or the classes won't exist and throw an error:


Exported feature with roles not imported when loading module

You need to un-exclude user permissions first.
Go to /admin/config/development/features > Select your bundle > (Tab) Configure Bundles > Alter (Configure) > Uncheck "Strip out user permissions."
Then recreate the feature.

I've also already been there.


Drupal
When it comes to multiple sites, you should consider what would be effects of managing multiple sites. Having a separate MySQL database for each Drupal site would means that your could do the following without disturbing others

take one Drupal Site offline
load new content into one site
alter contents of one site

Consequences

Upgrading Drupal content for one site may possibly affect others that are still running previous versions
Doing an Upgrade requires a full shutdown of all sites
Features for improving performance of one site (such as Boost Cache) may hurt performance for other sites

MySQL
When it comes to MySQL, you will have to consider one of two things

Using MyISAM Storage Engine
Using InnoDB Storage Engine

MyISAM and InnoDB have strengths and weaknesses.

MyISAM only caches Index Pages
InnoDB caches data and index pages
InnoDB can also be configured to have InnoDB bypass OS caching
InnoDB can be configured to access multiple cores/CPUs
There are some instances where MyISAM can be as fast or faster than InnoDB
As of MySQL 5.5, only MyISAM supports FULLTEXT indexing. MySQL 5.6 will introduce FULLTEXT indexing to InnoDB

Please see my past posts about other Pros and Cons:

May 03, 2012 : Which is faster, InnoDB or MyISAM?
Sep 20, 2011 : Best Of MyISAM and InnoDB
Jun 07, 2011 : How do I convert a database from MyISAM to InnoDB?
Apr 15, 2011 : https://drupal.stackexchange.com/questions/1715/what-would-be-the-optimal-mysql-configuration-for-a-drupal-7-site/2367#2367
Apr 14, 2011 : What are the main differences between InnoDB and MyISAM?


Custom drupal module does not appear on the extend page

There was a preceding issue with installation, I had several drupal projects under Projects folder, the newer project tried to access modules in the directory of the older one. Probably, the paths have somehow mixed, leading to the problems with modules installation and database connection(it was not described in a settings.php file). After the disabling of the previous projects and reinstallation of the current one, everything has been working properly.


How to get the list of values and keys for a given list field

It's just a matter of getting the field basic data, then get a list of possible values using Field API function that is part of List module.

$field = field_info_field([FIELD_MACHINE_NAME]); // This one gets the field data
$field_values = list_allowed_values($field); // This one gets an array of values => labels
$field_key = array_search('red', $show_field_values); // This one gets the key for the value labelled "red", that is: 1


This issue will help you out
http://drupal.org/node/502824


"COPY_ERROR: Unable to copy" while using drush make with download type "copy"

As a workaround, I used the includes[] directive instead.

Here is my working mymodule.make:

api = "2"
core = "7.x"

projects[drupal][version] = "7.39"

; Modules
includes[] = ./sub1/sub1.make


How to retrive menu_get_object() in javascript, jQuery?

There are several ways to go about this.  The most straightforward is use template_preprocess_node , drupal_add_js, and drupal_json_encode.

Something like this:

function mytheme_preprocess_node (&$variables)
{
  $node = $variables['node'];

  drupal_add_js(array(
    'mytheme' => array(
      'node' => $node,
    )
  ), 'setting');
}

The node will then be JSON encoded as Drupal.settings.mytheme.node.  The above is untested, but will be a decent starting point.  Keep in mind that if you have multiple nodes on a page, then this will get called multiple times.  You would need to add some logic to handle these cases.

If you do this as part of themeing, rather than a module via the Node API, then all modules that alter  the $node will have run at that point, so all data should be there.  Personally, I would only add the data that I need.  $node can get pretty big, so adding all of it would be a lot of JS on a page.


What's wrong with my code to overwrite a block template?

You can create a directory called templates/ in your modules root. Place your template here.

Now let Drupal know you store the template in your module. in your_module.module add this function:

function YOUR_MODULE_theme($existing, $type, $theme, $path) {
  return array(
    'block__my_module' => array(
      'render element' => 'elements',
      'template' => 'block--my-module',
      'base hook' => 'block'
    )
  );
}

Finally be careful about where you place your twig file and what you name it. Create a templates directory in your module directory, and replace the _ in the theme function name with -: mymodule-block.html.twig

Don´t forget to clear the cache.

According to answer written by Nicensin in this post: Drupal 8 custom block (module) create twig template file


Adding content of products based on subtype

Lets start by saying that content types are not meant to be used for grouping. Drupal content (nodes) come with permission checking and invoke a lot of hooks upon loading. That is not bad per sé (and in fact required for most content), but is overkill for grouping. Your parent child structure would involve 3 node loads where you want to display one.

If you need grouping, you need taxonomy. This offers almost the same functionality as content types with regards to fields and url aliases, but is much lighter in use. To start you could recreate your reference structure using taxonomy terms.

However, as I already explained in the comments, why not use nested taxonomy? You could place all your categories in one taxonomy vocabulary, allowing you to see, edit and rearrange all terms from one page. It would make your system much more maintainable. Also the fact that you state that you need second level terms to show up after selecting the first is possible. Have a look at Hierarchical Select, Simple hierarchical select and Client-side hierarchical select. These offer exact that functionality.

Your last requirement (if there is more please edit them into the question):

  I need to list category and sub category separately

Depending on how you want to achieve this, is can be done. With views it is very easy. Add a filter to the view, select the parent term, then select that it should be empty. It should give you a list of top level taxonomy terms.


Make certain pages available to logged-in users only

You need to use Content Access module for fine grained node view permissions.

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


How can I track how embedded media is used across my site?

First, there is a core issue to eventually get this into core.

Now, the best way is to use the Entity Usage module, which can handle tracking of media and many other cases.

Hats off to the module maintainers-- this is all I needed to do to implement my use case:

Download the module with composer.
Enable the module.
Go to /admin/config/entity-usage/settings and check Media under Enabled local tasks.


Is there advantage to using Drupal.settings, as opposed to directly passing json-encoded var to javascript function

The advantage of having in Drupal.settings is the values can be globally accessed across the JavaScript functions. In your case the function "my_js_function" only can access it because of its scope. It is based on the need and if you feel it is unnecessary to have it in settings then you can go with your method.

But best practice is to use Drupal settings. This method will never fail you.


show product reference field with both add to cart and render product display format

oh very easy i do it with template just create new template node--product--type--full.tpl.php  .

and use this

<?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);

      $options = $node->field_product[$node->language];
      foreach($options as $index => $option){
      $cmp_btn = drupal_get_form('properties_compare_add_form_' . commerce_product_comparison_create_key('commerce_product', $option['entity']), 'commerce_product', $option['entity'], $node->nid);
      $content['field_product'][$index]['commerce_product'][0]['cmp_btn']=$cmp_btn;
      $content['field_product'][$index]['commerce_product'][0]['cmp_btn']['#attributes'] = array('class' => array('compare-form' . $option['product_id']));

      }
      print render($content);
    ?>

i remove the add to cart button in view an set the display to render product


Have a look at the Flex Slider module. It provides this functionality, but you might need to theme it a little bit. A screenshot similar to what you want is below. Note that you are not limited to pictures, but you can use any type of content in the display.

It is quite a hassle to start with at first, but I found these youtube videos very valuable:

Basic set-up instructions: https://www.youtube.com/watch?v=MboDby9-PCE

Theming guide: https://www.youtube.com/watch?v=-Jukg7UlSZA


I would use the CiviCRM views integration to create views of the events, and ensure that these are searchable by using the Search by Page module which according to the project page "allows you to index non-Node pages, including user profiles, file attachments, and Views".


How to get the hard coded string as output in views_php module

Value Code : The value of the Field.

Output Code : The php code that you wish to execute for getting the output for that field.


How to link the parent of a Nice Menu to nowhere?

Yes you can do that using the Special menu items module:

Special menu items is a Drupal module that provides placeholder and separator menu items.
A placeholder is a menu item which is not a link. It is useful with dynamic drop down menus where we want to have a parent menu item which is not linking to a page but just acting as a parent grouping some menu items below it


Hide columns depending on checkbox state with Javascript

#states is a good JavaScript only approach to hiding simple markup, but sometimes we need to modify the render array itself

To add/remove form elements or complex render arrays based on feedback, you can do so by checking the value of $form_state['values']['my_fieldset']['my_checkbox'] in a condition around your table column logic. Also wrap the other_fieldset with a div defined in #prefix and #suffix that has that wrapper id.

if (isset($form_state['values']) && $form_state['values']['my_fieldset']['my_checkbox']) {
  // Add slot1/slot2 columns here.
}

Then add an AJAX/AHAH to the checkbox element:

$form['my_fieldset']['my_checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => t('my title'),
    '#default_value' => 1,
    '#disabled' => FALSE,
    '#ajax' => array(
      'callback' => 'my_module_form_ajax_callback',
      'wrapper' => 'other-fieldset-id-wrapper',
      'method' => 'replace',
      'effect' => 'slide',
    ),
);

Then implement a function to return the form element you want to replace. Note that you do not modify the form/form_state here and modifying the form will have no effect. However the value of the checkbox will be stored in form_state values when the form is re-rendered.

  function my_module_form_ajax_callback($form, $form_state) {
    return $form['other_fieldset'];
  }


How to use hook_form_BASE_FORM_ID_alter() to save variable?

return system_settings_form($form); will do nothing in this context. An alter function like this has no return.

What you should do if you want to save the value is add a submit handler into the form instead:

function MYMODULE_form_node_form_alter(&$form, $form_state) {
   $form['additional_email'] = array(
      '#title' => t('Additional E-mail'),
      '#type' => 'textfield',
      '#default' => variable_get('additional_email', $email_default),
      '#description' => t('If you would like to notify an additional person, please supply the e-mail address.'),
   );

   $form['options']['additional_email'] = $form['additional_email'];
   $form['options']['additional_email']['#title'] = t('Additional Notification');

   $form['submit'][] = 'mymodule_submit';
}

function mymodule_submit($form, $form_state) {
  if (isset($form_state['values']['additional_email'])) {
    variable_set('additional_email', $form_state['values']['additional_email']);
  }
}

This adds a new submit handler to the form, which will trigger upon submit. If a value was supplied, it will set the variable.

What is $email_default? That is never defined.

However I would suggest a different approach, because:

Variable can only hold one value, and this form item exists on every node. Every submission with a value will override the previous.
Rules can read fields, why not add an email field on the node, and use that in the Rule
You should do extra validation on the entered value to make sure it is a legit email value and not just any string with valid_email_address
You can default the email field to be the $email_default you are checking for
You could add cardinality for the email field and adjust the Rule if multiple people need to be notified

If you didn't use a custom form field, and instead added a real field on the node, you could ensure that any node can have any email address without relying on variable_set which as stated, will only ever allow one value to exist.

Rules is able to inspect your node and fetch a field value from it in order to use as a data variable in a later action, in this case, to send an email. If you do that, you don't really need any code at all.


The title of your question is.

  Views module doesn't call hook_node_view() when set to display fields

That is working as intended. The reason is that it's not a node that's being rendered, but just a bunch of fields and attributes that belong to a node that is being rendered.

One way of fixing hook_node_view not being called, would be to actually render the nodes.

If the problem is that the field is not rendered as you which, the best way of dealing with that, would be to alter the rendering of the fields, instead of trying to make Drupal act like you're rendering a node when in fact you're not.

The easiest, cleanest and most flexible way to do that, would be to create some custom field formatters for the fields in question. Field formatters are like theme functions for the fields, and you can in views select which field formatter to use when you want to render a field. It requires some work, but gives great flexibility. That would make your hook_node_view obsolete as you can use field formatters when fields are rendered under the manage display tab in the field settings interface.


Drupal 7: Customizing the display of a view

Look into creating your first article display as an attachment.  Attachments allow you to group different views together. This is for Drupal 6 and Views 2, but it should give you some idea of what attachments are.

  A Views Attachment is simply a type of Views Display that gets attached to another View Display (usually a page display or a block display).


How can I make a node title input form in a block?

Use the Prepopulate module, there is an example on the docs for pre-populating the title field. All you need is to have a simple form that appends your $data to this path:

/node/add/yourcontenttype?edit[title]='.'$data'


Drupal 8 admin toolbar z-index value is 502 only, but the bootstrap default static navbar z-index value is 1000, I think, Increase the admin toolbar z-index value would fix the issue,

.toolbar-oriented .toolbar-bar {
 z-index: 1001 /* or more */
}

Place that code in your theme's custom css file :)


Services default functionality for node creation is one by one. If you want to create multiple node at once then you should write your custom service using hook_services_resources(). You can find some example about how to write custom service Click Here


What cause my 404 error for my user_picture thumbnail in template file?

In hook_preprocess_html() add the following code.

  $user = user_load(\Drupal::currentUser()->id());;
  $variables['user_pic'] = $user->user_picture->entity->uri->value;

In your template file use code similar to the following one.

If you want to apply an image style, use the following code in hook_preprocess_html().

$variables['user_pic'] = ImageStyle::load('thumbnail')->buildUrl($user->get('user_picture')->entity->uri->value);

In the template file, use the following.


If you are working on Drupal 8, create a twig like html.html.twig in your themes templates folder and the put your script in there.

<!DOCTYPE html>
<html{{ html_attributes }}>
<head>
    <head-placeholder token="{{ placeholder_token }}">
    <title>{{ head_title|safe_join(' | ') }}</title>
    <script id="mNCC" language="javascript">
    medianet_width = "600";
    medianet_height = "120";
    medianet_crid = "455208315";
    medianet_versionId = "111299";
    (function() {
    var isSSL = 'https:' == document.location.protocol;
    var mnSrc = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/nmedianet.js?cid=8CUWJ3143' + (isSSL ? '&https=1' : '');
    document.write('<scr' + 'ipt type="text/javascript" id="mNSC" src="' + mnSrc + '"></scr' + 'ipt>');})();
    </script>

</head>
<body></body>
</html>


Enable Password and Confirm Password fields in Registration form

I think the LoginToboggan module can do everything you need.

  The LoginToboggan module offers several modifications of the Drupal login system in an external module by offering the following features and usability improvements:

  Allow users to login using either their username OR their e-mail
  address.
  Allow users to login immediately.
  Provide a login form on Access Denied pages for non-logged-in (anonymous) users.
  The module provides two login block options: One uses JavaScript to display the form within the block immediately upon clicking "log in". The other brings the user to a separate page, but returns the user to their original page upon login.
  Customize the registration form with two e-mail fields to ensure accuracy.
  Optionally redirect the user to a specific page when using the 'immediate login' feature.
  Optionally redirect the user to a specific page upon validation of their e-mail address.
  Optionally display a user message indicating a successful login.
  Optionally combine both the login and registration form on one page.
  Optionally have unvalidated users purged from the system at a pre-defined interval (please read the CAVEATS section of INSTALL.txt for important information on configuring this feature!).
  Integrates with Rules module to do various tasks when a user validates via email validation process (see http://drupal.org/node/880904 for an example)


How can I alter methods in ContentTranslationHandler?

There are mainly two ways

1- create a patch https://www.drupal.org/node/707484 then maybe you can apply it using composer patches.

2- override the method in your module by extending the class ContentTranslationHandler


Arranging tab menus created by views module

You can provide a weight while editing the Views tab:
. Higher weights will be moved to the back of the order. But since you cannot see the weights of the other tabs this can take quite a while to get right.

Better is to have a look at Tab Tamer

  Tab Tamer is an administration utility that provides easy re-ordering,
  hiding, and deactivation of tabs and subtabs. You can also rename tab
  labels.


Anonymous users randomly get 404 errors on front page

It looks like it was due to a permissions issue.  I set all files and folders to the correct permissions and it seem to fix the issue.

I also updated to the latest dev version of the mobile tools module.


How do I disable fields for a user account?

With the Field Permissions module you can hide fields per role.

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.

  Features

  Enable field permissions on any entity, not just nodes.
  Role-based field permissions allowing different viewing patterned based on what access the user has.
  Author-level permissions allow viewing and editing of fields based on who the entity owner is.
  Permissions for each field are not enabled by default. Instead, administrators can enable these permissions explicitly for the fields where this feature is needed.


As far as I know they've got to stay within /sites/default/files/webform/ folder as /sites/default/files is the only folder that should be both writable and publically accessible

If you edit the file component you added to your webform you can then specify a folder within /sites/default/files/webform/ that you'd like them to be stored specifically for that form. Look for the "upload directory" field.


This isn't exactly a Drupal question :)

Why not simply clear the form data as soon as you get to the AJAX success point?

Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
    //code starts
    $('#feedback-form').submit(function(e) {
      $('#feedback-form').hide().parent().append('

Please wait ...

');
      $.post("email_us.php",form.serialize(), function(data){
        $('#loader').replaceWith('

'+data+'

');
        $('#feedback-form').trigger('reset');
      });
      e.preventDefault();
  })
}

As far as I can see, if you modify the code like this, it will:

hide the form in preparation to post (no change)
post, and wait for success (no change)
show the success message (no change)
clear the form immediately (modified)

Does this solve the problem, or have I misinterpreted what you need in a big way?

To answer the specific question, it's not clear to me what the problem might be, but I'm suspicious that it's caused by the on event handler being attached inside the $post function's success function. Maybe try moving it outside as shown below:

Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
    //code starts
    $('#feedbackModal').on('hidden.bs.modal', function (e) {
      $('#loader1').remove();
      $('#feedback-form').show().trigger('reset');
    });
    $('#feedback-form').submit(function(e) {
      $('#feedback-form').hide().parent().append('

Please wait ...

');
      $.post("email_us.php",form.serialize(), function(data){
        $('#loader').replaceWith('

'+data+'

');
      });
      e.preventDefault();
    })
  }
}


You can override every single node with its node id, as per your nid it should work with node--302998.tpl.php then also if its not working just enable debug mode so you can get idea how many template name available.

To enalbe debug mode open setting.php $conf['theme_debug'] = TRUE;
 refresh page again and press ctrl + U for view source.
 you will get all the name those are possible with your page.


How can I save form data on a node in Drupal?

In your submit function, you just need to create a node, e.g.

$values = array(
  'type' => $node_type, // Drop in your desired node type.
  'uid' => $user->uid, // Want to set an author?
  'status' => 0,
  'comment' => 0,
  'promote' => 0,
);
$entity = entity_create('node', $values);

To make your life easier, I recommend to use entity_metadata_wrapper:

$ewrapper = entity_metadata_wrapper('node', $entity);

Now, you can just cycle through your form data and add the values to the correct fields of your node:

$key = '<MACHINE_NAME OF YOUR FIELD>'; // e.g. "field_firstname"
$val = '<VALUE TO BE SET FOR THAT FIELD>'; // e.g. $form_state['values']['firstname']
$ewrapper->$key->set($val);

This of course depends on the field type, the above works for example for simple textfields. Finally, if all is set, just save the freshly created node:

$ewrapper->save();


Get username in custom user twig template

The display name is not a field you can configure in {{ content }}. You can get it directly from the user entity:

{{ user.displayname }}

Reference for the php method: AccountInterface::getDisplayName


How do I access my fields in a .tpl file

I THINK you need to be using views-view-fields--myview--block-2.tpl.php to access $fields.


One click upload setting not able to save

why don't you use drupal image field for this. You can use add multiple image with drupal core cck image or you can install contrib module multiple image widget. You can be use to display on page or using views can be display.


If you just want see the $form_values array, I suggest you to install Devel and use the function dsm or even you can use the drupal_set_message with print_r.


How do I see *which user* last updated a node?

Use Administration Views module to replace default content page for admins.

Find new View created by that module and add Relationship -

Content revision: User

Then add field to your View "User: Name" and use that relationship on it. It will show you the username of the User who edited content last.


The problem is that you're adding it to page bottom region, which is above the JS.

What exactly is $token, is it something personalized or is it a global license key/identifier for the whole site? If the second, then use a library alter hook to load it instead.

See https://cgit.drupalcode.org/jw_player/tree/jw_player.module#n129 for example, that dynamically alters the library definition to either load from a CDN with a dynamic url or a local path that can vary based on input from the libraries module.


Pay order only after it been placed and validated

The standard approach here is to use the payment information to create an authorization for as much as you will need assuming the order is to be placed. If it's for $100 of custom merchandise, you authorize a $100 charge on the customer's credit card and then capture it after manual review. This is very typical and in many places a requirement - the idea being you can only authorize payment during checkout and capture it once the order has been shipped.

How the authorization + prior authorization capture flow works will depend on your payment gateway and the methods of payment you're accepting, but most should support this. (I don't have direct experience with Russian payment gateways if you're developing this for a Russian merchant, though.)

In your case, you might just include a message on the checkout form that the customer will see the payment authorization but will not have funds debited from their account until the order has been manually approved by an administrator. There is no automation that I'm aware of in Commerce 2.x core for capturing prior authorizations on specific state transitions, but that's something you should be able to include in your site's customizations module. Again, the exact process there will be very dependent on your payment gateway's API.


Active menu for a node with two different terms

You can adjust the breadcrumb using hook_menu_breadcrumb_alter() in your custom module. There's an answer about proper using of hook_menu_breadcrumb_alter() similar to your use case and with helpful references at https://drupal.stackexchange.com/a/49952/10176


How do I get the price of a line item for the transactions which are already completed?

Yes, Commerce Module does store product amount of past order... You can retrieve using below details...

To get full details of order

$order = commerce_order_load($order_id);
$view_mode = "administrator";
print entity_view('commerce_order', array($order->order_id => $order), $view_mode, NULL, TRUE);

To be more specific

  $order = commerce_order_load($order_id);
  foreach ($order->commerce_line_items['und'] as $line) {
    $line_item = commerce_line_item_load($line['line_item_id']);
    drupal_set_message("<pre>" . print_r($line_item,1) . "</pre>");
  }

There is no chance it gets new price instead of old price since it gets tracked in field_data_commerce_unit_price table in database ... All you need to do is divide by 100 if decimal places are 2 in order line item amount...


You may be able to use Aegir (Hostmaster): https://www.drupal.org/project/hostmaster


How to show html  marks to Views Custom text - field?

I've had similar problems trying to show a  tag. The only way I've been able to get around it is to install the Views PHP module - https://drupal.org/project/views_php - and add the HTML through that

Hope this helps you!


Here is the quick workaround for the issue:
STEP 1: Edit modules/date/date_views/theme/theme.inc and go find line 165.
Change these two lines:
$format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y');
$format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j');

To these two lines:
$format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y');
$format_without_year = variable_get('date_views_' . $granularity . '_format_without_year', 'l, F j');

Note: the only difference is one underscore character added to each line.
Upload the changed file back to your web server.
STEP 2: Go to (YOUR_WEBSITE)/admin/config/regional/date-time/date-views and click Save. If you get permissions errors, try clearing caches.
Before:

After:


Processing forms together for a tree of related entities

This is working now with entity saving logic neatly packaged with the sub-item entity code. Before saving the subitems, I set the value of a hidden element with the parent entity's id. I modified the wrapper form's submit handler array:

    '#submit' => array(
        'wrapper_form_submit',
        'update_subforms_before_save',
        'subform_submit_all',
    ),

First, the wrapper is saved and is assigned an id. Then it updates the subforms with that id. And finally the subforms are submitted. The function to update the subforms is modeled after subform_submit_all():

function update_subforms_before_save(&$form, &$form_state) {

    $wrapper_item_id = $form_state['values']['item_id'];

    if (!empty($form_state['temporary']['subform'])) {
        foreach ($form_state['temporary']['subform'] as $subform_name => &$subform_state) {

            $subform_element = &subform_array_get_nested_value($form, $subform_state['subform_element_parents'], $subform_exists);
            if ($subform_exists) {

                switch($subform_element['#subform_id']) {
                    case 'subitem_entity_form' :
                        $subform_state['values']['parent_item_id'] = $wrapper_item_id;
                        break;
                }

            }
        }
    }
}


WURFL underwent licensing changes a little while back, and I stopped using it.

I either use Mobile Tools if I need all of the features it provides (mainly Panels integration) or I use get_browser directly (make sure you have a recent browscap.ini).

I don't think Mobile Tools has a stable Drupal 7 release, though.

There is also the Drupal Browscap module, which purports to be better than the native version, though, I just manually keep my browscap.ini up-to-date.


The data is serialised and uses an array of named placeholders, so you'll need to use PHP to assemble the full message:

// Get data from the DB, each record stored in $row, then...
$message = $row->message;
$variables = unserialize($row->variables);

$full_message = strtr($message, $variables);


Migrate: What's the difference between prepare() and prepareRow()?

This is all covered in-depth in the Migrations classes documentation provided by the project. Specifically in the Commononly Implemented Migration methods page which says the following and includes further simple example function implementations. From the docs ...

function prepare_row($row)

  The prepareRow() method is called by the source class next() method,
  after loading the data row. The argument $row is a stdClass object
  containing the raw data as provided by the source. There are two
  primary reasons to implement prepareRow():

  To modify the data row before it passes through any further methods
  and handlers: for example, fetching related data, splitting out source
  fields, combining or creating new source fields based on some logic.
  To conditionally skip a row (by returning FALSE).

function prepare($entity, stdClass $row)

  The Migration class prepare() method is called by the destination
  class prepare() method, after it has called all field-level prepare()
  methods and immediately before the destination object is saved. The
  $entity argument is the destination object as populated by the initial
  field mappings and manipulated by the field-level methods; the $row
  argument is an object containing the data after prepareRow() and any
  callbacks have been applied. The prepare() method is the last chance
  to manipulate the destination object before it is saved to the Drupal
  database. It is important to remember that, since it is called after
  the field handlers, fields will be in their fully-expanded forms
  (i.e., in Drupal 7 a text field value will be at
  $entity->field_textual_data['und'][0]['value'] rather than simply
  $entity->field_textual_data).

The Migrate module is a framework which allows you to encapsulate a migration process from a source piece of data to a destination location and configuration. A migration consists of:

define where the data is
define where the data should go
fetch a piece of data (row)
sanitize the data
begin to move the data (say into an Entity)
actually move the data
after moving the data perform additional action(s)

The API provides hooks to affect the data being moved in this life cycle of a migration. By excluding data from the migration via your initial query you're limiting how much control you have over the total data you could move. For sub-migrations you may find this useful. But in a general content migration you would want your migration to be as all-encompassing as possible.


Is there any way to redirect page to front page, if it isn't translated?

To get current node:

$node = \Drupal::routeMatch()->getParameter('node');
if ($node) {
  $node_type = $node->getType();
}

Current language:

$language = \Drupal::languageManager()->getCurrentLanguage();
$langcode = $language->getId();
$language_name = $language->getName();

Check if translation is not available and redirect:

use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;

$translation = $node->getTranslation($langcode);
if (!$translation) {
  $url = Url::fromRoute('<front>', [], ['language' => $language]);
  $response = new RedirectResponse($url->toString());
  $response->send();
}

P.S.: I believe entity query you posted is a simplified version of smth more complex in your logic. Otherwise I see no reason to pass node id to entity query condition to get it back eventually. If you always have just one node use Node::load($id) instead of Node::loadMultiple($ids), and you don't need foreach in this case.


Content Types in Select list using views

I think You can create exposed filter Content: Type which will give users  the ability to select content type.

Then in Fields section add field Content: Type, select "Output this field as a link" and type: node/add/[type].

If You want to display only one "add" link per content type select "Exclude from display", go to Format settings and select "Content: Type" from Grouping field Nr.1's options.


The reason why the color is not showing is because you have this already:

body {
    background: url(images/body.png) fixed;
}

from my_elegant.css.

You have a background image already set. If you want to use a css color then you need to tweak the css for body to something like this:

body {
  background-color: #000;
}

or you can have an image background and a color at the same time:

body {
  background: #fff url(images/body.png) no-repeat center top;
}

If you are using style.css make sure that the file is properly added otherwise it could result to 404 and all the css in that file will not get applied. You can use drupal_add_css() api to add new css file or in the .info of your theme.


How to get historical content having historical date that happened in current week in Views?

I used DAYOFYEAR function.

$startDateNumber = date('z', strtotime("-4 days"));
$endDateNumber = date('z', strtotime("+3 days"));

$query = db_select('field_data_field_historical_date', 'fd');
$query->fields('fd');
$query->where('DAYOFYEAR(fd.field_historical_date_value)>=:startDate', array(':startDate' => $startDateNumber));

$or = db_or();
$or->where('DAYOFYEAR(fd.field_historical_date_value)<=:endDate', array(':endDate' => $endDateNumber));

$nid = $query->condition($or)->execute()->fetchField(3);

if (!is_bool($nid)) {
    print_r($nid); exit;
} else {
    print 'no';
}


For D7, I can see two answer depending on what behaviour you prefer:

VBO has a sub-module action permissions.  Enable this and it creates a permission for each action - see module page.  If the user lacks permission then the action is not even available for them.
If you need more granular permission that depends on the entity, then the "function which performs the action" can enforce it.  For example see views_bulk_operations_user_roles_action.  If the user lacks permission for some of the entities then the action won't take effect for those entities.  However there is typically not really any feedback to tell the user.

For D8, there is ActionInterface::access, see docs.


Did you try changing tab style? I haven't tried Drupal 8. But you can select no style option in tab style for Drupal 7. Which does not apply any CSS to tabs.


How to get children and parent book pages

This is for Drupal 6 but might also apply to Drupal 7.
The hierarchy of a book is created with a menu. When you have the node object in $node you'll get the menu link id of the parent in $node->book['plid']. You can then load the corresonding node with menu_link_load().

As for the children you have to get the menu that represents the hierarchy of your book with menu_tree_all_data($node->book['menu_name']) and then go through that menu to fetch the links you need.


How do I specify the custom template for a theme?

The equivalent in Drupal 7 is $variables['theme_hook_suggestions'], which is initialized in template_preprocess_page() using the following code:

  if ($suggestions = theme_get_suggestions(arg(), 'page')) {
    $variables['theme_hook_suggestions'] = $suggestions;
  }

If you want to add suggestions for the template files to use, you should append new suggestions using code similarly to the following one ($variables is the parameter passed to the preprocess functions):

$variables['theme_hook_suggestions'][] = "page__new_suggestion";

You can also add your suggestions before the existing ones, to be sure the template file you are suggesting is used whenever other template files exist.

array_unshift($variables['theme_hook_suggestions'], "page__new_suggestion");

Clearly if the template file your code suggests doesn't exist, one of the other template files will be used.
It is also suggested to prepend the template filename with the type of the template, in this case with "page__"; the underscores used in the suggested filename are converted in hyphens before to check if that file exists.


When does the core search module become worth using?

It really depends on your situation.

You should use Drupal search core module only when you don't have any performance issues (as it's using database backend), your site is not so complex (in terms of search functionality) or you're not advanced user and you are not looking to make make your site more complex than already is.

Please note that high traffic sites running search queries against the database can affect overall performance especially when the database becomes the bottleneck. Secondly Drupal core search doesn't scale much.

Therefore using Search module from Drupal core it's not adequate when you have thousands of nodes on site. In this case you should use either Search API (with solr backend) or Apache Solr Search modules. Using Apache Solr provides advanced and accelerated search platform which features faceted search (Facet API), searching multiple sites, real-time indexing, dynamic clustering, NoSQL features, indexing attachments and many more. It's a great way to have fast access to big data on a budget. Basically Solr solutions are designed for searching the same way as Search API is designed to replace the core "Search" module.

It's also worth to mention about Elasticsearch as alternative for Solr, but it's topic for another discussion. The decision to choose whether Elasticsearch or Solr really depends on the project requirements and the decision needs to be made by experienced Drupal developer or solution architect.

In overall, Databases and Solr have complementary strengths and weaknesses, so you've to investigate these further depending on your project. However core search has a very limited functionality.

Please find the following chart which shows Drupal core's search performance vs. Solr based on its execution time.

  The results are pretty clear: Drupal core's search takes longer as you put more words in the query. This may seem fair enough, as it makes the searching more complex. But when using Solr you can't barely see any difference at all. It doesn't really matter if you search for 1 or 6 keywords. The response time for a page is almost the same.

  DISCLAIMER: This is not a valid test, and the result is only used here to give a glimpse of what the difference might look like. The results will most likely look different on your environment. You can see the shell scripts I used to perform the test in the document folder I pointed out earlier. All tests were performed on a system where content was using cache.

Please find the following table which is comparison Solr v.s. Relational Database:

See also:

Search API vs Apache Solr Search Integration in Drupal 7?
What are the advantages of using Apache Solr over the core search module?
Solr or database? at stackoverflow SE
Search API documentation at Drupal.org
Why use Solr? at Solr Wiki
Solr's features at Solr
Enlightening - The Dark Art of Solr Search with Drupal at annertech


Not able to assign value to field using form_alter hook

You need to use #default_value:

$form['field_company_subtitle'][LANGUAGE_NONE][0]['value']['#default_value'] = ...


Bulk redirect update from CSV: in code or manually?

You either use hook_update_n as you described. Or, sync down TEST to DEV in pantheon, perform the task there as needed, and then sync the DB/code back to TEST from DEV.

The workflow that works best for you depends on whether your site is accessed alot by users and can have no downtime or disruptions, or if your sites workflow/content is more static.


There are a couple of easy to use modules that will help you manage your URL aliases.  They include,

Pathauto
Redirect
Global Redirect

The first two aliases you have sounds like the 'default' ones.  You may have created (or one of the modules you have installed automatically) created the other aliases.

All the same, you can manage your aliases (and re-directs) using the modules I mentioned.


Is there a module for Drupal 7 similar to OG Membership Expiration?

What exactly do you want to achieve?

Assuming that you want to unsubscribe an user after certain time:

In Drupal 7, OG integrates really well with Rules module. It can fire many OG related action based on the condition / event you set.

You can use Rules Scheduler to schedule the action to be fired.

Furthermore, the OG Role Reference Field can:

Grant a group role on a specific event
Use rules_scheduler to remove a group role after a certain amount of time


How To Wrap Multiple Content Field Items In Li Tag

You can easily theme a multiple value field in the field template.

To do this put a field twig in mytheme/templates:

field--field-track-listing.html.twig

{{ label }}

  {% for item in items %}

{{ item.attributes }}>{{ item.content }}

  {% endfor %}

Here you can change the html markup around each field item {{ item.content }} the same way as you do this in node around the complete field {{ content.field_name }}. This is the concept of nested render elements.


It's based upon the path.  In D6:

page-testpage-get.tpl.php

In D7:

page--testpage-get.tpl.php

(Although D7 might want page--testpage--get.tpl.php due to its love of double dashes :)

All about templates and their suggestions can be found here:

D6: http://drupal.org/node/1089642

D7:  http://drupal.org/node/1089656


How can I make individual nodes fieldable?

You could use something like http://drupal.org/project/conditional_fields but that's all done from a front-end point of view, which means Drupal doesn't really know about your structure.

http://drupal.org/project/properties looks interesting and may suit depending on your needs.

I had a similar issue recently and decided to split up into three separate content types instead of just one.


How can I theme a form "checkboxes" element?

The checkboxes description is not rendered in theme_checkboxes or theme_checkbox. It comes from theme_form_element.

If you want every form element on the site (not just checkboxes) to have the description first, then you could just override and modify theme_form_element.
If you want only specific checkboxes to have this, then you could override and modify theme_form_element to position the description based on a variable (similar to what it already does with #title_display). You could then set the variable when creating the FAPI array.
If you want all checkboxes (but only checkboxes) to follow this behaviour, then you could override theme_form_element as above, and use hook_element_info_alter() and change checkboxes to have the new variable you created appopriately set.

Let me know if you have any questions.


are you inserting "inline images" into your content type body-field (1) or using an image field at your content type (2)?

1) Inline images are inserted with an  tag which is stripped out by the standard text formatter (filtered html). Either use the "full html" formatter or (better) make a new text formatter which includes  tags for allowed html tags. Full html is normally below body field at the content edit form.
To add a text formatter (or edit filtered html) go to admin/config/content/formats/filtered_html and add the  tag (including the bracers) into the allowed html tags field.

2) If you are using an image field try to change the image field formatter to "image" and set format settings to a image style like "medium".

Greetings, krueschi


How to create a rule to send an email to a list of selected email addresses?

Assuming this question is about D7, you can use the Rules module to create a rule like so (in Rules export format):

{ "rules_send_email_to_selected_email_ids" : {
    "LABEL" : "Send eMail to selected eMail IDs",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : {
      "node_insert--article" : { "bundle" : "article" }
    },
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-email-addresses" ] },
          "ITEM" : { "current_email_id" : "Current eMail ID" },
          "DO" : [
            { "drupal_message" : { "message" : "An eMail about this new content with title \u0022[node:title]\u0022 and URL [node:url] will be delivered to [current-email-id:value]." } },
            { "mail" : {
                "to" : "[current-email-id:value]",
                "subject" : "You have new mail ...",
                "message" : "New content was created with title [node:title] ... You can read about it at [node:url].",
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}

Some more details about the above rule:

Rules Event: After saving new content of type "Article" (adapt the type to fit your needs, ie to XYZ).
Rules Action: a "loop" for all selected values of a multi value select list (contain the eMail IDs), with machine name field_email_addresses (adapt the machine name to fit your needs). For each item (= current_email_id), an eMail is created with some subject and message that also contains the title and url of the node being created. Note: this will send 1 separated eMail to each of the selected eMail IDs (there is no way to send a single eMail to all selected eMail IDs).

If you have the Rules UI enabled, you can import the above rule in your own site, after you adapt the machine names of the content type and the field name containing the list of eMail Ids.

After you're convinced the rule works as expected, you may want to remove the Rules Action that displays a message after the node is saved (with drupal_message).

Video tutorial: have a look at the List and loops video which show a similar scenario.


Disable translations update on module enable

I was able to disable update by:

<?php

/**
 * Implements hook_module_implements_alter().
 */
function MY_MODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'modules_installed') {
    $moduleHandler = \Drupal::service('module_handler');
    if ($moduleHandler->moduleExists('locale')) {
      unset($implementations['locale']);
    }
  }
}

/**
 * Implements hook_modules_installed().
 */
function MY_MODULE_modules_installed() {
  $moduleHandler = \Drupal::service('module_handler');
  if ($moduleHandler->moduleExists('locale')) {
    locale_system_set_config_langcodes();
  }
}


Can I make the second button in a form the default button?

The answer seams to be no, there is no built in Drupal method of getting around the problem of the first button in a form being the default when pressing [ENTER].

Here is what I had to do.

I created an extra submit button at the top of my form:

// A submit button that needs to be hidden, it'll be the default rather than one from the list.
$form['hidden-submit'] = array(
  '#type' => 'submit',
  '#value' => 'Save',
  '#attributes' => array('class' => 'hidden-default-submit'),
);

In the CSS included for the page I added the following belts and braces CSS to hide the extra submit button in as many web browsers as I could test:

.hidden-default-submit {
  position: absolute;
  left: -2000;
  top: -2000;
  width: 0;
  height: 0;
  border: 0;
  margin: 0;
  padding: 0;
}


There are some defaults that ship with D8 in your sites/default configuration files that you can configure during development.

The application portion:

Open development.services.yml in the sites folder
and add the following block (to disable twig cache)
        parameters:
          twig.config:
            debug : true
            auto_reload: true
            cache: false

There is more information on this Drupal.org node.


Add rules to the email recipients in webforms

What you want to do, certainly cannot be done with just webform.

But you may be able to pull it off when combining Webform with Rules and Webform Rules.

You can add a rule to fire at the event of a webform submission. As condition you will add the nid of the webform so you are sure this specific webform only triggers this workflow. You can also add you own php code as a condition (or no code at all if you are just going to do simple comparisons.). The good thing in this process is that all the submitted data are available through Rules so you can just grab them in your code/conditions to see if the data meet the criteria. If all the conditions are met then you will add an action to send an e-mail to either a specific user or all users of a role.


Yes it is very much possible, but probably you can do it only by creating custom module.

send Ajax request to the Drupal
load selected view form database by views_get_view
execute selected display by $view->execute_display('display')
send HTML created on executing display back to the client.
on client side put this html wherever you want

Check ajax load module (which is D6 only) too, maybe it can help you.

There is a even quicker way and more robust to render a view: views_embed_view


Is there any module to create different menus per user?

Yes. You can try OM Maximenu. It is really flexible and this means you will need some time getting the configurations right but it's really good especially when it comes to controlling menus per role.


Why do I get "Access Denied" on every page?

Don't edit core code as suggested by Flounders answer. If you're not using HTTP auth then simply disable the Basic Auth module via the UI or Drush:

drush pmu basic_auth -y

Drupal has different authentication providers. The defaults are: basic_auth and cookie, basic_auth has a higher priority but is not enabled by default.


Resource interpreted as Image but transferred with MIME type text/html

Image path is incorrect. It will pick the path of image as http://current_path/images/id-background.jpg.

global $base_url;
$path = $base_url . drupal_get_path('module', 'mymodule') . '/images/id-background.jpg'; // considering the image is placed in your custom module's image directory
$form['id']['myid'] = array(
  '#type' => 'item',
  '#markup' => '

'
);


No, Drupal devs didn't rewrite jQuery, a standard version is included (1.3.2). I can vouch for flag.js working fine with that version of jQuery.

It's not compatible with the version of jQuery that you're including though. You're probably also introducing a conflict between the two versions of the library that are included in the page.

jquery_update isn't a huge module at all, and it gives you several versions of jQuery plus the CDN option out of the box. It was written specifically to solve the problem you're trying to get round.

There's no good reason not to install it; if you don't, you'll just be reproducing functionality it already provides, which is time you could spend doing something productive.


Trying to remove options form an exposed filter

Instead try the following it will help you by using hook_form_alter()

function mymodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {

  if($form['#id'] == 'views-exposed-form-[your-view-here]') {

    foreach ($form['tid']['#options'] as $term_key => $term) {

      // Check if this isn't the 'ANY' option
      if($term_key !== 'All') {
        // Check if this is a child by looking for '-' as first char in string
        $term_value = reset($term->option);
        if($term_value[0] == '-') {
          unset($form['tid']['#options'][$term_key]);
        }
      }

    }

  }

}

taken from the source


If you used Views PHP, this is a known issue

Views Pager is hidden (7.x-2.x)

Pager disappears when Global: PHP used in Views 3.8

You have to apply one of the patches to fix it.


The hook hook_mail_alter() should work in this case.

Have you double checked if your module is activated and you have cleared your cache after adding the hook?

Also i am not sure if your template will work, because normally all templates are working with dashes instead of underscores.


if your teams data are coming from the same table use drupal db select and table api to create a table where u can see all the data
try to ajust that to your system

  /**
 * Render a filtered list of entries in the database.
 *
 * DBTNG also helps processing queries that return several rows, providing the
 * found objects in the same query execution call.
 *
 * This function queries the database using a JOIN between users table and the
 * example entries, to provide the username that created the entry, and creates
 * a table with the results, processing each row.
 *
 * SELECT
 *  e.pid as pid, e.name as name, e.surname as surname, e.age as age
 *  u.name as username
 * FROM
 *  {dbtng_example} e
 * JOIN
 *  users u ON e.uid = u.uid
 * WHERE
 *  e.name = 'John' AND e.age > 18
 *
 * @see db_select()
 * @see http://drupal.org/node/310075
 */
function dbtng_example_advanced_list() {
  $output = '';

  $select = db_select('dbtng_example', 'e');
  // Join the users table, so we can get the entry creator's username.
  $select->join('users', 'u', 'e.uid = u.uid');
  // Select these specific fields for the output.
  $select->addField('e', 'pid');
  $select->addField('u', 'name', 'username');
  $select->addField('e', 'name');
  $select->addField('e', 'surname');
  $select->addField('e', 'age');
  // Filter only persons named "John".
  $select->condition('e.name', 'John');
  // Filter only persons older than 18 years.
  $select->condition('e.age', 18, '>');
  // Make sure we only get items 0-49, for scalability reasons.
  $select->range(0, 50);

  // Now, loop all these entries and show them in a table. Note that there is no
  // db_fetch_* object or array function being called here. Also note that the
  // following line could have been written as
  // $entries = $select->execute()->fetchAll() which would return each selected
  // record as an object instead of an array.
  $entries = $select->execute()->fetchAll(PDO::FETCH_ASSOC);
  if (!empty($entries)) {
    $rows = array();
    foreach ($entries as $entry) {
      // Sanitize the data before handing it off to the theme layer.
      $rows[] = array_map('check_plain', $entry);
    }
    // Make a table for them.
    $header = array(t('Id'), t('Created by'), t('Name'), t('Surname'), t('Age'));
    $output .= theme('table', array('header' => $header, 'rows' => $rows));
  }
  else {
    drupal_set_message(t('No entries meet the filter criteria (Name = "John" and Age > 18).'));
  }
  return $output;
}


Install Conditional Rules so that you can add "conditions" between " rule actions". After that you can create a variable which iterates and use that to stop after the third elements.


Restriction on specific content types for admin content page filter

Just go to the /admin/structure/views/view/content and edit the
Content: Content type (exposed) filter in the "Filter Criteria Tab" of your view.

Then just select  your type1 and type 2.


Restricted access url for an image uploaded to private filesystem

You want to implement hook_file_download in Drupal 7.

  Control access to private file downloads and specify HTTP headers.

  This hook allows modules enforce permissions on file downloads when
  the private file download method is selected. Modules can also provide
  headers to specify information like the file's name or MIME type.

A small example:

function mymodule_file_download($uri) {
  global $user;

  // Does the user have access based on some criteria ?
  if (!user_access('ACCESS PAY-PER-DOWNLOAD-CONTENT', $user)) {
    return -1;
  }

  // Does this module own the file given by the $uri ?
  if (db_query('
          SELECT fu.module
          FROM {file_usage} fu
          WHERE fu.module = :module_name AND fu.uri = :uri',
          array(':module_name' => 'mymodule',
                ':uri' => $uri)->rowCount() < 1) {
    return NULL;
  }

  // If the above conditions fallthru then populate HTTP header arrays
  // for content download; If you need to grab the file object and work on
  // it -- say output CSV from the data, you can grab it as follows ...
  $files = file_load_multiple(array(), array('uri' => $uri));
  // If empty, $file will be false, otherwise will contain the required file.
  $file = reset($files);

  return array('Content-Type' => file_get_mimetype($uri));
}


The block module is not required by core; just go to mysite.com/admin/modules and disable it, if you don't want to use it in your site.

EDIT to address your updated question. This code should do the trick. It will deny access directly to the blocks admin overview page, but will still allow access to the add block page.

function mymodule_menu_alter(&$items) {
  // Deny access to the blocks overview page.
  $items['admin/structure/block']['access callback'] = FALSE;

  // Explicitly allow access to the block add page
  $items['admin/structure/block/add']['access callback'] = 'user_access';
  $items['admin/structure/block/add']['access arguments'] = array('required permissions');
}


Hierarchy of content types with taxonomy as parent

The most suitable structure in your case seems to be to create two-level Taxonomy for your Topic and Subtopic, and a Content Type with Taxonomy term Entity Reference Field.
If you want to limit which Taxonomy level appears when creating new nodes you can configure the Entity Reference field to use the Views Entity reference Display that filters and shows only the second level.
Use Pathauto module to set up automatic URL patterns based on the Taxonomy field and node title.
With Views you can create a Page with Contextual filters for the Taxonomy with Depth or Parent term, and the actual term the node is tagged with. These are two Contextual filters, each gives you one argument in the path.
With the first Contextual filter you filter out all the nodes that are tagged with the the child of the parent from the first URL argument. When you add the second Contextual you narrow it down to the particular Child term.
The third Contextual can be added for the node title, or node ID.
ER fields store entity IDs, not their names, so if you want the actual names in the path as arguments, and not the ID numbers, you'll have to add the Relationship for the ER field. This will open up more options in Views for the Vocabulary fields.
The solution I've described isn't trivial. If you're inexperienced in setting up Contextual filters try to practise first on simple examples. You can find many examples here with answers about Contextuals, Names, and Relationships.


Show multiple content in a view in drupal 7?

The "content related product i.e. Product name, product detail*" in your question is a bit ambiguous ... (not sure how to correctly interprete) ...

1st possibility:

It may mean that you only have a single content-type (named "Accessories") with some fields added to it, i.e. product name, product detail, product image, etc.

In that case, you should the "add" button to the right of Views "Fields" (1st column of the Views UI). First to add a field like Product name, and then for product detail, product image, etc.

2nd possibility:

It may mean that you have a content type "Accessories", and another type like "Product" or something.

In that case, you should add a Views "Relationships" (3rd column of the Views UI).


Drush cron - how to provide the actual task

From the Drupal perspective, you just need to implement hook_cron():

function MYMODULE_cron() {
  drupal_http_request('http://foo.bar');
}

That will be invoked on all normal cron runs (there are situations when it won't, e.g. if you have a cron management module installed that limits core cron operations).

But it might make more sense just to wget/curl that URL on a separate single-line cron job. Depends on your use case, but either will probably be fine.


How to update the google fonts provided by @font-your-face module?

If you just updated to a new version, have you gone and re-imported all the fonts you need/want (step 2 below)?  In D6 at least, the following worked here:

Install module, enable base and google apis.
Go to admin/settings/fontyourface and import google fonts -- 1449 fonts imported
Go to admin/build/themes/fontyourface and click browse -- 58 pages of 25 fonts displayed

and sure enough, Imprima is in there when you search.


Rewrite empty Fields on Feeds periodic Import

Yes, this is a known problem of feeds. However, there is a patch for it and will be included in the next release as I know. You can already apply the patch now yourself:https: www.drupal.org/node/1107522
It is #161 in the link above.

I am using it for a while and tested it too, it works for your scenario above.
There is one problem with email and URL fields: Feeds still creates the field when the import is empty and this results in empty fields shown.


How to upgrade to Drupals latest version via Composer?

I had exactly the same issue while performing upgrades. The solution for me was removing/renaming the vendor folder and the composer.lock file and run composer update drupal/core --with-dependencies.

You can also try to update dependency explicitly with composer update egulias/email-validator drupal/core --with-dependencies. This usually works in this type of issues, but it didn't work for me.

Given that you don't see drupal/core in your composer.json you might also try composer require drupal/core.


How can an entity reference field be displayed as a select list that shows the selected entity?

You have 2 relatively simple options without creating your own module and field display code (in a module).

use Views to generate the select lists you want. You can do this for example with a ctools dropdown or jumpto displays. While you're using a view you can always set Views to cache the results of your view so its not cumbersome after the 1st page load for all other visitors. You can even define views and attach them to your node if you want with field_views_field module.
Use Display Suite on your site and create a Custom Field in DS for any fields you want custom output for, like your select list. Then in the PHP area of the custom field you can access the currently loaded $entity fields and generate whatever HTML you want for your field output. You would then hide the default field display of your field, and show your custom DS created field for your content type.

I'm about to do (2) above with a slideshow content type where per-slide the content editor can select the text foreground and background color using the field_color module which would best match an uploaded image to the Node. Then in DS I will make a custom "slide_text" dyanamic field that examines the color values and basically outputs:

<?php
// This is pseudocode and untested.
$wrapper = entity_metadata_wrapper('node' $entity);
$text_color = $wrapper->field_foreground_color->value();
$bg_color = $wrapper->field_background_color->value();
$text = $wrapper->field_slide_text->value();
echo <<<EOFHTML
<span class="ds-slide-content-field"
      style="color: $text_color;
             background-color: $bg_color">
    $text
</span">
EOFHTML;
?>


multiple (two at least) user registration forms

You can achieve this using Profile 2 and Profile2 Registration Path module.

Profile 2

  Multiple profile types may be created via the UI (e.g. a general
  profile + a customer profile), whereas the module provides separated
  permissions for those

Profile2 Registration Path

  This module enables administrators to set unique registration paths
  per Profile2 profile type


The reason it works only for the frontend pages is that:

The System module implements hook_custom_theme() using the following code

function system_custom_theme() {
  if (user_access('view the administration theme') && path_is_admin(current_path())) {
    return variable_get('admin_theme');
  }
}

The function that invokes that hook has the following code

$custom_themes = array_filter(module_invoke_all('custom_theme'), 'drupal_theme_access');
if (!empty($custom_themes)) {
  $custom_theme = array_pop($custom_themes);
}

In other words, the theme selected is the one returned from the last hook invoked, which in your case is system_custom_theme().
If you want that your module always sets its own custom theme, even for administrative pages, you need to tell Drupal to execute your hook implementation for last.

function hook_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'custom_theme') {
    // Move mymodule_custom_theme() to the end of the list. module_implements()
    // iterates through $implementations with a foreach loop which PHP iterates
    // in the order that the items were added, so to move an item to the end of
    // the array, we remove it and then add it.
    $group = $implementations['mymodule'];
    unset($implementations['mymodule']);
    $implementations['mymodule'] = $group;
  }
}

As side note, since the module would be override the theme set in admin/appearance, the module should give an indication of that in that page.

As for using the Themekey module, that module doesn't override the theme for the administrative pages, since its hook implementation (themekey_custom_theme()) contains the following code.

  // don't change theme when ...
  if ((in_array('system', variable_get('themekey_compat_modules_enabled', array())) || !(variable_get('admin_theme', '0') && path_is_admin($_GET['q']))) // ... admin area and admin theme set
     && strpos($_GET['q'], 'admin/structure/block/demo') !== 0 // ... blocks demo
     && strpos($_SERVER['SCRIPT_FILENAME'], 'cron.php') === FALSE // ... during cron run executed by cron.php
     && strpos($_SERVER['SCRIPT_FILENAME'], 'drush.php') === FALSE // ... during cron run executed by drush
     && (!defined('MAINTENANCE_MODE') || (MAINTENANCE_MODE != 'install' && MAINTENANCE_MODE != 'update')) // ... during drupal installation or update
    ) {
  // …
}

The comment reads as "don't change theme when admin area and admin theme set." I would rather do what the Themekey module does, but since you are trying to set the theme in any case, the Themekey module would not work for your case.


Redirecting user-login-form on certain page

There are several methods to redirect user to specified url after login

You can use Rules

Events: User has logged in.

Condition: User has role

Actions: Page redirect

Another one with drupal api:

   function hook_user_login(&$edit, $account) {
     $edit['redirect'] = 'yourpath';
  }

if it not worked try to change $GLOBALS['destination'] with

function hook_user_login(&$edit, $account)  {
  $GLOBALS['destination'] = 'yourpath';
}

Also you can use Login Redirect module

  Overview A simple module providing a method to redirect users
  according to an URL-defined parameter after logging in. Allows
  redirects toward non-Drupal location.

  Features

Lightweight and minimal configuration. No module dependencies!
Allows custom URL parameter name
Filters XSS URL input


View inside a node with content from a relationship

You can build it in Views without EVA.
Here's a great article about different cases of how to build Relational lists in Views (I'm not affiliated): Relationships and Contextual Filters in Views 3 for Drupal
In your particular case you need to look at the 'Pulling fields of “Child” nodes by node reference' section.
You build a list of Artwork, then add the Contextual filter for the Artist ER field, configure it to default to "Content ID from URL", add the Validation that limits it only to the Artist type so it appears only on Artist nodes, adjust the other settings to your particular needs.


Taxonomy term name as contextual filter for view

The Term name converted to Term ID filter looks to be missing for D8 Views.

One site-builder workaround, is to add a Relationship, Taxonomy terms on node then to add a Taxonomy Term: Name filter to Contextual Filters using the aforementioned relationship. Checking the Specify validation criteria checkbox, set your Validator to Taxonomy term name & check the appropriate Taxonomy to filter on.


Error when running update.php about field_data_body existing

I would recommend you to apply this patch, that can be maybe the solution for you :

https://www.drupal.org/files/issues/1551132-drupal-install-schema-shared-tables-69-D7.patch


Show product commerce by taxonomy parent with childs

Well, I am my most popular fan so I will answer myself:
1. It's not possible to add that PHP code to the view, as it's a known bug that the view doesn't allow multiple contextual filter variables as a PHP. Although you can use them through the URL and changing the 'code PHP' option by 'Multiple Terms ID separated by ',' OR '+''. --> I don't like that option as the URL won't be very clean and can be a bit complicated.
2. Found a better option!! I decided to select the parent when one of its childs are selected. This option can be activated as automatically, when installing the Taxonomy Term Reference Tree Widget module:

About this module
This module provides an expandable tree widget for the Taxonomy Term Reference field in Drupal 7. This widget is intended to serve as a replacement for Drupal's core Taxonomy Term Reference widget, which is a flat list of radio buttons or checkboxes and not necessarily fit for medium to large taxonomy trees.

Note: I don't know why but my tree view is not as nice as in the picture and I needed to use a fix but it works perfect.


Let's assume that the Rules action that you want to trigger is to just set a Drupal message like "Rules action related to payment confirmation". But this action should only be triggered when "Viewing the content" located at your confirmation page, which has a path like "/payment-confirmation".

To get this to work, use the rule below (in Rules export format, just import it in your site and check the results of it):

{ "rules_extra_action_about_payment_confirmation" : {
    "LABEL" : "Extra action about payment confirmation",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_view" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "site:current-page:path" ], "value" : "/payment-confirmation" } }
    ],
    "DO" : [ { "drupal_message" : { "message" : "Rules action related to payment confirmation" } } ]
  }
}

The rule above should be close to what you're looking for, except from these further refinements:

Replace the rules Action by your own rules "action" (which you didn't specify).
If you want your Rules Action to be performed before your confirmation page is actually shown, then replace the Rules Event (= "ON" : { "node_view" : [] },) with "ON" : { "init" : [] }, (= "Drupal is initializing").


You can use "Taxonomy term: Parent term" as contextual filter in your view.

Most likely you will need to provide a default value for the filter, such as "Taxonomy term ID from URL".

Provide a default value for your filter according to your preferred usage. The options for setting the default value of the filter should be self-explanatory.

Since you didn't specify where this view is supposed to be displayed, I can't give any other insight.


Getting field value that attached to Commerce product field

You should be able to use entity_metadata_wrapper quite nicely for this. Note that it is part of the Entity API, but that is a dependency of Drupal Commerce so you'll be fine in this case.

Something like the following code should do it:

$wrapper = entity_metadata_wrapper('commerce_product', YOUR-REQUIRED-PRODUCT-ID);

$discount = $wrapper->field_diskon->value();

You can find out more about how to use entity_metadata_wrapper() here.


When I tried to use user wildcards first, I too came across this problem; and after some trial and error, found that the %user wildcard doesn't work with the menu type MENU_NORMAL_ITEM, instead it works if the type is MENU_LOCAL_TASK.

So, the code should be:

function hook_menu() {
  $items['user/%user/bookmarks'] = array(
    'title' => 'My Bookmarks',
    'description' => 'Link to My Bookmarks',
    'page arguments' => array(1),
    'access callback' => 'user_is_logged_in',
    'type' => MENU_LOCAL_TASK,
    'menu_name' => 'user-menu'
  );

  return $items;
}

Usually, this menu type is rendered as a tab in user menu.

I didn't get enough time to figure out why it doesn't work with MENU_LOCAL_TASK, but when I do find the reason, I'll post it back.


Is your settings.php file in a folder called 'default'?  If not, you might need to tell Drush where to find it by using --uri=mysite.com or -l mysite.com.

See: Drush Bootstrap Error on Multi-Site Install


Disabling single options from select lists is currently not that easy in Drupal. There are some open issues regarding the topic and a couple of suggested patches, but so far neither made it into core:

Allow FAPI select, radios, and checkboxes to specify some options as disabled
Introduce proper Form API #types for 'option' and 'optgroup', and make #options consistent
Using form_alter to disable ONE option of a select field

That said, there is a tutorial on Exove which works around the issue, by implementing the THEME_select() hook to enable theming of individual select options using a #options_attributes key: Drupal 7 Form API select element option attributes

Using the code for your theme's template.php from the tutorial, you can disable options in your form using hook_form_FORM_ID_alter().

function hook_form_FORM_ID_alter() {
  $today = date("Y-m-d H:i:s");
  $date = "2016-11-01 00:00:00";

  if ($date > $today) {
    //replace 0 with the actual index for Early Bird
    $form['your_select_field']['#option_attributes'][0] = array('disabled' => 'true');

    //set the other fields based on dates here
  }
}

There is also a module which seems to offer the same functionality as the theme code from the tutorial, but I have not yet tested it: Form Options Attributes. It seems to work in a similar fashion however and might be even a little easier to set up (since you don't need to write that theme function).


I don't understand if the extra fields to add are in the node form or into the page(display of node). If it's the first thing I think you can use hook_form_alter to add the extra fields and in the second case you can use hook_preprocess_node to add the variables to 'send' to the front-end of site.


getting key of submitted entity list field

I'm not familiar with entityform so forgive me if none of this makes sense, but I imagine it works much like webform in that it sends the e-mail to the addresses you set up upon a successful form submit with no need for any custom code. So adding another validator or submit function to send the e-mail would result in two e-mails.

What you can do is use hook_mail_alter in a custom module and see what variables entityform passes to its drupal_mail call. With any luck, all the form values from $form_state will be included and you can do the check there and then change the $message['body'] array accordingly.

In the hook_mail_alter you can do a switch statement for the $message['key'] or $message['id'] to make sure you're not running your check for every mail your drupal site sends but only for the entityform in question.

I would also include a custom token of sorts in the template you, presumably, entered when settings up the entityform so you can easily change the e-mail body once you've run the check. I don't know if you could do it with Drupal's Token system, but even just entering 'my_module_custom_token' in the template and then using str_replace on 'my_module_custom_token' with the correct sentence in the mail_alter is better than nothing.

If none of this applies, then naturally disregard this answer entirely.


show order payment option in order (admin/commerce/order)

Enable permission "Use the administration pages and help" under the System section should do the trick.


$form_state['redirect'] = FALSE;

This works like a charm since the form is not rebuilt or reloaded.
Below link contains more info
https://drupal.org/node/1850410


This command doesn't come from Drush core but from the Voting API module. This command simply doesn't exist yet in the currently latest Voting API release: 8.x-3.0-beta2.  See, the directory /src/Commands where Drush commands since Drush version 9 get registered now simply isn't there yet.
You need to get the latest Voting API dev:
$ composer require 'drupal/votingapi:3.x-dev@dev'

There the /src/Commands directory contains a VotingApiCommands.php file with all the commands in it. The module needs to be enabled to use them, of course.

Voting API version 3.0-beta2 only contains the legacy votingapi.drush.inc file for Drush commands up to Drush version 8.


You need to implement hook_admin_paths() to tell Drupal to use the admin theme for your URL pattern:

  Modules may specify whether or not the paths they define in hook_menu() are to be considered administrative. Other modules may use this information to display those pages differently (e.g. in a modal overlay, or in a different theme).

In your case the code would look a lot like this:

function MYMODULE_admin_paths() {
  $paths = array(
    'node/*/edit-full' => TRUE
  );
  return $paths;
}

Once you've cleared the caches your pages should now be using the admin theme.


How can I have device-specific block layouts?

I followed the counsel of Berdir and Ash Upadhayay. Having a sub-domain dedicated to mobile devices is a sound advice as many important websites currently use this method. As they say, using the same domain for both version could cause problems with caching and referencing by indexation robots.

This however doesn't clash with my requirements, and I was able to fulfill them using the Drupal 8 version of the Domain Access module.

The Domain Access module allows to define specific sub-domains that Drupal 8 will be able to recognize. The module then makes possible to condition all manner of things depending on the current domain, including the block layout.

I installed the module itself and its contrib module (packaged with it) Domain Alias. This last module allows you to associate various patterns to a domain that works as an alternative way of detecting the domain. This allows to match the URLs of local installs of the project without changing the Domain configuration.

This is the perfect solution for me as I am now able to condition the display of blocks from a single page - the block layout page.

All that's left to do then is to redirect the user on the correct sub-domain depending on the device, using a module such as Mobile JS Redirect.


Adding a new field for the last name will be the easiest way. Sorting by a substring would mean that you also have to cover the possibility of spaces in first names and/or last names.


Pager doesn't work in views block if views php field is used

There is a patch for that: Pager disappears when Global: PHP used in Views 3.8

  After upgrading from Views version 7.x-3.7 to 7.x-3.8, the pager was
  missing from all views that used Global: PHP fields.

If patch#6 does not work for you, just follow the links in comment#27


Sync +- 70 000 records from CSV into drupal

If you need an update feature of your records i'm not sure how you'd get around scanning for Diffs to find changes -- this takes time.

I've used Migrate to upload simple CSV files and tables. Have you looked at Migrate 2.6 Hash() function to track data changes in stuff to perform only updates from your source data?
http://www.acquia.com/blog/migrate-26-framework-changes

  With Migrate 2.6, we have introduced the 'track_changes' option to
  MigrateSource. If you pass 'track_changes' => 1 in your options array
  on your source constructor, Migrate will hash the source data after
  prepareRow() is called and save the hash in the map table on initial
  import. On subsequent imports, it will again hash the incoming source
  data and compare it to the saved hash - if the hashes don't match, the
  object will be reimported and the new hash saved, otherwise it will be
  skipped. Of course, this is a slower method than highwater marks, but
  when you must pick up changed records and don't have a good highwater
  mark field in the source data, this is the way to go.

Is there any reason you cannot import your CSV file into MySQL tables and then import your data from there using Migrate or a Drush script? Once in tables you could partition the data/tables easily to run the inserts more concurrently for a speedup.

EDIT:

I hit a .NET webservice for 100,000s of records for campus data at an EDU. I found that parsing the data linearly took me on the order of an 1 hour from top of the XML file to the bottom. By requesting each department individually at-the-same-time (get ~60 XML files at once instead of 1 big xml file) and processing in parallel up to 8 threads (via Ultimate Cron) the same process now takes ~5 minutes.

At some point linear processing of data simply fails and you have to find other means.


How to render language select block in page template?

drupal_entity() is for rendering entities. For rendering block plugins use drupal_block() instead.
The difference is explained very well in the following guide.
https://www.drupal.org/docs/8/modules/twig-tweak/rendering-blocks-with-twig-tweak


Creating nodes with cURL that have multiple tags and a content moderation transition

You need to map target_id => [id] as key/value pairs:

"field_tags":[{"target_id":"1"},{"target_id":"2"},{"target_id":"3"}]


Use hook_node_delete . This hook is being invoked right before node deletion.

function YOURMODULE_node_delete($node) {
  if ($node->type == 'NODETYPE') {
    $node->status = 0;
    node_save($node);
    unset($node);
  }
}


How can I access the raw value of a view in a template?

I found a solution. I was looking at the problem the wrong way. It is possible to get the raw url value of an image field in a page template by using native twig-drupal functions instead of using a view => https://drupal.stackexchange.com/a/224311/16146


For drupal set message below is a syntax.

drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE);

Parameters

string $message: (optional) The translated message to be displayed to the user. For consistency with other messages, it should begin with a capital letter and end with a period.

string $type: (optional) The message's type. Defaults to 'status'. These values are supported:

'status'

'warning'

'error'

You should pass any one of the status message with your custom class separated with space as shown below

drupal_set_message(t('an error has occured'),' status custom-error');


Feeds XPath parser - how to map to complex content types (eg to field collection field)

You can use Field collection feeds module which provides feeds integration for field collection module.

You can read here how to import field collection using feeds.


Entity metadata wrapper - how to get field value, NOT key

You may use $wrapper->field_something->label().