Ajax callback returns value but wrapper isn't filled

Edit your code into the code below:

 $form['show_liste_produits'] = array(
     '#type' => 'submit',
     '#value' => t('Lister les produits'),
     '#ajax' => array(
         'callback' => 'stockerAll',
         'wrapper' => 'listeProduits',
     ),
);

$form['listeProduits'] = array(
    '#type' => 'container',
    '#attributes' => array('id'=> 'listeProduits'),
);

If it doesnt work,make sure first if stockerAll is called. Insert watchdog('test','test'); in the stockerAll function . After doing so, run the program, check your drupal database, particularly the watchdog table and check whether 'test' is in the latest log.

function stockerAll($form, $form_state){
    watchdog('test','test');
    return 'test';
}

If stockerAll is called, clear cache of the browser to make sure the updated code is the one executing. Else, there's something wrong with the way you invoke your function.


How to style a webform like a spreadsheet?

It sounds like you're looking for Webform Table Element that will render your webform inside a table.

  This module will add a new component to Webform module that allows you
  to render multiple components inside a table element.


How to remember the selected foo before and after a registration process?

I tried a lot of things with logintoboggan but the unauthenticaed role makes it diffecult for other modules to make well. So if you try to establish this with logintoboggan you are implicied chosing for modules which are only compatible with the adjustment of the login system. Something I do not prefer.

I solved it with the following modules:

Email_registration          fo the username is not needed anymore
GenPas                      for generating a auto password and direct login
Persistent login            for login in for a long time
User email verification     for verify the email
nocurrent_pass              for remove password edit’s profile
email_confirm               when user changes email

When a anonymous gets on the site reqistrating is posssible with only email. With a rule you give the person a role. After that you can do what you like. If the person does not have a role yet and clicks on the link for premium content, you just append the unique id to the registration url and after registration a redirect can pick this up, the person is then verified with a first pre member role.

You send all pre member roles an email with user email verification. If this is verified u can use a rule to upgrade the role. You now have a full registrated process without have the disadvanced of logintobboggan concept and in line with tha fact that no passwords are send by email.


I'm relatively new to Drupal but I've had the same problem recently and this is how I solved it:

install the i18n module and enable the "field translation" sub-module (and its dependencies).
in the boolean field settings (admin/structure/types/manage/[your-content-type]/fields and click the edit link next to the field) make sure you have specified a value for the On and Off states (e.g. Yes/No).
then on the same page (boolean field settings), use the translate tab (on top of the page) and click "translate" for each language you need:
under the Field instance tab, you can translate the label for the field.
under the Field settings tab, you can translate the values for the On/Off states.
lastly (and this is perhaps the less obvious step), go to manage display (for your content type), and as "format" for you boolean field, choose "Default translated" instead of "Default".

Hope this helps.


How to send multiple emails after creating a node

As noted on the Reddit thread, this event will not work as described in this blog unless you are using PHP FPM. For most hosting providers this is the default setup. So, if you are using Apache with mod_php you are out of luck, it seems.

Are you hosting with Apache and mod_php? You'll need Apache and use PHP FPM with some settings changed. Or use nginx.

Sounds like the problem is due to your server not streaming the output. Per the Symfony docs

  Internally, the HttpKernel makes use of the fastcgi_finish_request PHP function. This means that at the moment, only the PHP FPM server API is able to send a response to the client while the server's PHP process still performs some tasks. With all other server APIs, listeners to kernel.terminate are still executed, but the response is not sent to the client until they are all completed.

https://symfony.com/doc/current/components/http_kernel.html#the-kernel-terminate-event


Content encoding error after enabling cache, aggregation and compression

Add this lines to your settings.php file.

$conf = array(
'cache' => '0',
'preprocess_css' => '0',
'preprocess_js' => '0',
'block_cache' => '0',
'page_compression' => '0',
);

or with Drush

// To turn on JS Aggregation

drush vset preprocess_js 1 --yes

// To disable JS Aggregation

drush vset preprocess_js 0 --yes

// To clear cache of JS and CSS only

drush cc css+js

// To enable CSS Aggregation

drush vset preprocess_css 1 --yes

// To disable CSS Aggregation

drush vset preprocess_css 0 --yes


Why does drupal_set_message not appear in the message area?

You do not have to call krumo directly. You can just use the helper function dpm, this will print a krumo output on the message variable.

Example:

dpm($row);


css file defined in .info file is not loading in Drupal 7

As far as I can see in the URL you posted, both css/style.css and js/responsiveslides.min.js are being loaded fine, but there is no trace of the css/responsiveslides.css file. Maybe you are not placing that file in the appropriate directory?

Hope that helps,


How do I programmatically install a module?

Use "module_installer" service.

$installer = \Drupal::service('module_installer');
// Or from the container.
$installer = $container->get('module_installer');

// Install single module.
$installer->install(['module_name']);
// Install multiple modules.
$installer->install(['module_name_1','module_name_2']);

Also for uninstallation of the module use the next example:

$installer->uninstall(['module_name']);


If you enable the RDF module, Drupal will automatically output some RDFa for your content. You can use a RDFa parser to extract it, e.g., http://linter.structured-data.org/. If it doesn’t find any data (under "Raw structured data extracted from the page"), you are likely using a theme that doesn’t support it. Use a default/core theme for testing, you should see it then.

If you want to provide additional structured data for your content types and field content, you need to map the content types to suitable RDF types, and the fields to suitable RDF properties. If you care about SEO, you’ll likely want to use the types and properties from Schema.org, as the big search engines sponsor this vocabulary, and use it for things like rich search results.

One way to add these mappings is using the RDF UI module (which comes integrated with Schema.org).


Uploading images so that they are searchable

To include image data in the core search index, you perhaps could implement hook_search_info and hook_search_index to add the custom image field text attributes (alt, title text etc..) to the search index.

You can then theme the output of the search results by overriding search-result.tpl.php or using hook_preprocess_search_result to add the image thumbnail.

Further core Search API docs here


Create a taxonomy term and defined in your content type
Use Simple hierarchical select or Hierarchical Select to create new term when you add new book "book name is taxonomy term"
Create a view using taxonomy term and select those terms whose parents has value = 0


Yeah, I can confirm Molots statement.

Try to use CKEditor 3.5.3 with the newest Wysiwyg.
Even with patches I could not solve the problems between CKE 4 and wysiwyg.

regards,
SuperEngineer 64

EDIT: Also possible is to install the Develpoment-Version of Wysiwyg. I use it mit CKE4 now.


Force using specific filter text on a content type

Using format permissions in combination with the Better Formats module should allow you to do what you are trying to do.

The Better Formats module allows you to set allowed and default text formats per field - so you can set different allowed formats for both of your fields.


How to pass an array or an object from a module to a theme

In Drupal 6, a menu callback needs to return a string that contains the HTML to output together the output of other modules; alternatively, it can print the output and call exit().

If you need to pass an array to a theme function, then the output returned from the menu callback should be output from a theme function to which the menu callback passes an array.

function pcb_exe($id) {
  $ar = array('arg1'=> 'value1', 'arg2'=> $id);
  return theme('pcb_exe_output', $ar);
}

In Drupal 7 (and higher versions), the output of a menu callback is normally an array that has the format used by drupal_render().
It still possible to pass an array to a theme function, but the parameters passed to a theme function changed.

function pcb_exe($id) {
  $ar = array('arg1'=> 'value1', 'arg2'=> $id);
  return theme('pcb_exe_output', $ar);
}

In this case, there is no noticeable difference, as the parameter passed to the theme function was already an array.
The parameter passed to a theme function since Drupal 7 is an array containing all the values required from the theme function. See the code of theme_vertical_tabs() as example:

function theme_vertical_tabs($variables) {
  $element = $variables['element'];
  // Add required JavaScript and Stylesheet.
  drupal_add_library('system', 'drupal.vertical-tabs');

  $output = '
' . t('Vertical Tabs') . '
';
  $output .= '
' . $element['#children'] . '
';
  return $output;
}


how to update a node field value with jQuery callback the drupal way?

The jQuery would be pretty simple, something like this:

$('#link-id').click(function() {
  $.ajax({
    url: '/vacancies_manage/status_callback/' + id1 + '/' + 'id2',
    data: {'arg1': 1, 'arg2': 2},
    success : function(data) {
      alert(data);
    }
  });
});

You'll need to replace id1 and id2 with the arguments appropriate to your situation, and arg1 and arg2 with whatever you want your POST vars to contain.

Then you just need to make sure that you callback actually prints directly to the page, and doesn't return the entire rendered Drupal page so that the jQuery code can receive a response:

function _vacancies_manage_status_update_callback() {
  // Do something with $_POST vars here

  // Print something, perhaps a status message to be picked up in jQuery
  print 'OK';
  drupal_exit();
}


Drupal 7 subtheme location best practice

Themes should be stored in sites/all/themes, not sites/all/modules.

You could certainly add your custom theme to sites/all/themes/custom, but what I do is just add my custom theme(s) to sites/all/themes directly.  I do this because I name my custom themes for the sites I am working on, so it's very clear that the particular theme is specific to the site.

The other reason I don't think a /custom directory is necessary is because, unlike modules, one generally only has five or six themes (at most) installed on a single site.  So there is far less possibility for confusion.


I found the solution myself.

I just created a new route with the requirement _format: json and the path /node/{node} just like entity.node.canonical. Then I could set a controller that is only called when the node is being output in JSON format.

My route definition looks like this:

entity.node.canonical.json:
  path: '/node/{node}'
  defaults:
    _controller: '\Drupal\my_module\Controller\NodeViewController::json'
    _title_callback: '\Drupal\node\Controller\NodeViewController::title'
  requirements:
    _entity_access: 'node.view'
    _format: 'json'


