You've just spelt 'arguments' wrong in both of the 'access arguments' and 'page arguments' properties.

At least one of 'access callback' or 'access arguments' needs to be present in the router item or you won't be able to access the page.

Just fix that spelling, clear the cache, and it should work fine


How to check in a rule if the data from a field collection has changed?

Processing field collections is always fun, and even more fun to do so with the Rules module. My favorite sample to refer to (for actually doing so) is contained in part 1 of my answer to "How to iterate over all field collection items in an eMail body using Rules?".

Have a look at comment #2 of the issue about "Field Collection does not work with Rules' 'node-unchanged' option", which states:

  ... For example:

  Create a content type with a field collection that contains an integer field.
  Create an "After updating existing content" rule for that content type.
  Add a "Show a message on the site" action that prints the integer field attached to node:field-collection and node-unchanged:field-collection.

  The printed value for node-unchanged is wrong. It shows the changed value.

So far the bad news, read on in comment nr 3 of that same issue, which is like so:

  The reason that node-unchanged and node both show the same (new) field collection values is that the node stores a reference to the field collection. The field collection is a separate entity. Changes to it can be caught by the rules events for field collections. The "after updating an existing field collection item" event gives the correct unchanged and new values.

With this explanation in mind, have a look at this rule (in Rules export format):

{ "rules_verify_updates_to_field_collection_items" : {
    "LABEL" : "Verify updates to field collection items",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_conditional", "field_collection" ],
    "ON" : { "field_collection_item_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "field-collection-item" ], "field" : "field_reviewers" } }
    ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "field-collection-item-unchanged:field-reviewers" ] },
          "ITEM" : { "previous_reviewer" : "Previous reviewer" },
          "DO" : [
            { "CONDITIONAL" : [
                {
                  "IF" : { "NOT list_contains" : {
                      "list" : [ "field-collection-item:field-reviewers" ],
                      "item" : [ "previous-reviewer" ]
                    }
                  },
                  "DO" : [
                    { "drupal_message" : { "message" : "Reviewer [previous-reviewer:name] was removed from the list of reviewers in field collection item with id [field-collection-item:item-id]." } }
                  ]
                }
              ]
            }
          ]
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "field-collection-item:field-reviewers" ] },
          "ITEM" : { "current_reviewer" : "Current reviewer" },
          "DO" : [
            { "CONDITIONAL" : [
                {
                  "IF" : { "NOT list_contains" : {
                      "list" : [ "field-collection-item-unchanged:field-reviewers" ],
                      "item" : [ "current-reviewer" ]
                    }
                  },
                  "DO" : [
                    { "drupal_message" : { "message" : "Reviewer [current-reviewer:name] was added to the list of reviewers in field collection item with id [field-collection-item:item-id]." } }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

Some details about the above rule:

Rules Event: After updating an existing field collection item. Note that this is different from the Rules Event you're using!
Rules Condition: Entity has field, for a field with machine name field_reviewers, which is a multi value entity reference field (to users).
Rules Actions:

The 1st loop (related to field-collection-item-unchanged:field-reviewers), will discover all removed reviewers.
The 2nd loop (related to field-collection-item:field-reviewers), will discover all added reviewers.

Obviously, for this rule to work you'll also need the Conditional Rules module, though you could also rework the Rules Action to performing Rules Components (in which you add the appropriate Rules Conditions), so that you don't need this extra module (for more details on that, refer to the answer to "What's the alternative to using the Conditional Rules module?").

Here is a demo of this rule (= some Drupal messages shown after I added/removed some user references in 2 field collection items (with id = 5 and 6):

Reviewer Hillary.Trump was removed from the list of reviewers in field collection item with id 5.
Reviewer UltraBob was added to the list of reviewers in field collection item with id 5.
Reviewer Donald.Clinton was removed from the list of reviewers in field collection item with id 6.
Reviewer Dries.Buytaert was added to the list of reviewers in field collection item with id 6.
Reviewer Pierre.Vriens was added to the list of reviewers in field collection item with id 6.

To finish: you're question may require a slightly different set of Rules Conditions, i.e. since you want to compare some field before the update (= unchanged) versus after the update. But if you're using the same Rules Event and Rule Condition (= Entity has field, for your field collection field), you should be able to perform such comparisons also.


Comment permission by role and content type

What you looking for is Comment Permission module.
Some description of this module

  The Comment Permissions module enables control of commenting by user
  role and by node type. Additional user permissions for selected node
  types are added to the user access system so you can configure
  commenting with more control than Drupal core provides.


Your form function is called redirect_custom_reg_user_register_form(), so your submit function needs to be called redirect_custom_reg_user_register_form_submit().

If you want to keep the same submit function name that you have currently, you need to add it manually in the form function as Drupal only looks for a function called FORM_FUNCTION_NAME_submit() by default:

$form['#submit'][] = 'redirect_custom_reg_submit';


force image style generation on save node

Yes - you can implement hook_node_insert() and hook_node_update() in a custom module and create the images there using image API functions. For example

function MYMODULE_node_insert($node) {
  // Get some field items from a field called 'field_photo.
  if ($image_items = field_get_items('node', $node, 'field_photo')) {
    $image_item = array_shift($image_items);

    // Load the associated file.
    $file = file_load($image_item['fid']);

    // An array of image styles to create.
    $image_styles = array('style_1', 'style_2');

    foreach ($image_styles as $style_name) {
      // Get the location of the new image.
      $derivative_uri = image_style_path($style_name, $file->uri);

      // Create the image.
      image_style_create_derivative($style_name, $file->uri, $derivative_uri);
    }
  }
}


I need to add rel="nofollow" to the button provided by "views load more" module

I found the answer myself, and I want to share it in case someone have the same problem in the future.

Just override the theme_pager_next() function in the template.php file of your theme like this:

function YOURTHEME_pager_next($variables) {
  $text = $variables['text'];
  $element = $variables['element'];
  $interval = $variables['interval'];
  $parameters = $variables['parameters'];
  global $pager_page_array, $pager_total;
  $output = '';

  // If we are anywhere but the last page
  if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
    $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
    // If the next page is the last page, mark the link as such.
    if ($page_new[$element] == ($pager_total[$element] - 1)) {
      $output = theme('pager_last', array('text' => $text, 'element' => $element, 'parameters' => $parameters,'attributes'=>array('rel'=>'nofollow')));
    }
    // The next page is not the last page.
    else {
      $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters,'attributes'=>array('rel'=>'nofollow')));
    }
  }

  return $output;
}

I've just add 'attributes'=>array('rel'=>'nofollow') to theme() function :)


Views contextual filter navigation links?

Take a look at the quicktabs module. It should let you define "tabs" for these filters.

  The Quick Tabs module allows you to create blocks of tabbed content,
  specifically views, blocks, nodes* and other quicktabs*. You can
  create a block on your site containing multiple tabs with
  corresponding content. Clicking on the tabs makes the corresponding
  content display instantly, using jQuery.

Additionaly, there is this in-depth blog post not written by me showing filtering/sorting a complex view + filters page using quicktabs. The left side of this view page has "tabbed" items like what you want in your example. CSS tweaks will make the tabs "look" how you want.


This works as a module, but think it should go in my .theme file instead

What you missed is, that you can achieve all that output manipulation by just using the admin UI and view modes. It has the benefit of you being able to adjust the output order and available fields without having to touch any code. And gives you more power and flexibility to administer how content is displayed.

By incident, your solution matches a question answered just recently here: How to modify the value of a taxonomy field of a node using hook_node_view()?

Please have a look to my answer there, which describes how to show a field of the the taxonomy terms on the nodes by using the UI.

You can easily adjust the proceedings by e.g. creating a dedicated display mode for your content nodes instead and adding the required fields there.

Additionally, you like to show the formatted created time, which you can either preprocess within a theme's hook_preprocess_HOOK() (so for example yourtheme_preprocess_node()), but also have already exposed within the template variables as {{ date }} in your node.html.twig template.


A token like [field_display_name] in the rewrite results option for the display of a Views field is not the same as a token everywhere else in Drupal, so hook_token_info() and hook_tokens() won't help you.  On behalf of Drupal, Views, and the million or so other available words in the English language, i apologize.

Instead you need to extend a Views field handler class and override the document_self_tokens() and add_self_tokens() methods.  You can instruct a field to use your custom field handler via hook_views_data_alter() (thanks to Daniel Wehner for this info, and very likely the hook itself).

You can see example code from my need for adding a Views field replacement pattern / token.

If you need help adapting it for your need above let me know and i'll write that here, but the remember to list in your .info the file with your field handler extending class so that Drupal registers it, and it'll work fine.


Programmatically set the front page per site?

Thanks to everyone for your responses.
I looked in to using the Domain module but am avoiding for 2 reasons:

It is still in Alpha14 and this is going to be a business critical site
I couldn't work out how to set the domain specific configurations

However, installing the Domain Module and looking at the README file pointed me in the right direction.

For anyone else who is looking to achieve setting a different Front Page per domain:

I used the Drupal Console to generate an Event Subscriber for Kernal.request
In the getSubscribedEvents method you need to set the weight to something greater than 30 which overrides the Page Cache and Dynamic Cache.

$events['kernel.request'] = ['kernel_request', '35'];

I got the editable configuration for the site settings from

$config = \Drupal::configFactory()->getEditable('system.site');

and the site name added in sites.php by doing:

$site_path = \Drupal::service('site.path');
$site_path = explode('/', $site_path);
$site_name = $site_path[1];

Then added the logic:

if ($site_name === 'site2') {
  $config->set('page.front', '/node/239')->save();
}
else {
  $config->set('page.front', '/main-content')->save();
}

The Key thing I was missing was setting the Cache Context for sites.
You need to duplicate the default.services.yml from the sites/default directory and rename it to services.yml (if you don't already have this file).

Then you will need to add url.site to the required_cache_contexts array so that is becomes something similar to:

required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions', 'url.site']

Remember to flush the cache and this should work!


change node types file fields widgets programatically?

It seems like this could do the job:
Programmatically change form widget type for a field


How can I use a custom table as a node type?

While you're making work for yourself using a custom table and not the Field API, you can use your own table with

hook_node_load ( load data from custom table into node )
hook_node_insert ( insert record in custom table )
hook_node_update ( update record in custom table )
hook_node_delete ( delete record from custom table )

You'll probably also need

hook_form_alter

if you want to add form elements to the node form.

Keep in mind the Field API will do that all for you though if using standard fields.


I put a breakpoint on one script's attach behaviours and inspected the call stack both times it was called.

The first time was expected, from drupal.js, and the second turned out to be from a call in the EU Cookie Compliance module. This turned out to be a bug in the EU Cookie Compliance module.

Thanks for comments. I'll leave this here in case anyone else of the 70.5k users of that module experience the same issue!


Error migrating a Drupal 8 site from beta15 to final

This particular error comes, when your services.yml file is outdated. It contains the default cache max-age:

The relevant portion looks like this.

parameters:
  renderer.config:
    auto_placeholder_conditions:
      max-age: 0
      contexts: ['session', 'user']
      tags: []

This was added after beta 15, which is why you are seeing that error. Since some portions depend on the default max-age being defined, it will gives error when it isn't.

When updating your site, pre 8.0.0 you need to verify that your services.yml contains the required info.


These aggregated CSS and JS files are generated by drupal_build_css_cache() and drupal_build_js_cache() functions when the hash of the content changes (based on the sha256).

If clearing cache didn't help, to force removal of cached files, you can remove the following variables: drupal_css_cache_files, drupal_js_cache_files.

Using drush, it's:

drush -y vdel drupal_css_cache_files && drush -y vdel drupal_js_cache_files

See also: Aggregated CSS/JS file names, when regenerated?

Other thing to check is drupal_stale_file_threshold variable which may prevent removing the old files via drupal_delete_file_if_stale(), if it's set to high.

Read more at drupal_build_css_cache() API docs page:

  The cache file name is retrieved on a page load via a lookup variable that contains an associative array. The array key is the hash of the file names in $css while the value is the cache file name. The cache file is generated in two cases. First, if there is no file name value for the key, which will happen if a new file name has been added to $css or after the lookup variable is emptied to force a rebuild of the cache. Second, the cache file is generated if it is missing on disk. Old cache files are not deleted immediately when the lookup variable is emptied, but are deleted after a set period by drupal_delete_file_if_stale(). This ensures that files referenced by a cached page will still be available.


I came up with this:

drush sql-query "
  UPDATE users
  SET
    name=CONCAT('User-',uid),
    mail=CONCAT(uid,'@anon.com'),
    init=CONCAT(uid,'old@anon.com')
  WHERE uid > 0;"
drush upwd User-1 --password=SecureAdminPassword


Searching way to **not** send mail after user registration

Mailcontrol worked like a charm.
If you are looking for the configuration it is right with the Drupal user configuration.

it provides the necessary UI additions for D7 (and D8) to enable site admins to enable/disable any standard Drupal mail


Difference Between render($content['body']) and print $body[0]['value']; in node.tpl.php

You kind of answered your own question. $content['body'] contains everything in a structure in which the render function can turn it into display. This includes all your fields.

print $body[0]['value'] simply prints the value of that one field bypassing any rendering functionality such as "weight".

Rendering is a fun thing in Drupal, especially when you get to Drupal 7. Think of what you're passing into "render" as instructions on how to output, whereas the value is simply... a string... a value.


How do I implement the equivalent of hook_url_inbound_alter()?

The PathProcessorAlias() class is probably your best example.

Create a module with a class the implements InboundPathProcessorInterface.
Create the service definition in your module.
Make sure your service has the path_processor_inbound service tag.  This will mark it for collection and tie it to the path processor.  You may need to play with the priority to change where it runs.

Your class will need to have some injected dependencies for looking up the entity.  EntityManager() got broken up recently, and I forget which ones you will really need.  You may also need/want the PathValidator() service.


How hidden the user_filter_form to a specific role?

hook_form_alter() wouldn't actually be the best place for this; the form is actually called in from user_admin() so the best place for your code would be hook_page_alter().

The first thing you should do is create a custom permission that you can assign to the role:

function MYMODULE_permission() {
  return array(
    'access user filter form' =>  array(
      'title' => t('Access User Filter Form')
    ),
  );
}

Then implement hook_page_alter() to hide the form:

function MYMODULE_page_alter(&$page) {
  // Make sure this is the right page
  if (arg(0) == 'admin' && arg(1) == 'people') {
    // Make sure filter form actually exists
    if (isset($page['content']['system_main']['user_filter_form'])) {
      // Check user access
      if (!user_access('access user filter form')) {
        // Deny access to the form if necessary
        $page['content']['system_main']['user_filter_form']['#access'] = FALSE;
      }
    }
  }
}


The easiest way to track where core hooks are called, from core code, is to look on the docs page.

For hook_file_download(), you'll see this:

A nice list of all implementations/invocations of the hook with links to the relevant functions.

For the cases that don't get covered there, I usually just grep the codebase for, e.g.

module_implements('file_download'

That takes me straight to file.inc, and the file_download() function, which I guess answers your main question.

If that's not quite enough, I thoroughly recommend using Eclipse/Netbeans with XDebug which will let you set breakpoints to see what's happening in more depth.


Add a popup text link to a specific "create content" page

Have you considered hook_form_alter and the usage of either of these 2 modules:

BeautyTips, which allows:

  The Beautytips module provides ballon-help style tooltips for any page
  element by integrating the BeautyTips jQuery Tooltip plugin by Jeff
  Robbins with Drupal. It provides an API for adding custom beautytips
  as well as some built-in features. Admins can enable rollover
  balloon-help style tooltips for text fields within forms. It also
  supplies hover tips for Drupal help links and advanced help links.

  Most importantly, it allows developers to add their own custom
  beautytips popups to their site without having to delve into jQuery.

Guided Tours, which allows:

  Gives content creators the ability to build tours on their sites which
  allow users to better understand complex workflows on the site and be
  guided through those workflows. The main advantage of this module is
  that you can build tours leading the user through multiple different
  pages with multiple tooltips on one page/step. This module uses qTip
  and jgrowl_d7.

EDIT

As an example for /node/add/page the recipe would be:

Implement hook_form_alter in a custom module for this pages $form.
For any form item of the form you want to add a beauty tip for add a class so you can find it easily using beauty tips.
For instance then at the end of your hook_form_alter function you then can add the beauty tips calls following the documentation. You can use your helper CSS classes to make your life somewhat easier.
repeat (1) thru (3) as necessary ...

# in file mymodule.module

// This is step #1.
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // This is step #1. Or target 'page_node_form', or use a Regex for certain forms.
  if ($form_id == 'student_blog_node_form') {
    // This is step #2. See https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#attributes
    $form['field_survey_program']['#attributes']['class'][] = 'my-beauty-tip';
  }

  // This is step #3. See: http://cgit.drupalcode.org/beautytips/tree/README.txt?id=HEAD
  $options['bt_drupal_help_page'] = array(
      // what selects the content from the page using css selectors.
      'cssSelect' => '.my-beauty-tip',
      // what to show in the tooltip.
      'text' => 'This is my tooltip!',
      'trigger' => array(0 => 'mouseover', 1 => 'click'),
      'width' => 350,
    );
    beautytips_add_beautytips($options);
}


Select all nodes that reference the current node

You could do this using views.Create a view where under

Fields you select your group as Node, Under that choose Title.

For Filters select Node Type, Operator: Is one of and select Clinic content type.

Under Arguments select your group as Content. Under that choose Clinic_group (the node reference field).

You can add additional parameters to your view like Number of items to display, more fields like Node: Body and maybe a filter that Node: Published, select yes.

To see a preview, under live preview give the arguments as node number and click Preview.

Hope this helps!


The webform module doesn't really provide such a feature without either using unstable dev version modules (and maybe achieving it) or custom code.

An easier alternative would be to use the Entityform module, which allows you to use any add-on modules that work with Drupal's field API.

This means you could achieve your requirement using something like the Field Collection or Inline Entity Form modules to provide a repeatable group of fields. In that case you can set the field to unlimited values and it will give the user the option to 'Add another item'.

With the Inline Entity Form option, you would have a separate entity for your ticket and you form will have an Entity reference field using the inline entity form widget, which will provide the full form, inline, whenever the user clicks the 'Add another' button.


Why is hook_node_access($node, $op, $account) called with $op equal to "create"?

The admin menu contains links to create new content, and menu items also go through an access check to make sure the current user has access to the path. If they don't, the menu item is hidden.

The access callback for the path node/add/* is node_access(), which invokes hook_node_access(), which is why your access hook is being invoked when the admin menu is present.

You can either remove the admin menu altogether, or remove the links to create new content from it and your hook won't be invoked any more.


As well as their schema and other basic definitions, fields have

Widgets

  Field API widgets specify how fields are displayed in edit forms. Fields of a given field type may be edited using more than one widget. In this case, the Field UI module allows the site builder to choose which widget to use. Widget types are defined by implementing hook_field_widget_info().

Formatters

  Field API formatters specify how fields are displayed when the entity to which the field is attached is displayed. Fields of a given field type may be displayed using more than one formatter. In this case, the Field UI module allows the site builder to choose which formatter to use. Field formatters are defined by implementing hook_field_formatter_info().

Each field needs a widget and formatter to do anything useful, but they don't necessarily have to be implemented by the same module that implements the field. For example, you could piggyback off of one of the select widgets if that made sense for your field.

For full code examples, check out the Examples module


Finally I got the solution by digging Drupal code.
We can get the real path or absolute path by using the file_system service.

$absolute_path = \Drupal::service('file_system')->realpath('public://2016-03/Places_2.xlsx');


How do you update a Live drupal server without overwriting the contents?

Thomas Zahreddin is right. But depending on what has changed ("has taken me a couple of weeks ... "), there are more things to consider.

Did you add/change content types. Try to export and import them. Make sure you are not losing contents.
Did you add/change views? You can safely export and import them.
Module Updates. Test them on current data. There's always a chance that user data breaks an update.
Module configuration changes. If it's not too much, take notes and redo them. Else try the features and strong arm modules. Another option is to figure out the exact variable names and write the values into the settings.php.
You have additional content in the dev system. Here things get really hairy. You can try the deployment module or node export. But they are no silver bullets.

If you don't have trivial case, I sugest to test your procedure beforehand. And of course take backups of files and data before you start on the live system. (Backup and Migrate comes in handy here.)


You could try the Views Field View module, which allows you to have a view as a field in another view.

So you would set up your view of nodes, filtering by taxonomy term and sorting randomly. Limit this to one result.

Then add another view that just shows the field collection items with a contextual filter for the parent entity id (I can't remember right now what filter you would use).

Then add the second view as a field on the first view.


Trying to make changes to page (post/article) text just before they are rendered

I can't help with the code, but could you use the String Overrides module for this?

Features:

Easily replace anything that's passed through t()
Locale support, allowing you to override strings in any language
Ability to import/export *.po files, for easy migration from the Locale module
Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.


Programmatically append multiple paragraphs to entity reference field on node

When you add a paragraph you also need to pass the revision id:

  $node->field_qs_and_as[] = [
    'target_id' => $paragraph->id(),
    'target_revision_id' => $paragraph->getRevisionId(),
  ];


How do I get the blog teaser view display on a content type?

Short answer:

Yes, you could do it without views. But, it wouldn't be ideal.

Long answer:

Display suite module will let you control the display of the particular content type and its fields. It won't allow you to control the display of a different content type from the other.
E.g. For your my-content-type, it will allow you to change the display settings of the fields of this content type.

If you wish to display teasers of nodes of the blog content type, on the node pages of my-content-type, you will have to do the follow the steps below:

Without views:

Create a custom module.
Load the blog $node using node_load on my-content-type node page.
Using node_view on the $node get the node in the teaser view of the node.
Use drupal_render to render the loaded teasers in a custom block created using hook_block_info.
Place this block in an region only on the my-content-type node page.

With views:

Create a view block of content of type blog.
Select the display method to be content, and select teaser from the settings.
Apply additional settings (filters, relations) as required.
Place this block on the node page of my-content-type.

In other words you let views build your query for you. And you also get an additional advantage of using other features provided by the views module like caching, etc.


How do I get the property of a node object?

Firstly, some background.

When you type $node->something you're getting a FieldItemListInterface. How do you know what values you can use for something? Well you can ask the entity.
$node->getFieldDefinitions()

Now you have a FieldItemListInterface you can iterate over its values, or in the case of single-value field, just its first one. So even if you're using $node->title, title is a FieldItemListInterface even though you'd only expect one item in the list.

So lets get the first value in the list. $node->something->get(0). This gives you a FieldItemInterface. From here you can access the properties of the field item. E.g. $node->title->get(0)->get('value'). Each of these is an instance of TypedDataInterface. But how do you know what you can use for value. E.g. For an entity reference field $node->some_er_field->target_id is valid but $node->some_er_field->value is not. Well you can ask the FieldItemInterface like so $node->title->get(0)->getProperties(). Or alternatively, you can know the data-type of the field and inspect its propertyDefinitions method. E.g. in the case of moderation_state field, it uses an Entity Reference field to track the reference to the moderation state config entity. So that means each FieldItemInterface is actually an EntityReferenceItem and you can check its ::propertyDefinitions() method to see what properties it defines.

So now you have a TypedDataInterface object, how do you get it's value? Well you use its ::getValue() method.

But wait why does $node->title->value work - I don't have to write $node->title->get(0)->get('value')->getValue() - well thats because we're using PHP magic methods on FieldItemListInterface and FieldItemInterface such that $node->title->value calls $node->title->get(0)->get('value')->getValue() for you.

So in summary:

$node->moderation_state->get(0)->get('target_id')->getValue() will give you the moderation state config entity's ID.
$node->moderation_state->get(0)->get('entity')->getValue() will give you the ModerationState config entity, so you can use its methods direct - like ::isPublished() and ::label().
$node->moderation_state->target_id and $node->moderation_state->entity would achieve the same thing respectively.

I did a lightning talk for my colleagues on this, if you're interested the slides are here unfortunately the recording didn't work.


found out what I was doing wrong. 1020 was the default width that was still being used at the General page of Variant even though I changed the default setting in the Panels Mod.


Create node programmatically with menu entries

The code you posted seems a bit frail at places, but if it works for you, we can focus on your specific question.

The main problem is that you are not adding the $menu array to your node object before saving it. You would only need to add it to the object before you save it, similar to this:

$node->menu = $menu;
...
node_save($node);

Cheers and good luck!

P.S.: You can check out this thread for some code examples https://stackoverflow.com/q/2603289/5875098
P.S.2: To get all the terms directly from the $node object:

$terms = array();
$language = 'und'; // or will be provided by some Drupal hooks
foreach ($node->field_tags[$language] as $delta => $value) {
  $termObj = taxonomy_term_load($value['tid']);
  $terms[] = $termObj->name;
}

You can replace the $terms = explode... in your code with this snippet.


Prevent redirect after submitting the form

I have achieved to make the desired redirection like this:

function redirect_to_edit_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == "page_article_node_form") {
        //$form['actions']['submit']['#submit'][] = '_redirect_to_edit';
        $form['#action'] = '?destination=node/' . $form['nid']['#value'] . '/edit';
    }
}

Reference:
https://www.drupal.org/node/1074616#comment-5115792


Why does my Drush post_make hook not run from bash script?

Do you run the script as the same user that you run the drush make directly as?  Or do you perhaps run the script from cron?  Check to make sure that your $HOME environment variable is pointing to the expected directory; if $HOME is not set, then Drush will not find your commandfiles.


Determine which region a menu block is rendered in

Figured this out with the help of an article!

http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion

// Add a region variable to a block.
// http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
function THEMENAME_preprocess_block(&$variables) {
    if (isset($variables["elements"]["#id"])) {
        $block_id = $variables["elements"]["#id"];
        $block = \Drupal\block\Entity\Block::load($block_id);

        if ($block) {
            $variables["content"]["#attributes"]["region"] = $block->getRegion();
        }
    }
}

// add a template suggestion based on region name
// http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
function THEMENAME_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
    if (isset($variables["attributes"]["region"])) {
        $suggestions[] = $variables["theme_hook_original"] . "__" . $variables["attributes"]["region"];
    }
}

That doesn't do exactly what I was trying for, but it does let me use different templates based on which region a block is being rendered in. Close enough for me :)


Reading textarea values per row: what is the internal method?

Drupal doesn't provide a method for that.

Just use whatever PHP splitting method makes sense for your use case. A very simple example might be:

$text = str_replace(array("\r\n", "\r"), "\n", $text);
$vals = explode("\n", $text);


How do I add static html files to my Aegir install

Your static websites cannot be managed by Aegir, so you should setup them separately on your server.

If you really need to restart apache from Aegir interface, just run 'Verify' task for any of the websites installed (hostmaster will work too). On verify, Aegir runs 'apache2ctl graceful' which effectively restarts apache.


I think you can use Flag to do it with some configuration and with Views.


Can I filter entityFieldQuery results by Workbench moderation state?

An EntityFieldQuery can only filter based on fields associated with the entity by default, and since workbench moderation records are held in a custom table outside of the field system the standard query can't include a reference to them.

However, you can extend the query using tags and hook_query_alter, e.g.:

function MYMODULE_query_alter(QueryAlterableInterface $query) {
  // Only change the query if we have the required tag
  if ($query->hasTag('WorkbenchModerationAssigned')) {
    // Join the workbench moderation node history table
    $query->join('workbench_moderation_node_history', 'wmnh', 'wmnh.nid = n.nid');

    // Add the state and current conditions
    $query->condition('wmnh.state', 'assigned');
    $query->condition('wmnh.current', 1);
  }
}

You would then build up your EntityFieldQuery like this:

$articles = new EntityFieldQuery();
$articles->entityCondition('entity_type', 'node')
  ->fieldCondition('field_moderating_user', 'uid', $user_id, '=')
  ->addTag('WorkbenchModerationAssigned');

That's a very basic example which may need some changing, you might also want to join in the workbench_moderation_states table but it depends on your exact requirements.

EDIT

Just for a bit more info you can also use hook_query_TAG_alter() to do this in a more targeted manner:

function MYMODULE_query_WorkbenchModerationAssigned_alter(QueryAlterableInterface $query) {
  $query->join('workbench_moderation_node_history', 'wmnh', 'wmnh.nid = n.nid');
  // ...


The WAMP issue sounds like CRON was not configured properly on a low traffic development site.  All of your scheduled tasks were likely backing up and running only when you loaded your site manually.

As for DAMP, do all php pages never complete or only Drupal?  Also, do static pages complete or time out?


Unset a SQL condition with query builder

Executing the same query builder object twice is not supported.

Instead, build the query with everything except the the two conditions, clone it, add the two conditions, if you have nothing, execute the original (or the clone, depending on which object you picked to execute first).


As part of your build script and/or revision control checkin script, write out a version number to constant in an include file.  Write a custom module that does something with this include file, such as make a block that prints it out, stuffs it into $conf expose the value via webservice, etc.  You could also do this directly to settings.php, too, if you just need a variable.


The best way to execute your custom code after a user logs in is by implementing hook_user_login in a small custom module you build yourself.  Turn that php you wrote into a function then call it.

i.e.

function module_name_user_login(&$edit, $account) {
  module_name_user_function($account->uid);
}

function module_name_user_function($uid) {
$usr = user_load($uid);

$array_roles=array();
//supose i'm logging in from internet
$details = array(
    'uid' => $uid,
    'roles' => array(
        21 => 'Internet'
        )
    );
foreach($usr->roles as $key=>$value) {
  if ($key!=20 and $key!=21) {
  $details['roles'][$key]=$value;
  }
}
user_save($usr, $details);
}

More about custom modules, and modules all around can be found at The Module Developer's Guide

I would not recommend putting custom php in a trigger and action.  Keeping custom code in the database is always dangerous for people coming down the line that have to maintain your site in the future.


Content entity form not displaying the previously selected value

You need to set a default value for the field. Drupal's field system by default assumes a field is empty, you will have to manually add a default value to the field definition.

This default value should be based on your entity's value, or be an empty string or NULL in case there is no value yet. Try something like this:

// Use the entity value if available, or NULL otherwise.
$default_value = !empty($entity->my_value) ? $entity->my_value : NULL;
$fields['content_display'] = BaseFieldDefinition::create('list_integer')
  ->setDisplayOptions('form', [
    'type' => 'options_buttons',
    'weight' => -4,
   ])
  ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
  ->setSetting('allowed_values', $values)
  ->setDisplayConfigurable('form', TRUE);

  // Set the default value on the field.
  ->setDefaultValue($default_value);


Is it necessary to export features with a version number?

It's metadata for keeping track of a Feature release. In D7, the use of Features has two cross purposes:

Bundling Drupal configuration up as a part of a released feature that can be deployed to any site (e.g. a bunch of re-usable content types).
Snapshoting config as code which is useful for capturing config that D7 didn't normally have (and has been supplanted by D8's config management system).

In the first case, the use of version tagging is more useful when you're a vendor of some project leveraging Features. A tag gives you an identifiable way to know what will be rolled back if you force a Feature back to its original state.

If you're using Features solely as config as code, versioning is not really important. Especially, if it's part of a large project that is already leveraging some release tagging.


Webform does not submit, instead redirects to self

I have never had any problem with the Webform module, but if it happened to me I would double check sites/default/setting.php to see if there are any settings for an explicit $base_url or $cookie_domain. The latter is much improbable, since you would probably have problems with logging in.


Get last accessed timestamp value of a user in Drupal 8

getLastLoginTime is not a static method so you would not be able to call it statically like that. You need to get the current user object from a couple of different ways:

1. Use the Drupal::currentUser.

This is easy, but not recommended to tightly-couple your block.

2. Inject the current_user service into your Block by implementing ContainerFactoryPluginInterface.

The disadvantage is that this also has a dependency on the container, but can be mocked.

3. Use the Context system because blocks extend ContextAwarePluginBase.

This is the recommended option in my opinion because there is already a current user context (as well as node contexts) for blocks.

 * @Block(
 *   ...
 *   context = {
 *     "current_user" = @ContextDefinition("type" = "entity:user", "label" => @Translation("Current User")
 *   }
 * )

Then $current_user = $this->getContext('current_user') will get the current user.

Unfortunately there is not a handbook page about using contexts so documentation is relegated to guessing things based on the change record, which itself was no longer accurate at the time of writing this answer.

Interestingly some IDEs (cough PhpStorm 10 cough) choke on the above annotation syntax because.

Finally...

You should look at the documentation for render arrays and the changes to make markup safe.


How do you implement a custom submit handler in hook_form_alter()?

According to the example in the documentation it's the same as for Drupal 7:

$form['actions']['submit']['#submit'][] = 'mymodule_upload_enabled_types_submit';

You can find similar (working) logic in

contact_form_user_form_alter()
editor_form_filter_format_form_alter()
locale_form_language_admin_edit_form_alter()

And a few others besides.


How do I migrate block content from a dev to a production site?

Another answer I haven't seen mentioned here is to use the Simple Block module, which is pretty much identical to core's 'Custom Block' setup, but instead of having a weird hybrid of content + config, you have all the Block settings and content stored in configuration, which can be cleanly exported and imported.

See, for further discussion in Drupal 8 core: Custom blocks cannot be properly exported and imported.


How to add a JS confirmation popup when clicking an #ajax button

Drupal is a PHP framework, and it's amazing how much fancy AJAX stuff you can get using that and the FAPI. But it has it limits and for a use case like this, I would suggest that you use custom JavaScript. Also instead of using the usually JavaScript dialog, you could use jQuery UI to create a themable dialog instead.

Anyways the problem that you're facing is probably caused because you use AJAX on the submit button. Since you are using AJAX for the actual delete call, preventDefault and the like won't work.

What you would have to do is something like this. (This is not widely tested but should work.)

Drupal.behaviors.module = {
  attach: function() {

    var events = $('.confirm').data('events'); // Get the jQuery events.
    $('.confirm').unbind('click'); // Remove the click events.
    $('.confirm').click(function () {
      if (confirm('Are you sure you want to delete that?')) {
        $.each(events.click, function() {
          this.handler(); // Invoke the click handlers that was removed.
        });
      }
      // Prevent default action.
      return false;
    });
  }
}


Something is intercepting the submission to the user password reset form.

The form should post to the user.reset.login route (/user/reset/{uid}/{timestamp}/{hash}/login), handled by UserController::resetPass(), then redirect to /user/{uid}/edit?pass-reset-token={TOKEN}.

This could be a number of different things which you'll have to troubleshoot (e.g. Rules performing some redirect logic on login, an altered form submit handler, Apache redirect, a module performing some redirect logic on a subscribed event, etc.).

Given that the destination URL is essentially appending "/admin" to password reset form URL that should probably clue you in on what is causing the problem.


how to create image upload of difference dimensions

You can either create two image fields, one for the media image and another one for the thumb, or you could just have one and use different Image Styles ( admin/config/media/image-styles in Drupal 7 ) for both the full and thumbnail. You could even add Image Javascript Crop for more fine-grained control of the thumbnail.


A possible reason can be missing .htaccess file in the drupal root directory or if it is present than possibly your web server is not able to read it. For example web server apache reads .htaccess file with help of mod_rewrite module or even if mod_rewrite module is installed on Apache , Apache server do not have Allow override all permissions. One of the way to check issue is related to .htaccess or not can be accessing internal pages with query parameter, for example www.yoursite.com?q=user and see if it works! then chances are issues with .htaccess file.just check you have shared the URL, for me reason looks like to be .htaccess file check your drupal install is having .htaccess file or not if so ask your web master to let your web server to read your .htacccess


My suggestion to you is use list as type and select list as widget then in select list value add something like below :

link1|link1
link2|link2
link3|link3

and after node saved it is completely link .


Error Drupal 7 body content missing when adding new content

The body field is field attached to content type, so if its remove from particular content type, then it mean you have removed the fields from the content type.

You can enable the fields again for the content type by Administrator -> Structure -> Content type -> [type] ->Manage fields.

In the section "Add existing field", you can select the fields "body" and add to content type.


Setting upper limit on user profile picture

You'll find it here: admin/config/people/accounts


What is the proper syntax to call the theme function for a node, passing an argument?

You should use the node_view function for that, which attaches fields to the node and creates a build array, which when rendered will use the node theme function that you try to use directly.


How Can I Prevent Webform Being Displayed in Front Page

The publishing options at Administration » Structure » Content types » Webform are defaults. Edit the particular webform node and uncheck "Promoted to front page".


Is there a reliable way to show Drupal messages from JavaScript?

I'm using Nice messages module to replace every message with a popup in the corner of the screen.

https://drupal.org/project/nicemessages

It lets you choose if you want the messages of a status to stay visible until closed, or auto close after x seconds.
And add a handy "close all" if there are more than one.

If anything, check out how it works. It's a good starting point i guess.


Add permission to taxonomy programmatically

By default, Drupal comes with a single permission to administer  vocabularies, so if you want your new user to be able to access only the new created vocabulary, you should take a look at the module Vocabulary Permissions Per Role. I never used it, but it sounds to fit your needs.

You'll need to explore how it handles the new permission and configure the module each time you create a new vocabulary.


Using PHP namespace hybrid for Drupal modules

It looks like there aren't any technical pitfalls. But, using PHP namespacing is not part of Drupal's coding standards. Clive sums it up nicely in a comment on the question:

  Drupal has it's own coding standards which it's best to follow, and namespacing functions isn't part of that. If you're not bothered about the Drupal conventions, then sure, do whatever works for you...but if you're looking to write a module to contribute back to the community, or want it to be understood easily by other Drupal devs in the future, it's best to stick to standards


How to set HTML value for taxonomy description field using entity_metadata_wrapper

I just encountered a similar situation myself and it looks like you're choices are either taxonomy_term_save() or to update the table directly via  db_update(). The format property belongs to the term itself, rather than the Description property of the term. If you execute $term->getPropertyInfo() you'll see that the format property is not returned. Keep in mind that the Description is a property of the taxonomy entity, rather than a field, but doesn't seem to be accessible via EMW.

taxonomy_term_save()

taxonomy_term_save((object)array(
  'tid' => $tid,
  'description' => $t($descriptions[$info['step']]),
  'format' => 'full_html',
  'vid' => $vocab->vid,
));


How to iterate over all the nodes from a content type

Drupal core provides a class called EntityFieldQuery().  There is also a handy document page for using it, that has lots of examples.  In its simplest form:

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'page')
  ->propertyCondition('status', 1);

$result = $query->execute();

if (!empty($result['node'])) {
  $nids = array_keys($result['node']);
  $nodes = node_load_multiple($nids);

  foreach ($nodes as $node) {
    // do something awesome
  }
}

This will load all published nodes of type "page". You periodically need to adjust this to

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'page')
  ->propertyCondition('status', 1);

$result = $query->execute();

if (!empty($result['node'])) {
  $nids = array_keys($result['node']);

 foreach ($nids as $nid) {
    $node = node_load($nid, NULL, TRUE);
    // do something awesome
  }
}

to avoid loading too much at once, which can cause memory issues.


Why not use a simple db_query()? In many cases, this is a perfectly adequate way of doing things; you can still use named parameters, and you can build your query as you'd like. It actually performs (very) slightly better than a db_select() anyways (see: http://drupal.org/node/1067802 and https://drupal.stackexchange.com/a/1205/26).

The only reason to not use a db_query() for a particular select query is if you need the query to be easily extended or changed by some other module.

$result = db_query('SELECT uid
  FROM users
  WHERE NOT EXISTS(SELECT NULL
    FROM users_roles
    WHERE users_roles.uid = users.uid
  )')->fetchCol();

Anyways, your particular query is a little more complex than normal, but can still be done using D7's DB API. See:

http://drupal.org/node/1001242#comment-3921430
Database query with notExists ($query->condition('', $subquery, 'EXISTS');)


The basic process would be to make the 2nd field an Ajax (AHAH) created field.  Then in this method, set the #autocomplete render element to a URL that uses the first field's value.  Something like:

function simple_ahah_select($form_state) {
if ($form_state['storage']['content']['simple_select_parent']) {
  $element = array(
    '#type' => 'textfield',
    '#size' => '60',
   // Define a autocomplete_path depend on the value selected on the parent select field
    '#autocomplete_path' => 'simple/autocomplete/' . $form_state['storage']['content']['simple_select_parent']
  );
  }
}
return $element;

The Autocomplete URL can probably be a view if you don't want to write code.  But code would be faster.

See this d.o page for some more details


Modify tpl file to print the path to the image instead of the image itself?

From the looks of your devel output (and the error message), each $item is an array, not an object.

You should be able to fix it by changing the line inside the loop to:

echo $item['#item']['uri'];


How to make one field automatically have the date-time of the last change of another field

You may use hook_node_presave to save time in the field

/**
 * Implements hook_node_presave().
 */
 function jysk_reviews_node_presave($node) {
  if ($node->type == 'my_type') {
    if ($node->my_changed_field[LANGUAGE_NONE][0]['value'] != $node->original->my_changed_field[LANGUAGE_NONE][0]['value']) {
      $node->my_time_field[LANGUAGE_NONE][0]['value'] = time();
    }
  }
}


Adding a webform in a webform confirmation

Could you not just redirect after a submission so it goes to a node page that has the other form on it? Rather than trying to put the webform into the message? As that message content could be in a drupal message rather than page content


I think you just have the primary navigation enabled in your theme. To see the second level, enable the secondary navigation in your theme settings. But this will split you're navigation. A probably better solution is, to use the "Menu Block" module. This allows you to build different kind of navigations in a block.


Passing Node ID/Title to Next Page Webform Field

Assuming you want: The user will create a node. Upon submission a form will be displayed showing the node id pre-filled in a form.
Make a module called example:

// example.module:
// we created a node type "product" (using UI). Saving this content
// will trigger the product form
/**
 * Implements hook_ENTITY_TYPE_insert().
 * @param \Drupal\node\NodeInterface
 */
function example_node_insert(NodeInterface $node) {
  if ($node->bundle() == 'product') {
    $nid = $node->id();
    $response = new \Symfony\Component\HttpFoundation\RedirectResponse(\Drupal\Core\Url::
    fromRoute('product.form', ['nid' => $nid])->toString());
    $response->send(); // When OO we will return the response object instead
  }
}

// example.routing.yml
product.form:
  path: '/form/product/{nid}'
  defaults:
    _form: '\Drupal\example\Form\ProductForm'
    _title: 'Product Form'
  requirements:
    _permission: 'access content'

// src/Form/ProductForm
<?php

namespace Drupal\example\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;

class ProductForm extends FormBase {

  /**
   * @var NodeInterface
   */
  protected $node;

  public function getFormId() {
    return 'example_product_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state, $nid = null) {
    // if you need to load the node
    // $this->node = NodeInterface::load($nid);

    $form['node_id'] = [
      '#type' => 'textfield',
      '#title' => 'Node ID',
      '#value' => $nid,
    ];

    return $form;
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    // TODO: Implement submitForm() method.
    // you can redirect back to the node
  }

}

When dealing with this issue please realize the node id is not available until you save the node.


yes hook_form_alter is the right hook you are looking for.

Something like below. Please check the values of form field inside $form_state and fix the code accordingly.

Basically hook_form_alter will allow you wo conditionally add submit handler to your webform which means if form field value is Y then only your custom submit handler will call, also the way we adding the custom submit handler is by replacing the other handlers so no conflict with your sudmit handler and any other comes by default.

function mymodule_form_alter(&$form, &$form_state, $form_id)
{
   if($form_id == "your_webform_id") {
     if($form_state['your_form_field']['#value'] == 'Y') {
       $form['#submit'] = 'custom_submit_handler_external';
     }
     if($form_state['your_form_field']['#value'] == 'X') {
       $form['#submit'][] = 'custom_submit_handler_internal';
     }
   }
}

function custom_submit_handler_external(&$form, &$form_state) {
  drupal_goto("redirect to a page");
}

function custom_submit_handler_internal(&$form, &$form_state) {
  $redirect_to = $form_state['redirect_field']['#value'];
  $form_state['redirect'] = $redirect_to;
}

The above code is just an idea of how you can approach, please debug it at every step and make it workable for you.


You can add elements to the <head> section of a web page using drupal_add_html_head().

$target = url('enable-javascript', array('absolute' => TRUE));
$meta = array(
  '#theme' => 'html_tag',
  '#tag' => 'meta',
  '#attributes' => array(
    'http-equiv' => 'refresh',
    'content' => "2; url=$target"
  )
);
$noscript = array(
  '#theme' => 'html_tag',
  '#tag' => 'noscript',
  '#value' => drupal_render($meta)
);
drupal_add_html_head($noscript, 'noscript');

API Documentation


In order to solve this issue, I combined the results of two views.

The Primary View

uses the search index and displays indexed nodes
has the correct search facet exposed filters
can't perform a proximity search (without Solr & Search API Location)

The Secondary View

uses the node content and displays non-indexed nodes
can't use search facets for the exposed filters because the nodes are not indexed
can perform a proximity search with just Geofield, GeoPHP, and GeoCoder (all of which we already had installed)

To create the secondary view, I followed the steps outlined here.

Then I used hook_search_api_views_query_alter() to alter the query for the primary view. In this hook, I retrieve the secondary view, pass in the zip code from the exposed filter in the primary view, and execute the secondary view to get the results. Then I turn those results into an array of nids.

Finally, I add a condition to the views query to filter out all nodes that do not have an nid from that array.

/**
 * Implements hook_search_api_views_query_alter().
 */
function mymodule_search_api_views_query_alter(view &$view, SearchApiViewsQuery &$query) {
  if ($view->name === 'my_primary_view') {

    // Try to get the zip code from the exposed filter.
    $zip_code = NULL;
    if (isset($view->exposed_input['field_geo_latlon'])) {
      $zip_code = $view->exposed_input['field_geo_latlon'];
      unset($view->exposed_raw_input['field_geo_latlon']);
      unset($view->exposed_input['field_geo_latlon']);
      unset($view->exposed_data['field_geo_latlon']);
    }

    // Get the second view, pass in the zip code, get the results.
    $proximity_view = views_get_view('my_secondary_view');
    if (isset($zip_code)) {
      $proximity_view->exposed_input['field_geofield_distance'] = array(
        'distance' => '100',
        'unit' => '3959',
        'origin' => $zip_code,
      );
    }
    $proximity_view->init_display();
    $proximity_view->pre_execute();
    $proximity_view->execute();

    // Turn the results into an array of nids.
    $proximity_nids = array();
    foreach ($proximity_view->result as $proximity_result) {
      $proximity_nids[] = $proximity_result->nid;
    }

    // Add that condition to the view query.
    $view->query->condition('nid', $proximity_nids, 'IN');
  }
}

Note: Initially, the dysfunctional zip code filter from the primary view was filtering out all results when a zip code was entered by a user. I needed to keep this field so that users could still enter their zip code, but I did not want the filter to actually be applied.

To get around this, I edited the settings on the exposed zip code filter in the primary view so that when a zip code is provided, it returns all nodes where the zip code is not empty.

This ensures that entering a zip code into the primary view won't change the result set (technically it will remove results without zip codes, but that's ok) but will still allow us to retrieve the value from the input and pass it to the secondary view for the "real" proximity filter.


According to the code, these are the admin routes. The links file would indicate that Conditional Fields should appear in the Structure area of the admin. Did you clear cache after enabling it? It should be in the Structure menu.


How do I set/get third party settings on a content block?

ThirdPartySettingsInterface is used by config entitiy types:

Interface for configuration entities to store third party information.
A third party is a module that needs to store tightly coupled information to the configuration entity. For example, a module alters the node type form can use this to store its configuration so that it will be deployed with the node type.

BlockContent is a content entity type, and doesn't implement the interface, hence the error.


How can I add an argument in the URL that link from a content

You could add the Title ID field to your view, exclude it from display, move it above the link, enable rewriting on the link field and write the link format you want, including the Title id.

Edit following the follow-up question:
Well, in my opinion, you shouldn't have to put the Title id in the URL at all. What I wrote above solves your specific problem but, really, I think you should do things differently and thus wouldn't have this problem or the follow-up one.

Link to node/quoteid and load the Title node by looking at field_title_id (replace by the actual field name). You can do that loading in hook_preprocess_node by calling node_load($node->field_title_id[LANGUAGE_NONE][0]['nid']) from there you can either render the whole title node (node_view) or just get one field and send it to your template.

Basically, the Quote->Title relation is in the database, there's no reason you should have to express it in the form of a URL. The reverse would make sense, if you had a Title page where you want to show a single quote.

Second edit following the second follow-up question:

To display all other Quotes linked to the same title you could create a view with Title ID as a contextual filter. You can render the view manually in your template, passing it the Title ID. That'll display all quotes, including the main one displayed in that page. You probably want to filter that one out one way or another.


The way it worked for me was by adding [path] at the end of the fields of the view and using css (position: absolute).
The best way would be to rewrite the image as link but never worked so I did it by css.


How to delete content type menu item in .install file on module uninstall /disable

Using a hook_uninstall() in your .module you can implement.

/**
 * Implements hook_uninstall().
 */
function YOURMODULE_uninstall() {

  // List custom content types that you want to delete
  $custom_ctypes = array(
    'blog',
  );

  // Go through each and unlock the content type
  foreach ($custom_ctypes as $ctype) {
    db_query("UPDATE {node_type} SET `custom` = 1, `locked` = 0 WHERE `type` = :ctype", array(':ctype' => $ctype));
  }

  // Clean Drupal cache; this is necessary for the "Delete" link to appear
  drupal_flush_all_caches();

}

Now you'll see the delete link on the menu and you can delete the content type. I think it's the only way you can delete the content type with fields.

But you can try using the function below too, afaik it will not delete the content fields:

/**
 * Implements hook_uninstall().
 */
function MYMODULE_uninstall() {
  // delete the content type
  node_type_delete('CONTENT_TYPE_NAME');
  variable_del('node_preview_CONTENT_TYPE_NAME');

  // node type rebuilds
  node_types_rebuild();

  // rebuild the menus
  menu_rebuild();
}


I think you're asking for a link to a View like drupal/project11/1 or drupal/project11/2. You can do this with Clean Pagination module.

  Clean Pagination is a very simple module that allows you to enable
  clean URL pagination for specified pages. The way Drupal typically
  works, if you had a view with the URL 'my-view', subsequent pages
  would normally use a query to pass the page number, as in
  'my-view?page=2'. When Clean Pagination is being used for a page, it
  will create a url like 'my-view/2'.

  Currently, the module has just two settings: 1) Set the pages where
  you want clean pagination enabled, and 2) Enable
  search-engine-friendly pagination hyperlinks.

  The search-engine-friendly pagination hyperlinks is an experimental
  feature you can optionally turn on that will add the page URL to
  pagination links, and then remove them via jQuery. To a user, it will
  look like a single number, but to a screen readers and search engines
  it will have the url in the hyperlink text, which is usually a good
  thing.


General error: 1366 Incorrect integer value while uploading image

You don't have any values for these columns in the SQL query: field_third_section_image_alt, field_third_section_image_title, field_third_section_image_width,
field_third_section_image_height
So there must have something for these fields in order for the query to work. Have a look at the code and see why they are not set.


How to migrate users from old drupal d6 site to new drupal 7 site?

Check this article . It describes how to use migrate module and it's API.
Code from this article:

First of all we need to create module by adding folder with name my_migration adding my_migration.info and my_migration.module files. So lets start, code below will have a lot of comments:

//my_migration.info file

name = "User Migrate"
 description = "Migration of data from Drupal 6 to Drupal 7"
 package = "Custom Migrate"
 core = 7.x
 dependencies[] = migrate
 dependencies[] = migrate_extras
 dependencies[] = field
 dependencies[] = file
 dependencies[] = text
 dependencies[] = path
 dependencies[] = taxonomy

 files[] = includes/users.inc

//my_migration.module file
// this file can be empty but we will define some constants
<!--?php /*
 * Define some constants to use in class
 */
define("SOURCE_DATABASE", 'd6_latest'); // Put drupal 6 db name you should also add settings to settings.php
define("CONNECT_NAME", 'migrate');// name of connection to drupal 6 db in settings.php
define('SOURCE_TERM_GARDEN_CAT', 3); // When we will migrate terms we will use it.
define('SOURCE_URL', 'http://path_to_drupal6.site');
define('MIGRATE67_SITE_DIRECTORY', 'public://');

//my_migrate_migrate.inc you should name this file as module_name_migrate.inc
// if not your migration won't be autoloaded.
<?php

/**
 * Implements hook_migrate_api().
 */
function my_migrate_migrate_api() {
  $api = array(
    'api' =?--> 2,
    'migrations' => array(
      'MfUserMigrate' => array('class_name' => 'MfUserMigrate'),
    ),
  );

  return $api;
}

//my_migration/users.inc

<!--?php /**
 * User migration class to migrate users.
 */
class UserMigrate extends Migration {
  public function __construct() {
    parent::__construct(MigrateGroup::getInstance('UserMigrate'));
    // Select fields from the Drupal 6 user table.
    $query = Database::getConnection('default', CONNECT_NAME)
      -?-->select('users', 'u')
      ->fields('u', array('uid', 'name', 'pass', 'mail', 'created', 'access',
        'login', 'status', 'picture', 'init'));
    // This is supposed to get roles not sure how.
    $source_fields = array(
      'uid' => t('User ID'),
      'roles' => t('The set of roles assigned to a user.'),
    );
    // Set source and destination.
    $this->source = new MigrateSourceSQL($query, $source_fields);
    $this->destination = new MigrateDestinationUser(array('md5_passwords' => TRUE));
    // Set up database maping.
    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'uid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'description' => 'D6 Unique User ID',
          'alias' => 'u',
        )
      ),
      MigrateDestinationUser::getKeySchema()
    );
    // Add simple field mappings
    $this->addFieldMapping('is_new')
      ->defaultValue(TRUE);
    $this->addFieldMapping('uid', 'id_to_preserve');
    $this->addFieldMapping('name', 'name')->dedupe('users', 'name');
    $this->addFieldMapping('pass', 'pass');
    $this->addFieldMapping('mail', 'mail')->dedupe('users', 'mail');
    $this->addFieldMapping('language')->defaultValue('');
    $this->addFieldMapping('theme')->defaultValue('');
    $this->addFieldMapping('signature')->defaultValue('');
    $this->addFieldMapping('signature_format')->defaultValue('filtered_html');
    $this->addFieldMapping('created', 'created');
    $this->addFieldMapping('access', 'access');
    $this->addFieldMapping('login', 'login');
    $this->addFieldMapping('status', 'status');
    $this->addFieldMapping('picture')->defaultValue(0);
    $this->addFieldMapping('init', 'init');
    $this->addFieldMapping('timezone')->defaultValue(NULL);
    $this->addFieldMapping('roles', 'roles');
  }
  // Set up Roles.
  // massage the user roles before saving
  public function prepareRow($current_row) {
    $source_id = $current_row->uid;
    $query = Database::getConnection('default', CONNECT_NAME)
      ->select('users_roles', 'r')
      ->fields('r', array('uid', 'rid'))
      ->havingCondition('r.uid', $source_id, '=');
    $results = $query->execute();
    // add the anonymous role for everyone
    $roles = array('1' => '1');
    foreach ($results as $row) {
      // adjust the old to new role id's
      // Editors (rid 7) need role id 4
      if ($row->rid == 7) {
        $roles['4'] = '4';
      }
      elseif ($row->rid == 4) {
        // producer from 4 to 5
        $roles['5'] = '5';
      }
      elseif ($row->rid == 5) {
        // blogger from 5 to 6
        $roles['6'] = '6';
      }
      elseif ($row->rid == 8) {
        // freelancer 8 to 7
        $roles['7'] = '7';
      }
      else {
        // Collaboraters are role id 5 in both old and new dbs
        $roles[$row->rid] = $row->rid;
      }
    }
    $current_row->roles = $roles;
    return TRUE;
  }
} // close the ourUserMigration class