Make sure that you have the required modules installed and enabled.
Your most probalby missing Chaos Tools

Module filter is also a easier way to manage modules


How to assign a user to administer one content type only?

The xpress is not an admin, right? So the xpress won't be able to see the admin toolbar. Have you tried accessing the link of node/add/testcontent, node/node-id/edit? was xpress able to access it? if yes then you need to provide a link/button for the xpress to see when he/she logs in. Then I think you need to use views to show the lists of TestContent where xpress can search/filter.


Commerce Kickstart change full text search product display to https

Maintainer of Commerce Kickstart.

I just checked out the site, and it's using a relative path like Drupal forms are expected to do. From your source:

<form action="/products" method="get" id="views-exposed-form-display-products-page" accept-charset="UTF-8">

The search form is a Views exposed filter exposed as a block. There isn't much trickery going on with the form beyond typical site building.

Also, I did not get mixed content warnings.


Try one of the following modules:
Bean

What is Bean?
Think of a Bean as a method to provide new types
(compared to node this would be a content type) which then provides an
add content interface to create as many blocks as you require (see
screenshot below). The bean content can then be placed around the site
just like any other block.

Boxes

Boxes module is a reimplementation of the custom blocks (boxes) that
the core block module provides. It is a proof of concept for what a
re-worked block module could do.

My personal preference has always been Bean (before I started using Panels more frequently), but I don't think there's a lot in it to be honest.


Webform has GET support built-in, see: Setting Default Values from the URL.

For POST you have access to %post[key] or you can retrieve $_POST and set your values using hook_form_alter().

  Webform allows several special values to be used as defaults when
  configuring a component. The special placeholders are commonly called
  tokens. The tokens Webform supports include:
  %username
  %useremail
  %site
  %date
  %server[key]
  %session[key]
  %get[key]
  %post[key]
  %request[key]
  %profile[key]

Working with Default Values


How can I change the  on a View filtered by NID so that it is the referenced Node's Title field?

You need to "Specify validation criteria" in your contextual filter.

In your Contextual filter scroll down and check the box "Override title" but leave the text box empty.

Next, check the box "Specify validation criteria" and select "PHP Code" from the validator menu.

In the code box enter the following:

if($argument) { // Check that argument is present
    $myNode = node_load($argument); // Load node based on NID
    $myTitle = $myNode ->title; // Parse node data to get title
    $handler->options['title'] = $myTitle; // Change the view's page title to node's title
}
return true;


How can I sort options in an exposed views filter alphabetically?

j.Rowny's answer doesn't work because $form_state is not passed by reference.  You must actually modify the $form variable.  This worked for me:

function yourcustommodule_form_views_exposed_form_alter(&$form, $form_state) {
    foreach($form_state['view']->filter as $filter) {
        if($fid = $filter->options['expose']['identifier']) asort($form[$fid]['#options']);
    }
}


I fixed it; you have to go into Administration » Configuration » Content authoring » Text formats and check the box Converts Media tags to Markup.


My site only listens to the event after I clear all caches

You need to use a Trusted Redirect Response and properly set cache metadata for your response. This is mostly documented in an answer to a related question, Disabling Page Cache for Redirect Response. However, in your case, you'll need to manually build a CacheableMetadata object, so I'll show that here.
// Tell the browser not to cache the redirect by setting these headers.
$response_headers = [
  'Cache-Control' => 'no-cache, no-store, must-revalidate',
];

$response = new TrustedRedirectResponse($url, '302', $response_headers);
// We need to add cache metadata to the response so it can be properly cached by
// Drupal. If redirecting was based on a $node or entity, you could simply call
// $response->addCacheableDependency($node) and addCacheableDependency() would
// automagically pull the correct cache tags, contexts, etc from the object.
// Since your redirect depends on a cookie, you'll have to build a
// \Drupal\Core\Cache\CacheableMetadata object manually.
$cache_metadata = new CacheableMetadata();
// Since you just want to cache the response based on whether they have a cookie
// you can use just the cookies:NAME cache context.
$cache_metadata->setCacheContexts(['cookies:age_gate_ok']);
// Add the metadata to your response.
$response->addCacheableDependency($cache_metadata);

$event->setResponse($response);


One quick option is to add some html markup that wraps the region (if you've disabled the default Drupal theme markup) in your page twig template where you call {{ drupal_block('breadcrumbs') }}.

For instance,

{{ drupal_block('breadcrumbs') }}

and

{{ drupal_block('breadcrumbs') }}

Alternatively, if your theme is setup to render blocks assigned to regions in Drupal's Structure > Block Layout, you could:

install/enable the Block Class module (as of Feb 23, it's in an alpha release for D8)
place two Breadcrumb blocks, one per region
assign your topnav and leftnav classes in the block config screen

For both use cases, you'll need to change your css to target:

.topnav ul
.topnav ul li
.leftnav ul
.leftnav ul li


display a node id within a specific content type

If you're trying to do this for a certain content type, and have a custom theme you're using with your site, I'd suggest modifying the template file for that content type to print out the node id somewhere below or above the content.

However, if you're not very good with theming a really creative way to do it is by creating a view block and enabling it for that content type.  Then the node id can be displayed on the side of the content.  It can be nothing more than a line... doesn't have to be obtrusive.

To do the above:

Create a new view and call it something like 'Node id display' (uncheck the page version of the view and only create a block version).  Restrict it to the content type you want here, and make sure it's displaying fields, rather than titles, summaries or whatever is the default
Under the view's 'Fields' section, remove all fields that appear by default and only dislay the 'Content: Nid' field.  You can change the label to be something like "Node id" instead of 'Nid' if you prefer.
Under the 'Advanced' section of the view, add a contextual filter of 'Content: Nid', and in the configurations, select for it to 'Provide a default value' if a filter is not present.  From the drop-down, select 'Content ID from URL'
Either through a context or from the block's admin page, enable the new block for your specific content type... place the block on a sidebar, above the content, below the content... anywhere you want.

:-)

Hope this helps!


How to add custom css classes to views exposed filters?

Have you considered something like this?

`.view-[viewname] .views-exposed-widgets`

You could use:

theme_form_alter(&$form, &$form_state, $form_id)

Check for the view/form id,  and then add classes:

$form['#attributes']['class'][] = 'test';


How to add a default controller to the  route?

<front> is not really a route that can be resolved for an incoming request, it's just a helper for building a URL.

It works in the opposite way, you create a controller at whatever path you want, and then you set the frontpage to that path on the system information page aka in the system.site configuration object.


How to pass data from a Rules Action to a subsequent Rules Action?

I think you can pass data with Variables , in one action set variable(s) and in next action get that variable(s),this have one bug if concurrent event occur data will return mistake values, a solution for this is using unique variable name per user(or action), I get you a clue (maybe you get idea from it)

in Action1
set Php action

 global $user;
 // some job here
 // $result= .....
 variable_set("action1_result-".$user->uid, $result);

in Action2
set Php action

 global $user;
 variable_get("action1_result-".$user->uid);


Drupal Album/Photos modules error. Not show photos/image/uid

The problem was the Photo Information Block being inactive; it has been now fixed.


First make sure following things are configured properly:

Is Entity API module is enabled in your site?
Have you enabled Logging and errors from admin/config/development/logging page, to see site errors?
In second line you have not defined $user object, are you defined else where?
How are you calling this function?

If everything is configured properly then execute following code:

$name = "Test";
global $user;
$userdata = user_load($user->uid);
$paragraph = entity_create('paragraphs_item', array('field_name' => 'field_userdata'));
$paragraph->setHostEntity('user', $userdata);
$paragraph->field_name[$userdata->language][]['value'] = $name;
$entity->save();


Use this inside your view template file:

print fields['your_field_name']->content;


How to display a list of products in same taxonomy as current product?

After a bit more digging, I came across a wonderful solution: http://scito.ch/content/show-related-nodes-block-based-taxonomy-terms-views-3-and-drupal-7

Create view (block)
Add fields (title, a small image, date, whatever
you like). Or teasers, what works as well.
“Arguments” is from now on called “Contextual filters”, so go there.
Add the filters: “Content: Has taxonomy term ID (with depth)” and “Content: Has taxonomy term ID depth modifier”
Configuration on this filter: → When the filter value is NOT in the URL: → Provide default value → Type: Taxonomy Term ID from URL →
under that, check the box “Load default filter from node page,
that’s good for related taxonomy blocks.” → now check the boxes of
the taxonomies you want involved here
Now you need to add the second filter in order to exclude the current node from the list. Click [+] button of the contextual
filters section.
Select Content: Nid
Set the ‘when argument is not present’ to ‘Provide default argument’
Set the ‘Default argument type’ to ‘Content ID from URL’
Go to “MORE” , and check the “Exclude” box.
Move the filter “Content: Nid” to the top position.
Add a block to your view and embed the block on your node pages
Save your view


How to load jQuery assets before blocks and regions

You have to wrap the javascript to avoid namespace conflicts.

(function ($) {
  $(document).ready(function() {
    $("#slideshow").zAccordion({
        ...code...
    });
  });
})(jQuery);


Let users review draft copies before publish

You could accomplish this with a combination of user roles (writer, peer reviewer, editor, for example) and Field Permissions plus maybe a couple of views for users of each role. More details about Field Permissions (from project page):

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

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

I would add a select list field to your content type that is editable only by peer reviewers and editors. You might call it publishing status or workflow status with the options of "needs major revision, needs minor revision, ready to publish" (just to give a couple examples). Use the field permissions module to make this field visible to the node author, invisible to anonymous users and authenticated users, and editable by peer reviewers, content editors, and site admins.
You could make it fancier by also using rules so that if someone with a given role (e.g. editor) selects ready to publish, the node is automatically published, and/or promoted to the front page, etc.
Hope this helps.


Is Pathauto designed to modify URL requests?

Pathauto only creates path aliases for nodes, users, etc. based on patterns, i.e. /node/23 will also work with /resource/resourcename. However, no redirect is made. If you wish to redirect the node path to the path alias you could use the Global redirect module.

Once an alias is created all menus etc. will use the alias instead of the real path, in fact, all links created with the l() (url()) function.


Javascript added via drupal_add_js() does not get aggregated

The reason it wasn't aggregating is that someone had every_page set to FALSE and preprocess set to FALSE(as @thedotwrite was saying in comment above) in a lot of  drupal_add_js() calls.  (Some of them were set like this because they really shouldn't have been on every page but there were some that really could be on every page).