On drupal main page menu, number after /node/7/1

Not sure I fully understand the question, but my 2 cents.

First, default Drupal URLs take the format of /{entity}/{id}/{action}, eg. /node/7/edit and /node/7/view. In both cases you are looking at the 7th node to be created, the first is the edit (admin) display, the second is the default display that visitors will see (view is dropped so you only see /node/7.

The second argument in your example is a little tricky as numbers don't give much away, so without knowing every module you have installed I would assume this is related to your template.

You can tell if this is the case by changing template to the default.

If these are the result of the custom template, the have a look in template.php as this is where theme level custom logic is done. On the off chance it hasn't been done well, have a look in the page.tpl.php and node.tpl.php files too.


Why is JW Player not working in custom Content Type?

There are many ways you can do this

Jwplayer Drupal Module

Video : http://www.youtube.com/watch?v=mAAIfi0pYHw

Embedding jwplayer in HTML5

http://www.longtailvideo.com/support/jw-player/28839/embedding-the-player/

For your example :

WRONG CODE (dont use)

page24.mp4

Try This


Page manager, Panels and theme suggestions

If you don't already have one create a yourtheme.layouts.yml file in your theme folder. There you will define the regions, preview icons, and labels.

custom_2col_brick:
  label: Two Column Brick
  category: My Custom Layouts
  template: layouts/custom_2col_brick
  icon: layouts/custom_2col_brick.png
  regions:
    left:
      label: Left
    right:
      label: Right
    footer:
      label: Footer
custom_1col_landing:
  label: One Column Landing
  category: My Custom Layouts
  template: layouts/custom_1col_landing
  icon: layouts/custom_1col_landing.png
  regions:
    main:
      label: Main Region
    footer:
      label: Footer

Now you can create your page__custom_2col_brick.html.twig and page__custom_1col_landing.html.twig files in your layouts folder. Inside there you can define your template. For example custom_1col_landing.html.twig could contain

        {{ content.main }}

        {{ content.footer }}

Once finished you should have the following files. (The preview icons are optional)

/yourtheme/yourtheme.layouts.yml
/yourtheme/layouts/custom_2col_brick.html.twig
/yourtheme/layouts/custom_1col_landing.twig


How to change authoring information with Rules?

I can't remember exactly, but you can create an action "Fetch entity by ID". Add user as the entity type, and create another action "Set a data value" with selected data [node:author]


MySQL server has gone away - production site

Culprit may be max_allowed_packet which is too little. Drupal Requirements page suggests 16M, but it depends on your site. If you are not able to get sufficient memory allocated, better change host.

  When using Drupal 5.x or later, particularly with contributed modules,
  it may be necessary to set the system variable max_allowed_packet to
  at least 16M. Some inexpensive hosting plans set this value too low
  (the MySQL default is only 1M). In that case, you may need to choose a
  better hosting plan. A value of 1M may be sufficient for 5.x.


How to auto assign node reference value D7

I found the answer by creating own module.

First I create the View which finds Card nodes by dob field of the user, then inside the hook_user_presave() function I call views_get_view_result() and finally assign the card_ref field like this:

$edit['field_card_ref']['und'][0]['target_id'] = $card;


Save selected values from a checkbox into a field

I think you what you want is an entity reference field.

Go the manage fields for your content type and create a new field of the type entity reference. In the setting for number of values choose unlimited and as widget choose checkboxes.

This will save the values for you, and display the chosen ones when the node is edited.


What is the best practice to index remaining content with solr?

The Apache Solr configuration page (/admin/config/search/apachesolr) provides a button under actions to index all queued content, which should send everything left in the queue. That can put a great deal of load on your server, so you should only use that option with some thought about how/if it will effect your users.

When I did a large import recently I went ahead and pushed it all the Solr as quickly as possible, but I was able to do that before the site went live. That meant that when users arrived the search index was complete.  If I'd had to do it while it was in production I would have spread it out to make sure the server was very responsive when they first started to use it.

The load that comes from extra cron runs is site specific. Some sites you can't really see the effects other sites it can have a noticeable slowdown from cron runs. I have worked with sites with light cron loads (or powerful servers) that run cron once a minute to allow functions like the Solr index or external data syncs stay very close to current. The 'right' answer here depends on your site, your server, and your users.

Also remember that you do not benefit from having cron run faster than it takes for an individual cron run to complete. If you have your Solr sync setup to send lots of large files for indexing in each pass it is possible your cron runs take more than two minutes.


Drupal Installation running without settings.php (multisite)

Have a look at sites.php in your sites folder.

 $sites = array(
   'devexample.com' => 'example.com',
   'localhost.example' => 'example.com',
 );

  The above array will cause Drupal to look for a directory named
  "example.com" in the sites directory whenever a request comes from
  "example.com", "devexample.com", or "localhost/example".

So in your case you should have 'drupal.abcd.com' => 'default'

The reason why its picking up settings file from abcd.com is because when a request comes for drupal.abcd.com it looks for folder drupal.abcd.com since that folder is not there it will look for next match like abcd.com and it picks it up from there.

I am not sure about Drupal 7 site set up but playing around with sites.php should fix it.


How can I send email to user that is not logged in since 30 days?

You can use the Rules module to do this.

Make a rule that that is triggered when a user logs in. Make this rule schedule sending this e-mail in 30 days. Let the identifier of the task be something like 30-days reminder for [account:uid]. This way, if the user logs in within the next 30 days, the scheduled task will be overwritten - pushing the 30 days e-mail.

Make sure to activate the Rules Scheduler module.


hook_form_alter checking $user->uid == $node->uid

hey You can simply do this :-

function custom_form_alter(&$form, $form_state, $form_id)
 {
    global $user;
    $node = node_load(arg(1));
    if($form_id=='custom_type_node_form')
     {
       if($user->uid == $node->uid)
        {
          $form['#attributes'] = array('class' => 'test-class');
        }
      }
}

I hope this will work for you.


The Context module would help here. It allows make 'sections' within your site based on selection rules like the path, views or menus chosen etc. Using Context you can apply a CSS class to the body based on the current section and then make the background image change based on that.

Context also allows you to use alternative layouts and you to re-order blocks as needed, and there are many add-on modules for it to extend its abilities further.


How do I render user Login block in main menu?

Block content can either be a string or a render array. As such you need to run it through render:

$block_content = module_invoke('user', 'block_view', 'login')['content'];
return '
' . $variables['tree'] . render($block_content) . '
';

It's worth bearing in mind that the user login form isn't wrapped in
 tags, so unless you're altering the markup for that form elsewhere, your code will produce invalid markup.


You need to use hook_form_alter for this requirement. You can create a submit function for the same & declare it as submit function for previously created alter function. You can access $form_state into that.

In same way you can have your own validate function etc.


Make page accessible to logged in users only

If it's a specific page on your system, create a page-----.tpl.php for it and put in there something like:

<?php if ($logged_in): ?>
  // do whatever you want for logged in users
<?php else: ?>
  // do whatever you want for anonymous users
<?php endif; ?>

If you are using Drupal 6, the http://drupal.org/project/content_profile module allows for all sorts of additional profile content fields.  In Drupal 7 I am assuming you'd use profile2 but I am only now learning about D7 (mostly from answering D7 questions with D6 answers ;)


How to make a style plugin available only for certain types of panes?

I figured out two ways to do this.

First way

It requires that any style plugins you want to filter be

provided by the module in which you're doing the filtering (unless you want to hand-code in a list of modules or something), and
named such that the machine name includes the name(s) of the content type(s) of the panes on which it should be able to be selected.

Inside a hook_form_FORM_ID_alter():

// Only show style plugins relevant to the type of pane we have.
$type = $form_state['pane']->type;
$this_module = basename(__FILE__, '.module');

foreach ($form['style']['#options'] as $key => $style) {
  $style_info = panels_get_style($key);
  $module = $style_info['module'];
  // If the style plugin was defined by our module and it does not have the
  // current pane's type in the name, don't make it an option.
  if (($module == $this_module) && (strpos($key, $type) === FALSE)) {
    unset($form['style']['#options'][$key]);
  }
}

Second Way

After doing it the first way, I wanted to make it more robust (not rely on naming conventions) so I submitted a feature request to Panels and attached some patches. Issue here: https://www.drupal.org/node/2320045

This way allows you to just add something like 'content type' => array('foo', 'bar', 'baz'), (Where foo, bar, and baz are the machine names of Panels content types) to the $plugin declaration, along with the title and description and all that. If you have plugins that don't have that, they won't break, they'll just continue to appear as options for every content type. If you do specify some types, it will only appear as an option on panels of those types.


How to integrate Field collection module in Views?

What kind of view are you creating?

Since the collection is being used in the user entity you should create a user view. This will allow you to set the user id filter you want to set.

Once you create that user view you will need to add the field_collection relationship to display those appropriate field.

This is assuming you are using the latest field_collection - dev version.
Hope this helps.


Delivery Date Changes Price field value with New Custom Field

Rules will be the best option in the above mentioned cases. You can use "data validation" to compare both fields and set value of the "product price" field accordingly


Deleted files for node are being included in view for services

You should use file_usage_delete to remove file usage records to nodes that files was having relations so you stop that problem for future deleting files on nodes.

And you still have to fix it for the existing nodes I suggest two ways

first : write a script to loop on file_usage records and check if the not currently used in the node (via node load and check fid exist) if so delete that record (if u have small number of rows in that table)

secod : Implement hook_views_pre_render  and do the same check.

the first is preferred however it may take long time but it will stop the problem reason


Fetch images across the internet with File API

You might want to try just leaving the remote files as remote and have something like http://drupal.org/project/remote_stream_wrapper? There's an open issue in the module to add a field widget for image and file fields to support just a simple URL entry for a file.


Display hash anchor tags into drupal 7 menu items without modifying hooks or adding modules?

Drupal cannot do this out of the box. However, you can use the Special menu items module to create a new menu item, and place "nolink" in the path settings.


An invalid implementation mymodule_form_alter was added by hook_module_implements_alter

The exception is raised from the following code. (See ModuleHandler::buildImplementationInfo().)

    // If a new implementation was added, verify that the function exists.
    if (!function_exists($module . '_' . $hook)) {
      throw new \RuntimeException("An invalid implementation {$module}_{$hook} was added by hook_module_implements_alter()");
    }

It simply happens because, in your case, there isn't any mecca_hierarchy_access_form_alter() or similar hook, most probably because there isn't any mecca_hierarchy_access module.

The code you want to use is probably the following one.

/**
 * Implements hook_module_implements_alter().
 */
function mymodule_module_implements_alter(&$implementations, $hook) {
  if ('form_alter' == $hook && isset($implementations['mymodule'])) {
    $group = $implementations['mymodule'];
    unset($implementations['mymodule']);
    $implementations['mymodule'] = $group;
  }
}

Always check the implementation of your module has not been already removed from another module, or your hook implementation would actually set $implementations['mymodule'] to NULL.


How can I avoid the installation directory appears in the site URLs?

Set server DocumentRoot to Drupal folder

As mentioned by @leymannx you have to configure your server virtual host to use the drupal1 as the DocumentRoot.

<VirtualHost *:80>
    ...
    DocumentRoot /path/to/drupal1/

    <Directory /path/to/drupal1>
      AllowOverride All
    </Directory>
    ...
</VirtualHost>

RewriteBase on a shared host (in Drupal .htaccess)

If you're on a shared host you won't have access to change DocumentRoot. Instead, you can adjust RewriteBase in Drupal .htaccess file (or $base_url in settings.php).

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
RewriteBase /drupal1


Commerce Order id as seletion list in view filter and limit to 10

You can do it in views.

Add a new view for the product display type.
Add a relationship under "Advanced -> RELATIONSHIP" with the product, something like "Content: Referenced product", check "Require this relationship".
Add a filter in "FILTER CRITERIA" & choose "Commerce Product: Product ID" by help of added relationship, expose this filter.
Show it wherever you want, like you can make tab in the profile page etc.


How can I override the empty search message?

You can implement template_preprocess_item_list (or hook_preprocess_HOOK to be precise) in your theme or module to override that.

/**
 * Implements template_preprocess_item_list().
 */
function MYTHEME/MYMODULE_preprocess_item_list__search_results(&$variables) {

  $variables['empty']['#markup'] = '<h3>' . t('Foobar') . '</h3>';
}


So I figured this out, it was not straightforward or obvious, and I could find no forum or post detailing this method, so hopefully it helps others.
The preprocess function changes to preprocess field as:

function MYTHEME_preprocess_field(array &$variables, $hook) {
  $element = $variables['element'];

  switch ($element['#field_name']) {
    // Machine name of the field
    case 'field_audio':
      $node = \Drupal::request()->attributes->get('node');
      // separate field (machine name = field_image) that holds image for poster
      $media_field = $node->get('field_image')->entity->uri->value;
      $variables['poster'] = file_create_url($media_field);
      break;
  }
}

Then in the field twig file (field--field-audio.html.twig), replace the appropriate item.content section (or all of them as I did, just in case!)

      {% set attr = item.content['#attributes']|merge({'poster': poster}) %}
      {% set mycontent = item.content|merge({'#attributes': attr}) %}

      <div{{ attributes.addClass(classes, 'field--item') }}> {{ mycontent }} </div>

Finally in the file-audio.html.twig template you just need to add the poster="{{poster}}" like:

<audio {{ attributes }} style="background: transparent url({{ attributes.poster }});">

I've done the same for Video, i.e. using a separate field for the poster of the html5 video tag, using the same method EXCEPT in the field template #attributes is #player_attributes as you should be able to see in the file twig template, named video-player-formatter.html.twig in my case. Happy to post the code if anyone needs it.

Thanks to the drupal forums, twig documentation and of course stackexchange for the snippets I picked up along the way to figure this out.


cannot get custom Omega stylesheets to load responsively

There's something odd about what you wrote in your question, because you mention *.less files. I'd expect to see just .css. Are they really .less?

But more importantly, you should not add css[] lines in the .info file for your width-specific css files. That makes them regular CSS files that will always be loaded. They will be listed in the list of CSS files, and can be turned on and off, as you see.

Take a look at the starter-theme .info file (e.g., starterkit_omega_html5.info), and you'll see that there are css[] lines there only for global.css, and not for any of the width-specific files.

Take those lines out. Omega will automatically generate loads for the width-specific files. It looks for the files based on the name pattern, and loads them with the appropriate media queries.

If the width-specific files do not appear at all in your page output with media queries, then there may be something wrong with your naming of the files. One common problem is that if your theme name has an underscore (e.g. "my_theme"), then the filenames must have dashes ("my-theme").

One other oddity to know is that the width-specific files for all the widths narrower than the browser width are loaded. So, for instance, if your browser is at "normal" width, the global, narrow, and normal width CSS files will all be loaded, in that order.

MORE:

Don't forget to check the box "Enable the responsive grid" in the theme settings, and also check the box "Use this layout with the responsive grid" for each width you want to include

You should see something like this in every page that's output:

....
@import url("http://yoursite.com/sites/all/themes/mytheme/css/global.css?lxt4yy");</style>

<!--[if (lt IE 9)&(!IEMobile)]>
<style type="text/css" media="all">@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default-normal.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/omega/alpha/css/grid/alpha_default/normal/alpha-default-normal-12.css?lxt4yy");</style>
<![endif]-->

<!--[if gte IE 9]><!-->
<style type="text/css" media="all and (min-width: 740px) and (min-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)">@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default-narrow.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/omega/alpha/css/grid/alpha_default/narrow/alpha-default-narrow-12.css?lxt4yy");</style>
<!--<![endif]-->

<!--[if gte IE 9]><!-->
<style type="text/css" media="all and (min-width: 980px) and (min-device-width: 980px), all and (max-device-width: 1024px) and (min-width: 1024px) and (orientation:landscape)">@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default-normal.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/omega/alpha/css/grid/alpha_default/normal/alpha-default-normal-12.css?lxt4yy");</style>

<!--<![endif]-->

<!--[if gte IE 9]><!-->
<style type="text/css" media="all and (min-width: 1220px)">@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/mytheme/css/mytheme-alpha-default-wide.css?lxt4yy");
@import url("http://yoursite.com/sites/all/themes/omega/alpha/css/grid/alpha_default/wide/alpha-default-wide-12.css?lxt4yy");</style>
<!--<![endif]-->


The Drupal modules decide what to cache (and for how long etc), Redis is just where the cached data is stored.

Having both/all enabled is not inherently redundant (though as 4k4 noted in the comments, there's a theoretical chance that one cache will improve speed so much that it renders the other redundant in terms of further speed improvements).

Enabling the lot will probably be common practice, and if not with Redis as the storage backend then Memcache, etc.


Alter language select on a node add/edit form

See http://cgit.drupalcode.org/redirect/tree/src/Form/RedirectForm.php#n70

The language widget/form element is designed so that when you explicitly provide some options, then it doesn't add the default.


How can I use UUID in a Views relationship?

I figured out how to do this. It doesn't require a custom relationship handler. In MYMODULE.views.inc:

/**
 * Implements hook_views_data_alter()
 */
function MYMODULE_views_data_alter(&$data) {
  // Add a relationship between the field_subscription_uuid field and node UUIDs
  $data['field_data_field_subscription_uuid']['field_subscription_uuid_value']['relationship'] = array(
    'title' => t('UUID'),
    'help' => t('Relationship for field_subscription_uuid to node UUID.'),
    'handler' => 'views_handler_relationship',
    'base' => 'node',
    'base field' => 'uuid',
    'label' => t('UUID'),
  );
}


No more error messages shown, once i uploaded a file of invalid size?

The error about invalid extension which you're seeing is invoked by File module in modules/file/file.js, here is a snapshot:

/**
 * File upload utility functions.
 */
Drupal.file = Drupal.file || {
  /**
   * Client-side file input validation of file extensions.
   */
  validateExtension: function (event) {
    // Remove any previous errors.
    $('.file-upload-js-error').remove();

    // Add client side validation for the input[type=file].
    var extensionPattern = event.data.extensions.replace(/,\s*/g, '|');
    if (extensionPattern.length > 1 && this.value.length > 0) {
      var acceptableMatch = new RegExp('\\.(' + extensionPattern + ')$', 'gi');
      if (!acceptableMatch.test(this.value)) {
        var error = Drupal.t("The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.", {

Since it worked for the first time, but not on the second time, it's possible that you've some JS error which preventing this event to be invoked. If that's not the case, make sure file.js is included on the second time.

To debug that issue, you may create a breakpoint in above code to see if it's triggered properly. If it's not, using DevTools try enabling Event Listener Breakpoints for Control change/submit events, then try to reproduce the issue, so you'll know exactly what's happening.

Test also if you can reproduce the issue with File it-self using the default theme. If not, maybe it's worth to report a bug against that module.


Collapsed and collapsible Field Sets in Admin

I have solved it installing the module Field Collection Fieldset, and instead of Embedding the Field Collection, I have put it as a Fieldset, and then one of the options is to be shown Collapsed at rendering. All with a module.


Now there is a module for that ;) It's the Developer Docs module.
Here's a brief description about it (from its project page):

Developer Docs is a module specially made for drupal developers (amateur). When a new module is installed, it is hard to find what changes it does unless we look into the code. This module provides an overview of "what it does" without looking into the code.
This Module generates a document automatically based on the drupal elements used in the module such as:

Administration menu
Hooks
Database Schemas
Themes
Variables
Blocks
Node types
Entity Types
Fields (Formatter, Widget)
Field Formatters
Field Widgets
Hooks Created

After enabling this module, list of installed modules will be available at admin/reports/developer-docs/


You can use PersianTools modules,
Features

This module is going to cover some basic features required for Persian
websites.
Fix possible misplaced chars in mixed Persian and English texts
Find a way to fix Calendar.
Convert English numbers to Persian numbers.
Fix sort issues for persian characters.

One of its features is Convert English numbers to Persian numbers. ( indeed Persian number is Arabic digits ).
Install this module and go to its settings and just active convert digits.
Also you can convert all Latin digits to Arabic with some Js code.
Try something like this (put it in custom JS file and load in each page_
String.prototype.toIndiaDigits= function(){
  var id= ['list of arabic digits'];
 return this.replace(/[0-9]/g, function(w){
  return id[+w]
 });
}
var content= $('body').html();
$('body').html(content.toIndiaDigits());

See this articles about how change Latin digits to Arabic
https://stackoverflow.com/questions/1675786/convert-from-english-digits-to-arabic-ones-in-html-page
https://stackoverflow.com/questions/21415121/convert-english-digits-to-arabic-digits-in-html-documents
http://jsfiddle.net/McxL5/


how to remove WIDTH and HEIGHT from img-tag in Drupal 8

In your theme open file THEMENAME.theme, example in my case THEMENAME is bartik and file is bartik.theme add code below:

function bartik_preprocess_image(&$variables) {
  if (isset($variables['attributes']['width']) && isset($variables['attributes']['height'])) {
    unset($variables['attributes']['width']);
    unset($variables['attributes']['height']);
  }
}

Clear all cache and see result.


How to translate the author line "Submitted by ... on ..."

While the page /admin/config/regional/content-language holds the actual translated text, it's not the place where the "Submitted by" translation is derived from. To do so you need to

Navigate to Configuration > Regional & language > User interface translation
Search for "Submitted" in the String contains field. Note the uppercase S (thank you @Hudri).
Now enter the translation and save it. Also note the placeholders for author and date information.