Not sure why I didn't notice that before :)


Have you tried adding a trim() ? Like :

<div class="banner" style="background-image:url('<?php print trim(render($content['page_banner'])); ?>');

It should just do the trick...

Beyond that, whatever is generating the $content['page_banner'] content is probably adding the unnecessary spaces.


is there any way to implement java into drupal?

Drupal is a PHP web framework. The tools that is uses are those of the web. If you are trying to implement something with XML and Java you are not really using Drupal. There are skills that you have to learn in order to create web pages which are different from those on a phone.

Having said that. I believe that there are some Android front ends for Drupal. That may be a good starting point for you.


Organic group request membership email issue

For OG 7.x-1.x, I discovered that simply by enabling the Rules module, email notification Rules from OG are made active. That did the trick for me.

(Not sure about OG 7.x-2.x, which makes mention of the Message_Notify module on the OG project page...)


Show list of taxonomy terms, with node's current terms given a class

I think I have found a solution that achieves the desired result in good way (in terms of not writing spaghetti php or hardcoding stuff in the theming layer). Instead of providing the full configuration at once, I will try to guide you step by step.

1/ Create a new view (mine is called 'test') that only has a Block display, and displays Taxonomy terms for a specific vocabulary (mine is called 'Target Group'). Use 'HTML list' as the selected Format, make sure the
'Taxonomy term: Name' is added in the list of the displayed fields, also use 'Taxonomy term: Name' as a sorting option in ascending order, select 'Display all items' in the pager settings, and make sure query Distinct settings are DISABLED (we will achieve that via aggregation later on). Save your view. You can see the view results in the preview section of the view manage page, or place the block in the respective node display if you prefer to view it directly in the front end. At this point, you will be able to see a list of all the terms form the specific vocabulary.

2/ Add a new relationship to your view (in the Advanced section). The relationship should be the one labeled 'Taxonomy term: Content with term'. It is highly important (for the rest of the code that will be provided) that you choose this generic relationship option, instead of the more specific one labeled 'Taxonomy term: Content using Target group' (where Target Group is the vocabulary name I used for this example). Provide an identifier for this relationship - I left the default one labeled 'node'. Make sure that 'Require this relationship' is NOT checked - this will create a LEFT JOIN between the terms table and the node term data table. Now go to the fields section and add the field 'Content: Nid' and set it to use the relationship with the aforementioned identifier. Any other field settings do not matter for now - we will adjust them later on. Save your view. At this point you will be able to see plenty of duplicates for all terms, each one with a different nid. Good.

3/ Now go to the contexual filter section and add a new one for 'Content: Nid'. Make sure the 'node' relationship is used. For 'When the filter value is NOT available' choose 'Provide default value' and set 'Type' to 'Content ID from URL'. It is recommended to 'Specify validation criteria' as you see fit. Save your view. The configuration until this step, is actually the one presented in this excellent answer here which has some screenshots too. Up to this point, you will be able to see only the terms with which the current node is tagged. "Duhh, that was the original problem" you'll say, but bear with me as we take it one step further.

You see, when adding a contexual filter, views adds the restriction to the WHERE clause of the generated query (which is good and desired in the majority of cases). The current query generated is the following:

SELECT DISTINCT taxonomy_term_data.name AS taxonomy_term_data_name, taxonomy_term_data.vid AS taxonomy_term_data_vid, taxonomy_term_data.tid AS tid, taxonomy_vocabulary.machine_name AS taxonomy_vocabulary_machine_name, node_taxonomy_index.nid AS node_taxonomy_index_nid
    FROM
    taxonomy_term_data taxonomy_term_data
    LEFT JOIN taxonomy_index taxonomy_index ON taxonomy_term_data.tid = taxonomy_index.tid
    LEFT JOIN node node_taxonomy_index ON taxonomy_index.nid = node_taxonomy_index.nid
    LEFT JOIN taxonomy_vocabulary taxonomy_vocabulary ON taxonomy_term_data.vid = taxonomy_vocabulary.vid
    WHERE (( (node_taxonomy_index.nid = '4072' ) )AND(( (taxonomy_vocabulary.machine_name IN  ('topics')) )))
    ORDER BY taxonomy_term_data_name ASC

But what we DO want in our case, is that the nid restriction is applied as an additional restriction to the LEFT JOIN with the node_taxonomy_index in order to filter the join and not the whole result set. Unfortunately, views does not support that out of the box but after some digging I found that it is programmatically supported in views_join handler which can be gracefully managed via hook_views_query_alter. So, moving on.

4/ In order to implement a hook, you will require a custom module. If you are not sure how, then read the respective documentation. Here is the implementation that removes the nid restriction from the where clause and adds it to the LEFT JOIN clause

function my_custom_module_views_query_alter(&$view, &$query) {
  if ($view->name == "test") {
    // try to resolve the nid from the contexual filter condition
    $contexual_nid = null;
    if (!empty($query->where)) {
      foreach ($query->where as $delta => $where_clause) {
        if (isset($where_clause['conditions']) && count($where_clause['conditions'])) {
          $condition = $where_clause['conditions'][0]; // in the current use case, there will be only one condition
          if (isset($condition['field']) && strpos($condition['field'], "nid") !== FALSE) {
            $contexual_nid = array_shift($condition['value']);
            // remove the nid constraint from the where clause
            unset($query->where[$delta]);
          }
        }
      }
    }
    // add the nid constraint to the relationship
    if ($contexual_nid != null && isset($query->table_queue['node_taxonomy_index']) && isset($query->table_queue['node_taxonomy_index']['join'])) {
      $join = $query->table_queue['node_taxonomy_index']['join'];
      $join->extra = array(
        array(
          "field" => "nid",
          "value" => $contexual_nid
        )
      );
      $query->table_queue['node_taxonomy_index']['join'] = $join;
    }
  }
}

So, at this point, you have a list that has tons of duplicates. "Duh, I had achieved that via 'views_field_view' and with less duplicates" you'll think. Well, no. First of all, the list is now sorted alphabetically, and second, getting rid of the duplicates, now that we are dealing with a single result set, is a piece of cake via aggregation. Back to the view administration then.

5/ In the Advanced section, set 'Use aggregation' to Yes. For field 'Content: Nid', click on the 'Aggregation settings' and set 'Aggregation type' to 'Count'. For field 'Taxonomy term: Name' the aggregation type should be the default 'Group results together'. Save your view and say goodbye to the duplicates.

6/ Last step in order to convert the 'Content: Nid' to useful markup. Click on the field which is now labeled '(node) COUNT(Content: Nid) (Nid)' and apply the following settings:

Create a label: unckeck
Exclude from display: check
REWRITE RESULTS: Rewrite the output of this field: checked
REWRITE RESULTS: Text: 'current' (the actual literal 'current'
without the quotes)
NO RESULTS BEHAVIOR: Count the number 0 as empty: checked
NO RESULTS BEHAVIOR: Hide if empty: checked
NO RESULTS BEHAVIOR: Hide rewriting if empty : checked

And finally click on the Settings link for the HMTL list format and for 'Row class' enter token '[nid]'. Save your view. Everything should look as expected.


How to custom theme Inline Entity Form (IEF) - using a .tpl.php file

I don't think that Inline Entity form supports that. You could alter the behaviour of the form itself though with

 function THEMENAME_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) {
   // your alters
}


This is very tricky but see this helpful link.

Varnish device detection and redirect to mobile site


How can you remove the edit lock on a node?

Did you use the back button to get to your edit page? Have you tried manually going to the node and clicking the edit tab again to see if it reoccurs?

This message is caused when either (1) two users access the edit page and one user saves changes before the other user gets a chance or (2) when a user edits content, saves it, and clicks the back button to get back to the edit page.

https://obrienmedia.co.uk/kb/drupal-website-management/avoiding-the-the-content-on-this-page-has-either-been-modified-by

Are there other users signed in? When all else fails (or rather the first step of troubleshooting always) Flush all cache. Clear your browser cache. Close your browser out. Re-open your browser. Attempt to recreate problem. Is it still happening?


ImageCache action: How do I set the width as 500px and the height will constrain propotion to width?

Found solution
Use "Scale" in Action, Width:500, Heigth:0,
Select "Allow Upscaling"
Then update action.


How do I avoid the "too many connections" error message is shown?

There are two issues here:

Users are seeing site error messages that they shouldn't
The error message itself

For 1, go to admin/config/development/logging and set Error messages to display to None.  Don't worry, this won't affect messages like "incorrect login details" or "page not found, we did a search instead" ... things that the user really needs to know.

As for 2, here are a couple of things to try:

Turn off all your custom modules if you have any, re-enable them one by one to see if you can find the cause
Do the same with contributed modules
Read up on the error message, there are too many things that could be causing it that are non-drupal specific to be useful on this site.


If you want to access nid inside preprocess_page you should try something like this

arg(0) will return 'node' and arg(1) will return node nid.

Provided you must be inside a node.

if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  if ($nid) {
   $node = node_load($nid);
   // creating the node variable
   $vars['node'] = node_load(arg(1), NULL, TRUE);
  }
}


How to install new drupal packages on local apache server

Looks like this is a permission issue. You might want to make sites directory owned by the apache user and the themes or modules folder is writable as well.

$ chown -R www-data sites # Change owner sites directory

If that doesn't work, you might try setting modules and theme dir writable.

$ chmod -R 777 sites/all

Ref: https://www.drupal.org/forum/support/post-installation/2011-01-22/module-installation-requires-ftp-access


How to list page translations next to the original in the same row?

Have a look at the Translation Management Tool, considered as the successor of the  Translation Overview module, and "the" module to move forward with in D8 also. From its project page:

... provides a tool set for translating content from different sources. The translation can be done by people or translation services of all kinds. It builds on and uses existing language tools and data structures in Drupal and can be used in automated workflow scenarios.
This module does not make i18n or any other language module for Drupal obsolete. It does only facilitate the translation process.

One of its community pages also contains some related screenprints, such as this one:

Plan B
Another possible approach that might be worth experimenting with, is to try to tune the View itself, by using "rewrite results" for each of the values in the columns with "Czech", "English", etc. And use these values to rewrite them to shown an image (like "Czech.jpg", "English.jpg", etc) with an "Edit" link below it. For the "Add"-equivalent you'd have to check what value you get for a 3rd language if you don't have a translation yet: if you do get something for that also, you could using a similar rewrite result, but then with an "Add" link.


When can a contrib module considered to be stable?

Read the docs.

Release naming conventions

  rc: A release candidate should only be created when the all critical bug type issues are reported fixed in the project's issue
  queue. This tag should only be used when the developer believes that
  the project is ready for use on a production site. There is no
  official best practice for how long a project should be a release
  candidate before creating a official .0 release, but it is suggested
  that it should be out for at least a month with status set to "needs
  review". If something (e.g. a new critical bug is reported) makes it
  necessary to create a new release during this period, a new release
  candidate should be created and this should remain for at least a
  month with status set to "needs review".


How to change the title of the page dynamically?

You need to add an onclick() event handler for all tabs.
Assuming UL LI layout http://jsfiddle.net/k7Gkm/

$(".my_tabs").click(function(){
 $("#header").html($(this).html());
});


Notice: Trying to get property of non-object in my_module_get_nodequeue_id_by_name() (line 30 of my_module/my_module.module)

fetchField() returns a single value, not an object. You either want to use fetchField() like this:

$qid = db_query('SELECT qid FROM {nodequeue_queue} WHERE title = :title', array(':title' => $name))->fetchField();
return $qid;

or use fetchObject() instead:

$data = db_query('SELECT qid FROM {nodequeue_queue} WHERE title = :title', array(':title' => $name))->fetchObject();
return $data->qid;


Its better to use drush.

Goto your project source folder from terminal.

Use the following command to upgrade.

drush pm-update projects

Ex: root@karthik$ drush pm-update projects drupal-6.34

This will update your drupal core to 6.4 version.


I think you are missing one of the buried options.

Make a view, configure it the way you need.
Make a Page display, and set the path to article/me
Add a Relationship for Content: Author.  This is likely not needed, unless you want to pull in author fields and display them or if you need the author name explicitly somewhere in another filter.
Add a Contextual Filter for Content: Author uid; it should automatically pick up the relationship.  In the options for When the filter value is not available, select Provide default value.  In the dropdown, choose User ID from logged in user.

I think you are missing the last part of the final step.  I always forget where that one is.  It helps if you configure views to always show the advanced settings (see admin/structure/views/settings).


What's a good module for moderating content submissions?

The Workbench module will help you. You could set up some Rules to accomplish the same tasks.


How can I easily verify if a core or module update has not broken anything?

In general Drupal core updates should not break Drupal core. If you upgrade stable community modules to a newer stable release -- again you should not encounter regression error problems.

That being said and long as your not the edge with alot of modules it shouldnt be such a huge worry -- but I similar worries. Backup, Backup, Backup always.

I doubt you have 1000s of unique pages. There are tools like Selinium, or JMeter or Java's The Grinder that let you script interactions with a webpage for known results. You could script your set of possible necessary functionalities on a handful of generic pages.

There's no way around testing if you really have to test and assure error-free site usage.


Drupal comes with a login block you can put in any of your theme regions to have show up on that page.

Or you can use drupal_get_form('user_login') if you want it to show up in your content somewhere.


with taxonomy_node_get_terms() function (D6) you can get 'terms from node'. one example:

<?php
$terms = taxonomy_node_get_terms($node);// get term from nodes
rsort($terms); //rsort() just sort an array in reverse order
$myterm = $terms[0]->name; //get a value
echo $myterm; //show value
?>


Add aditional field with title to every node

As far as I know there's no generic #title property (it's certainly not mentioned in the render array docs); forms use them, but I don't think extends to any render array.

#prefix would be the way to go:

$content['my_additional_field'] = array(
  '#markup' => "additional field",
  '#prefix' => "
Title
",
  '#weight' => 1000
);


Drupal7 REST webservices API KEY vs OAUTH two-legged authentication for clientside JS consumer library

The solution came from Kyle Browning (thanks!) - the current dev version of services 7.x-3.x-dev has support for the following OAuth authentications methods:

None, OAuth authentication will be disabled by default
Unsigned with consumer key
Consumer Key, also known as 2-legged OAuth
Consumer key and access token, also known as 3-legged OAuth

With this version I ended up using the consumer key for the client libraries as identification token for applications.


How to add client side validation to form via FAPI?

Solution was to add following for each integer field with form alter:

['#rules'] = array('digit');

And perhaps it was also needed to set 'views_exposed_filters' as a custom form for validation in the settings of Client Side Validation module.


How do I remove the revision information from a node edit form?

In your MODULE_form_alter hook add:

$form['revision_information']['#access'] = FALSE;


Tracking Sessions and Calling a web service

There seems to be a bit of confusion in your code: the set_tracking_params() function calls itself, which would would result in an infinite recursion.

That being said, you're calling the set_eddy_tracking_params () function directly in the PHP file which means it will probably be executed before Drupal's full bootstrap has run, and before the wsclient module file has been loaded.

If you're trying to run this function on every page then hook_init() would be the best place for it; it's called early on in every page load:

function MODULENAME_init() {
  set_eddy_tracking_params();
}


How do I put form field sets in jQuery UI tabs?

If you're adding javascript for a specific form, use

$form['#attached']

e.g:

$form['#attached']['library'][] = array('system', 'ui.tabs');
$form['#attached']['js'] = array(
  drupal_get_path('module', 'mymodule') . '/my_module_init.js',
);

You might also be interested in field_group, which provides jquery tabs etc.. for entity forms


By programming theory anything is related to action, when anyone do any action then he get any result or response, in your theory I can not able to understand the action.

But I would like to suggest you by default every trigger works when cron runs, if you want to send mail without cron then set trigger on any action.

Enjoy!


Changing a field settings on a live site in Drupal7

Unlike in Drupal 6 where setting the max length of a text field didn't have any influence on the database, but merely added a validation check, Drupal 7 will actual create a column that can only hold the selected number of chars.

You can get around this, but not though the UI, as you need to alter the table in the database.

What you need to do is alter the max length of the value column in the field tables named:

field_data_[FIELD NAME]
field_revision_[FIELD NAME]

The column you need to change should be called [FIELD_NAME]_value

Then you need to alter the configuration, which is serialized data in the data column in the field_config table for the field. You can either edit it directly if you are familiar with PHP serialized data or can do it with drupal_write_record. I believe the usual API function field_update_field wont work, as it should throw an exception not allowing the field to be saved, you can however use field_info_field to get the field data as it is stored in the database.

So in short, it can be done, but requires some custom hacking on the DB not using proper APIs.

An alternative solution would be to create a new field and migrate the data and then delete the old field.


Drupal 7 custom form submit handler is not being called

I had this same problem trying to edit commerce_product form. For some reason the submit handlers are registered under actual submit button and custom handlers added to the #submit -element weren't registered.

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

So when I added that second line to register my custom handler to button and atleast it works.


Take a look at the example migration for beer and wine that ships with Migrate in the 'migrate_example' folder.

You will need to register your your migration and handler classes explicitly with hook_migrate_api(). See 'migrate_example.migrate.inc' inside 'migrate_example'.

However, you don't need to explicitly register abstract intermediate classes that hold common info for other migrations you're implementing. See the abstract class 'BasicExampleMigration', inside 'beer.inc' as an example.


How do I programmatically get a field's value?

Make sure the field is displayed in the display settings of your bundle (admin/structure/types/manage/bundle/display; replace bundle with the machine name of the content type) and define its settings (e.g., delimiter, prefix suffix).

In your template file, add <?php echo render($content['your_field_name']); ?>


It is difficult to have such functionality working with views generated fields. Solutions that are close to this functionality are available but may not provide acceptable UX.

For Views you can check out Editable Views and Edit Views modules.

You can also try Quick Edit module, but you will have to give up rendering your fields w/ Views, as it doesn't support fields generated by Views now and not sure if it will.


How to optimise views with multiple field collection?

As per your reply, you dont want to use Cache, so I can suggest a module for this, Views Accelerator. It increases the performance of the view.

  Views Accelerator can bring about significant speed improvements on
  sites with views that cannot be cached normally, for instance because
  the views depend on an aspect of the visitor's session, like their
  location. Views Accelerator serves up two modes of operation.

  Analysis mode: Switched on from the module's configuration page,
  admin/config/system/views-accelerator, this displays at the top of the
  screen a performance summary for each view on the page. If performance
  is already great, tell your boss or customer. If it isn't, take a
  screenshot of the performance summary and proceed with the Accelerator
  mode: On views that could do with a boost, find and click the Caching
  option link in the Advanced section of the Views UI. It will reveal a
  new pseudo-caching option: None. Post-execution optimized by Views
  Accelerator. Select that. Revisit the page with the view(s) and
  compare performance stats to the screenshot you took earlier. Win?
  Then tell your boss or customer.


How to modify the header  in superfish menu?

I'm not sure that this is a good idea because changing that ID may break the scripted functionality of a Superfish menu but that said, here goes...

I'm assuming you're on Drupal 7.

It's not a template that you'll be doing anything with. It is a theme function. When the Superfish menu is generated by drupal it is in response to a call to the theme_superfish() function. You can find detailed info info on it here: http://api.drupalhelp.net/api/superfish/superfish.module/function/theme_superfish/7

So with that in mind, you would want to override that funtion in your template.php file in your theme folder by copying the function to your template.php file, renaming it to YOUR_THEME_theme_superfish($variables) and changing the part at the end where it builds the menu.

If you have several Superfish menus and only want to affect one of them (ie: superfish-1), you can add a conditional to the function so that it only changes the ID of the menu when the conditions match.

Hope that works for you.


Categorize the contents of content type without creating a different template file for each

You can use

Panels Module

It gives you UI to override node templates,providing appropriate selection criteria you can have different layout as per content types.

Display Suite

Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!


You can either use google (or some other search engine if that's your thing), or drupal.org search.

On the drupal search pages you can filter by modules and by the "views" category, among other things.

For example, see https://drupal.org/search/site/views?f[0]=&f[1]=&f[2]=im_vid_3%3A89&f[3]=drupal_core%3A103&f[4]=sm_field_project_type%3Afull&f[5]=ss_meta_type%3Amodule&solrsort=iss_project_release_usage+desc

Other than that there are no secret ways, just persistent searching.


Support for this it was requested over 2 years ago, and was moved to 7.x-3.x-dev branch, so it will not be possible in phpmailer for Drupal 6. The reason is that Drupal 6 will reach the end of its life soon, when Drupal 8 stable will be released. Thus, it will never be possible to set it in phpmailer for Drupal 6.

Anyway, enabling it at PHP level is a costly procedure. PHP is not really the best language for cryptography. As you can read here, configuring DKIM support at the MTA level makes all your server generated email for a given domain signed by default, and also off-loads the calculation burden to the system that's supposed to be optimized for it.

To make sure there is your MTA involved, you can use SMTP Authentication Support module. As you can see in it's issue queue it does not enable you to force DKIM from Drupal, but at least it ensures your mail server is sending mails, and does not interfere with mailserver's DKIM settings either.


How to use single search box (autocomplete) for users and content?

No need to create two views this can be achieved by modifying the query if you are using views. You can easily alter the query, if you are using the custom form then you can use Form API with autocomplete and in autocomplete callback you can do whatever you want. I have solved this using the autocomplete and its callback using FAPI


Drupal 7 Hierarchtical Taxonomy Translations

You need to enable Taxonomy translation module (Comes inbuilt with the Internationalization module).

If you are not using Internationalization module, please do make use of it to translate the taxonomy related values.


While I agree with the accepted answer, one way to accomplish your goal is to:

Assign the form errors to a variable, such as $form_errors
Clear all form errors from $form_state
Remove the particular form error from $form_errors
Loop through the remaining $form_errors, re-setting them to $form_state.

So to clear the field_mobile error you would use the following code:

// Temporarily store all form errors.
$form_errors = $form_state->getErrors();

// Clear the form errors.
$form_state->clearErrors();

// Remove the field_mobile form error.
unset($form_errors['field_mobile']);

// Now loop through and re-apply the remaining form error messages.
foreach ($form_errors as $name => $error_message) {
  $form_state->setErrorByName($name, $error_message);
}


Programmatically update alt tag on image field

As @clive suggested use $node->save();. Without node saving, alt of the image will not show up in the edit form.

$nids = \Drupal::entityQuery('node')->condition('type','sfa_social_post')->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);
foreach ($nodes as $node) {
  $node->field_sfa_image_file->alt = 'Image for ' . $node->getTitle();
  $node->save();
}


How to send forget pass email programatically?

With  some reverse engineering on core user module  the solution is :

    $name = \Drupal::request()->get("name");
    $langcode =  \Drupal::languageManager()->getCurrentLanguage()->getId();
    // Try to load by email.
    $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(array('mail' => $name));
    if (empty($users)) {
        // No success, try to load by name.
        $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(array('name' => $name));
    }
    $account = reset($users);
    // Mail one time login URL and instructions using current language.
    $mail = _user_mail_notify('password_reset', $account, $langcode);


Your drush is using system php, whereas Drupal is using XAMPP's. This reliably creates drush problems.

Look into XAMPP and figure out where its php binary is and then set your path accordingly in .bashrc or whatever other shell init files you have sitting around.

Check your progress with drush status, in particular what it reports for the database connection.


Here how your code should look like:

/**
 * Implement hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {

  if($form_id == 'FORM_ID') {
    $form['actions']['request'] = array(
      '#type' => 'submit',
      '#value' => t('Forgot Password?'),
      '#submit' => array('mycustom_submit_redirect'),
      '#limit_validation_errors' => array(),
      '#attributes' => array(
        'class' => array('form-request'),
        'title' => array(t('Request a new generated password via e-mails.')),
      ),
      '#weight' => 2,
    );
  }
}

function mycustom_submit_redirect(&$form, &$form_state) {
  // sometimes it seems to fail
  //$form_state['redirect'] = 'user/password';

  // alternative method to redirect
  $options['absolute'] = TRUE;

  $url = url('user/password', $options);

  header('Location: ' . $url);

  drupal_exit($url);
}


How to group facets (Facet API) by day for date fields?

Use the numeric_groups module. It is a sandbox project.


Found: there's not an exported API, but an implementation of a regular form hook for the UI, which does all the magic (webform_share.module:123).


drupal 7: how to add a field that displays a message when user is not logged in?

You can try the following 2 modules: Field Permissions and Markup.

Define the field.
Directly behind, define the markup field that shows the message to log in.
Use field permissions to allow access to the target field for authenticated users only.
Use field permissions to allow access to the markup field for anonymous users only.

That workaround should solve you issue.


try with arguments or use views module and configure your block view CONTEXTUAL FILTERS


Possibility to reinstal module without deleting old configuration for module permissions by term

Module configuration files are stored in the module's config/install directory. When you enable the module, Drupal tries to install those configurations. If Drupal complains that the configurations already exist, then you can take the following steps:

Identify which configuration files Drupal is complaining about.

Move those configuration files out the module's config/install directory. It doesn't really matter where you move them to, but you're going to want to restore the files after everything is fixed so I suggest just moving them up one level into the config directory.

Try to install the module. Drupal won't find the module's default configuration files that you moved so it shouldn't complain any more.

If Drupal still complains, that means you missed a configuration, so repeat the above steps.

Restore the original configuration files - move them back into config/install.

Note that this is a workaround - not a solution. The module should be examined to ensure it properly removes its own configuration (if appropriate) when uninstalled, and that it declares the proper dependencies in its configuration, and that configurations which are not removed are defined as optional. Please file a bug report in the issue queue for that module so that this can be fixed for other users.


Pre-defined color picking in the node admin in Drupal 7

Like I said in my comment I'm having trouble understanding the actual question. If you want a user to be able to choose from a set of predefined colors and connect this value to a node of type article you could do like this:

Visit admin/structure/types/manage/article/fields
Add a new field of type List (text)
Set the widget to Selectlist and press save
On the next page under Allowed values list you then enter all your colors in the form key|value for instance Red|Red or Black|Black and then press Save field settings
In the next form you might set if this field is required or not and a default value

Now your users can select a color from a select list on the article edit screen. Not sure this is what you're asking for though.

Here is an example of what the user will see when editing an article:


Send the email when specific node is created

I've never used it but the Queue Mail module purports to do exactly that:

Queues email sending from your site so that instead of being sent immediately it is sent on cron.
Useful for high traffic sites that can send a lot of emails on individual page requests.

It has the unusual properties of being both actively maintained, and bug report free at this time - so looks quite promising


Adding new website as multiwebsite under existing drupal website

Domain modules will be your best bet. It will allow you to use same codebase and database for all your sites. You will also have an option to push content to a specific site if need be.

  The Domain Access project is a suite of modules that provide tools for running a group of affiliated sites from one Drupal installation and a single shared database. The module allows you to share users, content, and configurations across a group of sites


I'm not sure if this solution applies to your specific case, but on my site, I award a role with the license.  So, when I want to "give away" a license without creating an order, I just add the role to the account.  Or, I use the Rules and Flag modules to flag a user (and there is a rule that automatically adds the role).

If you really wanted a license, you could also probably use Rules to create an order and fill it with dummy information, then award the license that way.  Commerce License has decent Rules module integration, so you can get pretty far without any coding.


Is it possible to run 2 different sites in Acquia Dev Desktop on the same computer?

Yes, you can install more than one Drupal site on the same computer using Acquia Dev Desktop. Check out Acquia's documentation here:

https://docs.acquia.com/dev-desktop/sites/

It looks to me like maybe you have specified an identical name for the local database. The error screen that you see is one that commonly appears when a new Drupal installation attempts to run install.php but the database is already set up.

As an experiment, click on the link that says "View your existing site." If my hunch is correct, you should see the content of your other site.

Instead, try selecting "Create a new database" when setting up the second site, and make certain that you give it a different name than the first site uses.

If the two cloned sites just happen to have identically-named databases, you should still be able to create a new one with a new name, and then import a sqldump of the second site's database into that.


CSS aggregration breaks site - how to troubleshoot?

Some initial things to check:

Clear the cache (if you're running advagg, clear its cache). You can end up with stale file references sometimes.
Find out what's happening to the missing CSS:

When the styles go missing, does the page source contain a <link> to an aggregated CSS file? If not, check for modules/themes implementing hook_html_head_alter(), hook_css_alter(), or hook_preprocess_html(), and see if they're doing anything strange.
If the source does contain the <link>, what status code is the browser returning for the request? 404? You might have a stale cache issue. Clear all caches including those on any reverse proxy you're running. It might easily be something else, would require more intimate debugging. 500? Check the server logs, that should give you clues as to where things are failing.
If it's 200, does the requested file actually contain the styles it's supposed to? If not, you might be looking at a cache issue again, or potentially an issue with build tools (Compass/Gulp/Grunt/etc).

Switch the theme to a core one. Does it have the same problem? If so, it's probably a module or server setting at fault. If not, it's likely to be a problem with the theme.
Make sure permissions for your files folder are at the right level - the web server must be able to write to that folder to store the aggregated files. This is less likely to be an issue if the files are being created successfully, but it's worth double-checking you don't have an intermittent file system issue (if it's over NFS for example)

Getting the answers to those questions will help to narrow down the source of the problem, but unfortunately it's difficult to give specific advice as to where you should look in the code, as there are a lot of points problems could occur, and a lot of different modules you could have installed, at varying versions.


Set the back-office theme to a specific url

I'm not familiar with using translation pages, but I've had good success using the themekey module for changing themes based on URL:
https://www.drupal.org/project/themekey


Why can the Views Gantt module not find the DHTMLX Gantt JS library?

Are you sure the dhtmlxgantt JS library is located in: sites/all/libraries/dhtmlxgantt ?

Within that folder you should have extracted the original library which should have:
sites/all/libraries/dhtmlxgantt/codebase and sites/all/libraries/dhtmlxgantt/samples.

Also make sure the "dhtmlxgantt" folder name is all lower case.


SMS Framework - Multiple destination numbers

Assuming your question is about D7, you could try to create a view (using the Views module) of those users that you want to send an SMS to.

After you succeeded in creating such view, you can process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions (in the rule you already have in place):

Load the VBO list of those users.
Add a loop to perform a Rules Action "send an SMS" (similar to what your current rule already does), for each user contained in your Views results.

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".


Module Background Image (bg_image) installed, image not showing

Did you configure the base bg_image settings? You need to specify a css selector to apply the background image to.


how to print login_days with user_stats module?

As Berdir stated in the comment, user_stats_get_stats('login_days'...) returns a number of days so you can't use this with format_date, also I tried this on my site and if you're the author of the node this function will return nothing, but if you try with other users that have logged in, this should display the number of days since their last access.

In fact if you're only using this module for this function, it may be a little overkill and you should better do this manually:

$u = user_load(31);
print floor((time() - $u->access) / 86400);

Edit: 12/06 11:57
If you want to format the last access date then do:

$u = user_load(31);
print format_date($u->access, 'custom', 'j M H:i');
//will display 12 Jun 12:03 with hour formated in 24H.


you can rewrite the output of that field and make it a link. Rewrite works for all fields - some fields do offer a link output in their settings though and might be the better option if available.

Steps to take:

add a path to the content and exclude it from output.

rewrite the output of the field you want to add a link to.


How to combine block form submit result with on fly created content together in Drupal 8

There are two ways you can do this. You can put the results in the form, or you can put the results in the block. Choosing which one to do will depend upon how the form should work - if you were to use this form in another location, and would want the results to show in that location as well, then you should put the results in the form as follows:

function some_form(array &$form, FormStateInterface $form_state) {

  // Note: Form build not shown.

  $results = some_function_that_returns_results();
  $form['results'] = [
    '#prefix' => '
',
    '#suffix' => '
',
  ];
  foreach ($results as $result) {
    $form['results'][] = [
      '#prefix' => '
',
      '#suffix' => '
',
      '#markup' => $result,
    ];
  }

  return $form;
}

If you only want the results to show if the form is in the block, and not in other places where the form would be shown, you add the results to the block as follows:

public function build(){
  $form = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\myform');
  $markup = bunch of html here;
  $content = ‘some data’;

  $block = [
    'form' => $form,
    'markup' => [
      '#markup' => $markup
    ],
    'content' => [
      '#markup' => $content,
    ],
  ];

  $results = some_function_that_returns_results();
  $block['results'] = [
    '#prefix' => '
',
     '#suffix' => '
',
  ];
  foreach ($results as $result) {
    $block['results'][] = [
      '#prefix' => '
',
      '#suffix' => '
',
      '#markup' => $result,
    ];
  }
}


Whats the best method for displaying different page layouts for a node based on taxonomy?

In D6, if you are displaying a full node page, you can use the preprocess_page() hook to select a different page template based upon that CCK field.  For example,

function mythemeormodule_preprocess_page(&$vars) {

  $node=$vars['node'];

  switch ($node->field_i_am_interested_in[0]['value']) {
    case 'something':
    case 'anotherthing':
      $vars['template_file']='page-bytax-' . $node->field_i_am_interested_in[0]['value'];
      break;
  }

}

and then create page-bytax-something.tpl.php page-bytax-anotherthing.tpl.php etc with whatever page layout you want.

If though, you are really talking about how the node itself is laid out in the $content area of the page, you could do the same thing inside preprocess_node() and create node-bytax-FOO.tpl.php templates instead.

Also, depending on what kind of cck field you are looking at, you might need to change up the [0]['value'] part.

If D7, subtle changes apply :)


CKEditor + IMCE file uploader. What am I missing?

Depending on what version of Drupal you're using, my first inclination is to say the Media module is what you're missing.

That aside, there are a number of steps to take to configure the WYSIWYG image experience.

How did you install CKEditor? Did you install the WYSIWYG module and the CKEditor library properly?
Did you install the correct version of CKEditor? I think you might need the 3.6 version.
Have you set up the correct input format? Does your user have permissions to use it?
Have you set up a CKEditor profile with the correct image insert buttons that integrate with IMCE?

Those are the main things that come to mind, though knowing more about what happens (i.e., when you disable rich text, does anything display in the editing window?) and what steps you've already taken would help narrow it down.


Drupal 7 Views 3.13 Filter groups returns nothing if one group is empty

I think this is a bug/changed behavour in views introduced a long time ago.

A workaround might be to select the Reduce duplicates checkbox from one of the fields in OR group filter - which will transform your query to LEFT JOIN instead of INNER JOIN.

I found the solution here:
https://www.drupal.org/node/1766338#comment-6973984

It worked for me in Views 7.x-3.13


Why are some fields output wrapped in div and others a span?

If you click on a field in your view, you get the 'Configure Field' dialog. Look for "Style settings", because there you can customize the Field HTML, Label HTML and the wrapper. E.g. with 'Label HTML' option you can change the <span> to a <div>.


If you are showing a standard drupal user profile page this should get you going:

  $user = user_load(arg(1));
  $user->uid; // access user id

This assumes the path is user/uid. If your path looks different adjust the arg(position_in_path) to your needs.


Restrict coupon for same shipping address (or user creating multiple email ids)

There is surely a way to block this, you can alter the forms and add validations. But do you really want one to one mapping between shipping address and user account?

What if the old user wants to purchase the same product again, or a new user signing up stays in the same apartment?

Maybe you need to review your business rules and figure out a better way to restrict this behaviour.

Maybe IP address?


Get the site name from config and add the config as cacheable dependency so that the block gets updated when you change the site name.
public function build() {
  $config = \Drupal::config('system.site');

  $build = [
    '#markup' => $config->get('name'),
  ];

  $renderer = \Drupal::service('renderer');
  $renderer->addCacheableDependency($build, $config);

  return $build;
}


How can I check in Rules if the number of members is below 50 or not?

You need get the count of the total users so far from the users table.
To do that, you can use a condition with php code where you have to write a db_query("SELECT COUNT(*) FROM users"); //[not tested]

if result gets number of existing users. you can return true/false to go to the action in order to assign points.

Let me know if you got it working.


A migration has the following required components:

A source plugin, which provides the data to the migration system from D6/7, a CSV file or whatever it is it connects to.
A destination plugin that stores data in Drupal 8.
The migration config entity that connects the two by defining the mapping and any processing/transformation of those properties/values.

The destination plugins are provided for all entity types in a generic way. So you can import data into D8 commerce products. However, what's fairly certainly still missing is source plugin that reads data from a D7 site. You can implement that yourself, it's fairly easy and there are plenty of examples for node, user, .. in core.

The migration entity is then also something that you need to define since that won't exist either. Depending on how different the data is, this is often the complicated part and needs possibly various transformations/process plugins to re-structure the data for D8.

For an example, see the migrations the we are in the process of writing for simplenews.


Can I set a status message to be displayed when a user clicks a link?

I think you need to make a custom form with a submit button (the button should be your "link" button), and then you can do what you want.


Some things to check:

Is your update function placed in [modulename].module or in [modulename].install? It should be in the install file.
Is the function really called hook_update_6031? in that case, replace 'hook' with the name of your module. For instance, an update function for the comment module could be called comment_update_6003.

If the above does not help, please update your question with the code of your update function. Also check the value in the schema_version column in the system table for your module - for the [modulename]_update_6031 function, it must not be less than 6031, but not -1.


A View which displays Posts assigned to a Parent which is followed by current user

Use Views PHP.

In Views

Format

Content

Filter Criteria

Content: Published
Content: Type (=Post)
Global: PHP (see below for code)

Code for Global: PHP -

$flag = flag_get_flag('follow_parent');

$post_nid = $data->nid;

$post = node_load($post_nid);

$field_parent = field_get_items('node',$post,'field_parents');

$parents_followeds = array();

foreach ($field_parents as $field_parent) {
  $parent_nid = $field_parent['target_id'];
  $followed = $flag->is_flagged($parent_nid);
  $parent_followeds[] = $followed;
}

return in_array(TRUE, $parent_followeds) ? FALSE : TRUE;


How can I display empty text for an empty CCK field that is output in a node template

You could use an if statement, to check for value, and if not print something else:

<?php
  if (!isset( $node->field_name[0]['value'] )) {
    print t('My empty text');
  } else {
    print $node->field_name[0]['value'];
  }
?>

But I think that if you print the whole field  you don't need to do this. Use something like:

<?php print $node->field_name_rendered; ?>


Restricting the term reference field from creating a new vocabulary term

Is there a specific reason why you want users to type in the term? You should be able to change the widget type to something else (select list or multiselect). This has also been discussed at length as an issue against the Taxonomy module (Autocomplete term widget: disable creation of new terms).


Problem with mobile_theme theme switcher module

mobile_theme wouldn't work with Drupal cache on. It is not mentioned anywhere in the documentation. We should use m.example.com for mobile url's for Drupal. I tried many such modules except for ThemeKey but the same problem( since I was using the cache).

I finally wrote my own module. But later found : simple_mobile_redirect to be good one but have not tried yet.


How to show nodes where the user is (not) in the reference field with Views?

You can use exactly the same you did for positive reference but with a single exception. You will see a checkbox contextual field setting names "Exclude". You can check that and the views will exclude the records which have not referenced.


Yes it is. Navigate to your Drupal directory and run the following command:

drush pm-update drupal-7.x

Note you can use the same tactic to update any module to a development version from a stable version, as well as update a development version to a newer, stable version.


How to create inline node-add forms using a block with content type names

Panels is definitely the way to go here.

Using Page Manager set up a URL with an argument, like mypath/%node-type
Set the argument to be Node add form: content type
In the content area you can rearrange the form how you like or just add the whole node creation form by using the elements under form in the add content screen
Make either a custom pane or a menu of links that point to the various node types:

mypath/article
mypath/event
mypath/document
mypath/video


What are some alternatives to admin_menu module for Drupal 7?

you may use admin module in combination with coffee


Revised:

Your code looks right

3 Things could be the problem

'mypage' could be a banned link.
you don't have access to 'custom_work_mypage_view' form.
Clear your cache.   Without the 'access argument' line you will get access denied.  If you added it then save your file, you will still get access denied until you clear your cache.

My gut feeling is #3.


It depends on the type of reference. You can load any node-content with node_load(). The question is simply if you know when to load which nodes. This reference could via Taxonomy or Contentype or User or anything else.


How might I display a field twice in a node using different field formatters?

There are 2 options available for this to do.

By linking the image to its image path from the site. This can be achieve using a module https://www.drupal.org/project/image_link_formatter.
By using download module and custom field theme formatter.
In this you need to enable the download file module https://www.drupal.org/project/download_file.
And than create customize the field view using the field template.


Create view with parent taxonomy terms only

Create contextual filter with parent taxonomy term id as fixed value 0


Looks like the Views text area filters style="anything" out to prevent XSS attacks. If you create a template file for your view, I believe it will work.

As pointed out by @4K4

  If you put a twig variable inside of a style attribute standard
  sanitizing won't prevent . To protect against this you need to
  filter even brackets. See XSS attacks and style attributes

Therefore, you need to make sure your field is not a text field, where the user has the power to write/put whatever they want. You should use a Select list field or better yet use a color field.


Views allows you to expose sorts, but doesn't create the type of UI you are asking for by default.

What you get by default with views after clicking 'expose' at the top of your sort value is two menus, one for the value to sort by, and one for the sort direction.

The most important thing to remember here is what you get in your view's url after submitting this original exposed filter form: /myviewpath?sort_by=XXXXX&sort_order=XXXXX.

You can write your own custom module, do a hook_form_alter of the existing form, a fancy jquery widget, heck write it in Flash if you really want to, all the view cares about is you passing those two values and that those values are enabled and available for that view.

In terms of getting your own custom values available there have a look at the views sort class documentation and the view_handler_sort_* examples already provided in /views/handlers. Views argsort looks pretty interesting as well if you don't want to write your own sort handler but haven't tried that module myself yet.

For part 2 of your question this summary is already provided by views. Click on header, click on "Global Result Summary", and use the tokens provided to create your summary.


How do I add a cart form to the product view?

To display an "add to cart" button on a product's display you need to:

Go to /admin/commerce/config/product-types/TYPE/edit/display
Make sure that Variations field is displayed
Select "Add to cart form"

Views display:

You simply need to add the "Product: Variations" field and set its display as "Add to cart form"

You of course you need to have the "Commerce Cart" module enabled :)

Not intuitive really. I might end up using Commerce Variation Add to Cart module.


Getting a formatted address component in another field's template

How I understand the linked doc you need to configure the plain address formatter in a view mode to use address-plain.html.twig. Then you can output the node field as formatted in this twig:

   if ($node->bundle() == 'location') {
     $variables['address_state'] = $node->get('field_address')->view('custom_view_mode');
   }


Drupal Commerce: Create advanced add to cart form block in views

Ajax on the block only works for the views pager and the table sorting. You have to simulate that behaviour by triggering the ajax call when an attribute is selected.

Alternatively try with Ajax Block, Block Refresh, or Authcache Blocks, and see how they trigger the Ajax load on page load, and do the same on attribute selection.


Any field created with the core Field UI module has its name prefixed with field_.
Any field created programmatically is named exactly as the module creating it wishes, without the prefix.
The field data tables are named directly from the field names

Yes, you have it absolutely right.

It's worth noting that the data is also stored in field_revision_foo, regardless of whether you're using revisions or not. The field_data_foo tables will always contain the most up-to-date data whether revisions are enabled or not.


Follow below steps to add path aliases to "weather" menu path

Enable locale module
Go to admin/config/search/path/add
Select language rs and add path alias as "vreme" and Existing system path as "weather"

That should work !:-)


Where does Feeds cache the source and how do I disable this cache feature?

I've posted this issue on Drupal before. Basically it's a problem that they are working on.

http://drupal.org/node/1156062


Feeds importer incremental URL parameter

You want to take a look at the Web Scraper Example.

https://www.drupal.org/project/example_web_scraper

In Feeds Importer you want to look into the Robots spider setup, which will follow links and patterns, so a single importer can create 10's, 100's or even 1000's of new Nodes.

The example scrapes the Stanford Events website - spidering the page, following the links and creating a new node for each item. You can also run the importer on single event pages.


Try Google Analytics Reports module.

  Graphical reports include a dashboard widget for admins, a small
  path-based report in blocks, and a full path-based report.

  Prerequisites are the Google Charts API module and the OAth
  module. Do not forget to set the module’s permissions about who has
  access to the reports.


Add data to JSON generated by views_datasource

You could implement something in the view template for the JSON display.

The correct file to modify seems to be views-views-json-style-simple.tpl.php.

You have to copy it to your theme's template folder (usually template's root directory, or template subdirectory) and add the necessary data to the $json variable before the correct print $json statement.


The Plupload integration module allows you to upload multiple files at once.

I've used this module before and I think it works really well. It also allows you to drag and drop files onto the browser window to initiate the upload.


Is there a stable way to fill a filefield/imagefield via bulk upload in D7

For completeness, the only stable way I found (and it's still not perfect, though) is to use plupload in combination with block_upload to get a PLUpload widget on the content site once it is created. It still is not the perfect workflow, but it currently allows me to dump 100s of photos/files into one filefield. Using PLUpload during node creation didn't work, btw.


Pass parameters to Drupal to Return XML data

Exposing Views as XML is one of the features of the Views Bonus Pack module.  You would lose your idea of using GET parameters, but you can easily build up other paths, pipe in your parameters, and get output as XML.

This is also something that the Services module can handle, but isn't as tightly coupled with views.  This module is very well documented, though.  In particular, I suggest reading the REST examples.  This is an add-on, Services Views, that may fit your needs, but I have never tried it.


How can I change the labels on a chart created with the Google Chart Tools module?

That is very easy. Simply uncheck link field to original piece of content of the field you are using.


How do you programmatically get the shipping information from a placed order?

You can have the shipping information with :

$shippement = $order->shipments->first()->entity;
$shipping_profile = $shippement->shipping_profile->first()->entity;


What could cause uids to not be numbered consecutively?

So, it turns out this is indeed normal since Drupal 7: the users table is not auto-increment but uids are created with a sequences API that is shared with actions and batch jobs. Uids can therefore be non-consecutive.

Several reasons for changing back from auto-increment table in D6 are pointed out here by chx.

(From reading chx's response to this blog post)


Programatically Create Nodes with Body and Custom Fields

try using  like below

$node->body[LANGUAGE_NONE][0]['format'] = 3;
    $node->body[LANGUAGE_NONE][0]['summary'] = 'summary';
    $node->body[LANGUAGE_NONE][0]['value'] = 'dfg sdgdfs gsdg sdfg sdfg sdfg sdfg sdfg sdfg sdgsdf';

// Try to set your custom field
    $node->rscg_mashup_image_url[LANGUAGE_NONE][0]['value'] = "Too many to count...";


Redirect user to login page when they have to access to a view?

The Redirect 403 to User Login module should do what you need.


External URL Redirect Breaking Image Links

A redirect from the old site to the new should not affect how the page is rendered on the new unless some absolute paths are hardcoded in the template files.

First check the value of $base_url in the settings.php.
If that is correct (or just commented out) check the code of your theme's template files.


Disabling module with config sync and removing with composer

You need two consecutive releases for stuff like that.

First release:

Your colleague uninstalls the module and commits the updated config.

If you don't manage your site via config use hook_update_N instead.

/**
 * Uninstall SOME_MODULE module.
 */
function MYMODULE_update_8001(&$sandbox) {

  \Drupal::service('module_installer')->uninstall(['SOME_MODULE']);
}

Second release:

The module can be removed via Composer.

Related:

Order of drush commands for automated deployment?


Instead of

<?php print $title; ?>

You can do:

<?php print check_plain($comment->subject); ?>


Basing on the patch provided in Remove Generator META tag & X-Generator for Drupal 8 version! this is the code that would achieve that.
/**
 * Implements hook_page_attachments_alter().
 */
function HOOK_page_attachments_alter(array &$attachments) {
  foreach ($attachments['#attached']['html_head'] as $key => $attachment) {
    if ($attachment[1] == 'system_meta_generator') {
      unset($attachments['#attached']['html_head'][$key]);
    }
  }
}


D7 - download files works for admin, not for other users

As you setup the content type default as unpublished, this will prevent any one to see the individual content but the author of the content(if he or she has permission to "View own unpublished content") and User with the privilege of "Bypass content access control"
which probably you don't want to give it to any one but admin, so basically there is a better approach to this :

I recommend to

1) setup content type default as published

2) Setup Content Access module http://drupal.org/project/content_access

3) Setup content type access permission by Content Access module.

3-1) Use Content access module to prevent any user but HR to have access to the specified content type. This will prevent any one to have access to following content type but HR, so you don't need to worry about content being published.

3-2) give permission to the specified rules (maybe anonymous or authenticated) to be able to create the specified content type.

Note: Don't do this in production environment, first test it to make sure everything is as you want it since "content access" module will rewrite your current website permissions.

If it still seems confusing let me know I will add photos to explain it.


How to theme a link in a D7 render array?

The theme_link() function behaves a bit like the l() function; the attributes array needs to be inside an #options property:

$link = array(
  '#theme' => 'link',
  '#text' => $row->title,
  '#path' => $base_path . 'node/' . $row->nid,
  '#options' => array('attributes' => array('title' => $row->title)),
  '#prefix' => '<h3>',
  '#suffix' => '</h3>'
);

echo render($link);


How to use Twitter Bootstrap with panels?


Paragraphs Entity Type Causing Issues After Core Update

I figured this out, not sure if it is the best way, I ended up using a mysql command to delete the config manually:

DELETE FROM `config` WHERE name='core.entity_view_mode.paragraph.preview';

After, you can enable and disable the module. Which appears to have fixed the issue.


Views rewrite results texfield to uppercase

One solution is to rewrite with inline CSS styling. For example:

[my_field]

Depending on your design needs you might want use CSS classes instead.


Block Settings not applying to Zen sub theme

I solved the problem, but don't know exactly what the issue was.

While troubleshooting, I noticed some Warning

  site:drupal.org Invalid argument supplied for foreach() in
  element_children()

As well as the tabs not changing names regardless of which themes were enabled. Disabled and uninstalled all of my custom modules, but nothing changed. Disabled and deleted all the custom themes I had installed, and the errors disappeared and the Block Settings menu started behaving properly again. I copied all the themes back in, and it's still working properly, so I am not sure what the problem was.

I will be reinstalling several of the modules and checking to see if the problem reoccurs, but for now all is well.


Hooking into page specific instance of checkout flow form

Conditionals are still the answer, but turns out there's an easier way that doesn't involve getting the current path:

function MYMODULE_form_commerce_checkout_flow_multistep_default_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form['#step_id'] == 'order_information') {
    Do stuff to the order information page form.
  }
  if ($form['#step_id'] == 'review') {
    Do stuff to the review page form.
  }
}


How to customise calendar week view's day title?

Y rectify like this and that seems good for me:

function template_preprocess_calendar_week(&$vars) {
$min_date = clone $vars['view']->date_info->min_date;
foreach ($vars['day_names'] as &$cell) {
 $cell['date'] = $min_date->format('j');
 $cell['data'] = $cell['data'] . ", " . $cell['date'];
 $min_date = $min_date->modify('+1 day');
}
}


How can I include Google Structured Data via a module?

There is a Drupal 8 module works tandem with the Metatag module: Schema.org Metatag

From the module description:

  This project extends Drupal's Metatag module to display structured data as JSON LD in the head of web pages. Read more about Schema.org, JSON LD, and how this module works in an article on Lullabot.com, Create SEO Juice From JSON LD Structured Data in Drupal.


why doesn't system_menu() return the option I am expecting

It's hard to know what you mean, but at a guess you're expecting system_menu() to be responsible for all of the paths you can visit in the system, and therefore you're expecting to see a listing of all paths in that function?

If so, that's not quite how it works. Drupal is extended by way of a hook system, one of those being hook_menu(), which allows modules to define menu items and page callbacks.

So in the case of jQuery Update, this is its implementation of hook_menu():

function jquery_update_menu() {
  $items['admin/config/development/jquery_update'] = array(
    'title' => 'jQuery update',
    'description' => 'Configure settings related to the jQuery upgrade, the library path and compression.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('jquery_update_settings_form'),
    'access arguments' => array('administer site configuration'),
  );

  return $items;
}

And that's where the jQuery Update admin menu item and link come from.


Expose a filter to turn a different filter on or off

There is a module for that; you can use Views Dependent Filters which allows the presence of exposed filters on a view to being controlled by values in another exposed filter. Dependent filters are hidden when not relevant, and their values are not considered when the exposed form is submitted.


How to clear varnish cache using drush? I'm on acquia cloud dev account

With Acquia Cloud API v1 Drush commands

On Acquia Could API v1 the command is ac-domain-purge. Here is a snippet from the drush help available from the Acquia box.

$ drush help ac-domain-purge

Purge a domain from the Varnish cache.

Arguments:
 domain              Domain name.

Options:
 --username          Acquia Cloud API username
 --password          Acquia Cloud API password
 --acapi-conf-path   Acquia Cloud API config files location. If not specified config will be loaded from $HOME/.drush
 --caller            Acquia Cloud API caller name. Default is the current username.
 --endpoint          Acquia Cloud API endpoint URL.
 --cainfo            Path to a file containing the SSL certificates needed to verify the ac-api-endpoint.
 --format            Format to output the object. Use "print_r" for print_r, "export" for var_export, and "json" for JSON. If not provided, the output is printed in a human-readable format.

Additionally, if you want to do this programmatically without drush, Acquia have an API endpoint for clearing the varnish cache.

Note that the drush commands only work with Acquia Cloud API version 1, which is EOL in 2020.

With Acquia Cloud API v2 requests

Acquia Cloud API v2 is json-api based, and the following API v1 to v2 migration document explains the URL request homologue that replaces each v1 drush command.  In this case:

The V1 drush API command ac-domain-purge becomes one of either:

POST /environments/{environmentId}/domains/actions/clear-varnish

To clear the Varnish cache for all domains used in an environment (eg both the internal appname.prod.acquia-sites.com domain, as well as your site's public domain.
POST /environments/{environmentId}/domains/{domain}/actions/clear-varnish

To clear the Varnish cache for a single specific domain.

See the Acquia Cloud API v2 documentation reference for additional information.


This is not different from what is done in Drupal 7:

When building the form, you verify in $form_state a value is present; if it is present you show its value
In the submission form handler, you tell Drupal to rebuild it

What changes is the code you actually use, since Drupal 8 introduces new classes Drupal 7 doesn't have.

class FavoriteCarForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'favorite_car_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['fav_car'] = array(
      '#type' => 'radios',
      '#title' => $this->t('What is your favorite Car!'),
      '#options' => array('Toyota' => $this->t('toyota'), 'Ford' => $this->t('Ford'), 'Subaru' => $this->t('Subaru')),
    );

    if ($form_state->getValue('fav_car')) {
      // Show the value the user entered.
    }

    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->setRebuild();
  }
}

Calling $form_state->setRebuild() causes Drupal to call buildForm() again, passing in $form_state the values the user submitted and the values added from validation and submission handlers.

I didn't add the code to write the submitted value. You could:

Show it as description of the form element
Show it in a #markup element

I would rather not implement such code for just showing the selected value, though. I would use it to show the result of an elaboration done from the input given from users, for example showing a map of the town entered from users.


Override formatting for paragraph edit view

Most edit forms utilize your current admin theme and form render arrays with according widget subforms.

So - in theory - you have several options:

(1) Provide your own admin theme with templates for your single forms. Using a contrib admin theme as base theme would make up for an easy start.

(2) Create a custom module and implement one of the many hooks that allow to alter your forms (e.g., hook_form_FORM_ID_alter, hook_field_widget_WIDGET_TYPE_form_alter, ...).

(3) If suitable, choose your front-end theme for editing your content. Then you can implement your templates there. For this, you'd want to implement a custom theme negotiator in a custom module.

In most cases however, the above methods are overly time-consuming.

To improve usability of back-end forms for content authors, have a look into the field_group module. It allows you to structure your back-end editable forms and displays. You can add groups like detail wrappers, horizontal/vertical tabs, and/or containers with custom HTML-elements and classes.


The solution was adding the following code in settings.php. It will allow Drush to connect to mysqlnd.

if (drupal_is_cli() || basename($_SERVER['PHP_SELF']) == 'update.php') {
  $databases['default']['default'] = $databases['default']['ms'];
}


Why drush sql-sync fails with mysqldump unknown variable error?

This does look like an issue with mysql, not Drush.  Run your Drush command again with the -s flag (simulate);

drush sql-sync @stag @local -s

Drush will then print out the shell commands that it would execute, without doing anything.  You can copy the mysqldump command into your shell, and experiment with the options until the dump works.