Is there a way to see all the available variables inside content? I am using Drupal 9 with twig files
I have a page where in one section I need to show thumbnails of the latest posts. So I created a new view as a block, and placed this block under Content in admin/structure/block/list/
When I inspect with debug on I get these file suggestions -
 FILE NAME SUGGESTIONS:
   * block--views-block--latest-news-block-1.html.twig
   * block--views-block--latest-news-block-1.html.twig
   * block--views-block.html.twig
   * block--views.html.twig
   x block.html.twig

So I created a file name block--views-block--latest-news-block-1.html.twig with the code from block.html.twig.
Inside that file I have -
    {% block content %}
      {{ content }}
    {% endblock %}

Which shows all the content in the block. I need to customize the content in the block though, some things need to be removed, I need to truncate the article text, need to add buttons.
I think I'd be able to do what I want if I could target specific parts of the content. I want to do something like this -

{{ content.title }}

{{ content.body }}

Is there a way to target specific parts of the content like that?

Normally it works that way but Views templates may be different.

Enable Twig debugging.
Add Devel and Kint: composer require drupal/devel kint-php/kint
Enable Devel: drush -y en devel
Inside the template put {{ kint(content) }}, flush caches, visit the page and you should see what else can be found inside content.


Change the submit handler of a form of a module I installed base cart module and I need to totally overwrite the submit handler of one of its forms and not to execute its default functionality at all. From what I searched, I wrote this code in template.php :

function ThemeName_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'order_node_form'){
    $form['#submit'] = 'submit';
    $form['#validate'] = '';
  }
}

function submit() {
  return "submit";
}

But it is not working. Is it possible to do this in template.php or I need to build a module to do this? or the problem is from anything else?

Thanks

I think that it solves the problem to do like this

$form['#submit'] = array("my_module_form_submit_handler");

Here's the whole function:

function my_theme_form_alter(&$form, $form_state, $form_id) {
  $form['#submit'] = array("my_module_form_submit_handler");
}

function my_theme_form_submit_handler($form, &$form_state) {
  drupal_set_message("The form is being submitted, do some extra stuff now...");
}


Cannot access empty property in /var/www/clients/client1/web9/web/modules/field/field.attach.inc I was deleting nodes using Views Bulk Operations and suddenly I got a white screen.

In my error log I get the following error:

  mod_fcgid: stderr: PHP Fatal error:  Cannot access empty property in /var/www/clients/client1/web9/web/modules/field/field.attach.inc on line 324

I'm using domain module and my other subdomains work fine, but my main domain always gives me a white screen with that error.

Does anyone know what I can do to fix this?

This solved my problem: https://drupal.org/node/2051839

Apparently there's something wrong with my image field of a slider, I have no idea that happened during bulk delete of a different content type.


problem using facebook connect module i installed the module Fbconnect in my drupal 7 site

the fbconnect button starts appearing now but the window which opens upon clicking the button, gives the error ,"An error occured, try again later."

Anyone please help

have put in the api key, I think you are missing that. Have you also enabled it on certain node types you want to display.


Get current region name in node template Drupal 7 I need to find out what region the node block is appearing in within the node template. I am using node block module to display nodes as blocks but need to know what region the node blocks are appearing in within the node.tpl. In Drupal 6 there was a template preprocess function where you could set a global var to accomplish this but that function is not available in D7.
Thanks for any help.

It won't let me answer my question yet so I will put it here.

If anyone else runs into this and wants to know what region the node is being displayed in within the node template using the node block module or something like it. You can use the template_preprocess_node($vars) function and add the region to the content so that it will be in the content array in the node template like this.

$vars['content']['region']=$vars['elements']['#block']->region;

If anyone else runs into this and wants to know what region the node is being displayed in within the node template using the node block module or something like it. You can use the template_preprocess_node($vars) function and add the region to the content so that it will be in the content array in the node template like this.

$vars['content']['region'] = $vars['elements']['#block']->region;


Email notification or several reminders at different time points I have content where in I have to send the email notification or several reminders at different time points:
Ex: After saving content, email should send after 1month.
then after 6 months for the same content.
then once every 5 years.
I have tried with node expiry module but it displays content expiry, and when we run the cron at that time only its able to send the mail,user cant run the cron every time sometime he may forget though.

Also I tried with rules schedule but I am not getting exactly what I want like i cant send the email according to time interval, also how to send mail without running the cron. can any one know how to resolve this issue.please help me.

You need to use rules and scheduler module which is work with rule to send mail at period of time.


How to setup multisite to multisite rsync with drush? I try to rsync between a multisite setup (local) and a multisite setup (stage). If I run a sync it will copy all sites from dev to stage but I just want the current site to be synced.

$drush rsync @dev @stage

My drush alias file is located in ~/.drush/example.aliases.drushrc.php

$aliases['local'] = array(
  'root'           => '/Users/admin/Sites/drupal',
  'uri'            => 'example.local',
  'shell-aliases'  => array(
    'dump' => '!drush sql-dump --gzip --ordered-dump'
  ),
  'path-aliases' => array(
    '%dump'          => '/Users/admin/dev-' . date('Ymdhis') . '.sql',
    '%drush'         => '/Users/admin/drush',
    '%site'          => 'sites/example/',
  ),
);

// REMOTE: STAGING
$aliases['stage']  = array(
  'remote-user'      => 'xyz',
  'remote-host'      => 'stage.example.com',
  'root'             => '/home/xyz/www/stage.example.com',
  'uri'              => 'stage.example.com',
  'path-aliases' => array(
    '%drush'         => '/home/xyz/drush',
    '%drush-script'  => '/home/xyz/drush/drush',
    '%dump-dir'      => '/Users/admin/.drush-backups/example.stage',
    '%site'          => 'sites/example/',
  ),
  'command-specific' => array(
    'sql-sync'       => array(
      'no-cache'     => TRUE,
    )
  ),
  'shell-aliases'    => array(
    'dump' => '!drush sql-dump --gzip --ordered-dump'
  ),

  // DB
  'databases' =>
  array(
    'default' =>
    array(
      'default' =>
      array(
        'database'   => 'xyz',
        'username'   => 'xyz',
        'password'   => 'xyz',
        'host'       => 'xyz',
        'port'       => 'xyz',
        'driver'     => 'mysql',
        'prefix'     => '',
      ),
    ),
  ),
);

Questions:

%site: My project folder in sites/ is called example on the local side and has the same name on the staging side. Do they need to be different?
Do i need to put all domains in site.php on my staging server? At the moment I am using just the actual setup ($sites['stage.example.com'] = 'stage.example.com';) on my staging server.
My local sites.php file:

$sites['example.local'] = 'example.local';
$sites['stage.example.com'] = 'stage.example.com';
$sites['example.com'] = 'live.example.com';

Are the directories all/ and default/ always needed?

My local Setup:

Drush 7.x dev
PHP 5.5.x
MAMP

My Server Setup:

Drush 7.x dev
PHP 5.5.x

Edit: Removed opinion based questions ;)

On Drupal 6, your sites folders must be the same.  Since you are using Drupal 7, they can be different, but it is more convenient if they are the same.
You do not need to copy all of your multisites to your dev server.  The drush rsync option you are looking for is --exclude-other-sites.  This will cause rsync to skip everything in the sites folder except for sites/all, and the site you are syncing from.
sites/all is where sites/all/modules and sites/all/themes go, so you typically need these.  With some effort it might be possible to move your contrib modules elsewhere (if everything was in a profile, or if you hand-modified your registry), but this would be an unusual setup.  sites/default is not needed.


Custom entity operation links I've built a couple of custom entities in Drupal 8

Vendor, defined as such:

/**
 * Defines the vendor entity.
 *
 * @EntityType(
 *   id = "vendor",
 *   label = @Translation("Vendor"),
 *   module = "vendor",
 *   controllers = {
 *     "storage" = "Drupal\vendor\VendorStorageController",
 *     "render" = "Drupal\Core\Entity\EntityRenderController",
 *     "form" = {
 *       "default" = "Drupal\vendor\VendorFormController",
 *       "delete" = "Drupal\vendor\Form\VendorDeleteForm"
 *     }
 *   },
 *   base_table = "vendor",
 *   uri_callback = "vendor_uri",
 *   translatable = FALSE,
 *   fieldable = TRUE,
 *   entity_keys = {
 *     "id" = "vendor_id",
 *     "uuid" = "uuid",
 *     "label" = "name",
 *     "bundle" = "type"
 *   },
 *   bundle_keys = {
 *     "type" = "type"
 *   },
 *   route_base_path = "admin/vendors/types/manage/{bundle}"
 * )
 */

and VendorType:

/**
 * Defines the vendor type entity.
 *
 * @EntityType(
 *   id = "vendor_type",
 *   label = @Translation("Vendor Type"),
 *   module = "vendor",
 *   controllers = {
 *     "storage" = "Drupal\vendor\VendorTypeStorageController",
 *     "access" = "Drupal\vendor\VendorTypeAccessController",
 *     "list" = "Drupal\Core\Config\Entity\ConfigEntityListController",
 *     "form" = {
 *       "default" = "Drupal\vendor\VendorTypeFormController",
 *       "delete" = "Drupal\vendor\Form\VendorTypeDeleteForm"
 *     }
 *   },
 *   config_prefix = "vendor.type",
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid",
 *     "label" = "label"
 *   }
 * )
 */

VendorType is a config entity and serves as the bundle for Vendor, in exactly the same way that the core Node/NodeType entity types do. I have all the boilerplate code in place mimicking the Node/NodeType relationship.

Everything's up and running, the entities work great in every respect, but I can't figure out a small detail. On the "Content types" admin page, the action links in the right hand column of each row have the "Manage Fields/Manage Display/etc" links, plus the usual "Edit/Delete" as inherited from EntityFormController::actions().

On my VendorType overview form, I only see the Edit and Delete links, not the field-specific ones.

(ignore the missing delete buttons, those particular types can't be deleted; the delete link shows up for manually added types)

I've tried to track it down but it seems like the node module is getting these links added for "free" as it were, without implementing anything explicitly to add them.

What do I need to do to take advantage of this little nicety and get the field-specific links added automatically for my own entity types?

Since the patch in Use hook_entity_operation_alter() for manage fields and manage display links has been deployed, there is now a easier way to alter the operations visible in a list of entities. Also, the Field UI module automatically adds some operations.
Differently from what the patch in that issue shows, the hook to implement is hook_entity_operation(), which is implemented as follows, from the Field UI module.

function field_ui_entity_operation(EntityInterface $entity) {
  $operations = array();
  $info = $entity->getEntityType();
  // Add manage fields and display links if this entity type is the bundle
  // of another and that type has field UI enabled.
  if (($bundle_of = $info->getBundleOf()) && \Drupal::entityManager()->getDefinition($bundle_of)->get('field_ui_base_route')) {
    $account = \Drupal::currentUser();
    if ($account->hasPermission('administer ' . $bundle_of . ' fields')) {
      $operations['manage-fields'] = array(
        'title' => t('Manage fields'),
        'weight' => 15,
        'url' => Url::fromRoute("entity.{$bundle_of}.field_ui_fields", array(
          $entity->getEntityTypeId() => $entity->id(),
        )),
      );
    }
    if ($account->hasPermission('administer ' . $bundle_of . ' form display')) {
      $operations['manage-form-display'] = array(
        'title' => t('Manage form display'),
        'weight' => 20,
        'url' => Url::fromRoute("entity.entity_form_display.{$bundle_of}.default", array(
          $entity->getEntityTypeId() => $entity->id(),
        )),
      );
    }
    if ($account->hasPermission('administer ' . $bundle_of . ' display')) {
      $operations['manage-display'] = array(
        'title' => t('Manage display'),
        'weight' => 25,
        'url' => Url::fromRoute("entity.entity_view_display.{$bundle_of}.default", array(
          $entity->getEntityTypeId() => $entity->id(),
        )),
      );
    }
  }

  return $operations;
}

Before that patch was deployed, you had to implement a list controller and use its getOperations() method. For example, for nodes that is done in NodeTypeListController, whose NodeTypeListController::getOperations() method contains the following code.

  if ($this->moduleHandler->moduleExists('field_ui') && user_access('administer node fields')) {
    $operations['manage-fields'] = array(
      'title' => t('Manage fields'),
      'href' => $uri['path'] . '/fields',
      'options' => $uri['options'],
      'weight' => 0,
    );
  }
  if ($this->moduleHandler->moduleExists('field_ui') && user_access('administer node form display')) {
    $operations['manage-form-display'] = array(
      'title' => t('Manage form display'),
      'href' => $uri['path'] . '/form-display',
      'options' => $uri['options'],
      'weight' => 5,
    );
  }
  if ($this->moduleHandler->moduleExists('field_ui') && user_access('administer node display')) {
    $operations['manage-display'] = array(
      'title' => t('Manage display'),
      'href' => $uri['path'] . '/display',
      'options' => $uri['options'],
      'weight' => 10,
    );
  }

The description for the class simply says "Provides a listing of node types." Looking at the plugin annotation for the NodeType class, you could notice a reference to NodeTypeListController.

@EntityType(
  id = "node_type",
  label = @Translation("Content type"),
  module = "node",
  controllers = {
    "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
    "access" = "Drupal\node\NodeTypeAccessController",
    "form" = {
      "add" = "Drupal\node\NodeTypeFormController",
      "edit" = "Drupal\node\NodeTypeFormController",
      "delete" = "Drupal\node\Form\NodeTypeDeleteConfirm"
    },
    "list" = "Drupal\node\NodeTypeListController",
  },
  config_prefix = "node.type",
  entity_keys = {
    "id" = "type",
    "label" = "name",
    "uuid" = "uuid"
  }
)

The class defined as list controller for your Vendor Type entity uses the following code, for ConfigEntityListController::getOperations().

public function getOperations(EntityInterface $entity) {
  $operations = parent::getOperations($entity);
  $uri = $entity->uri();

  // Ensure the edit operation exists since it is access controlled.
  if (isset($operations['edit'])) {
    // For configuration entities edit path is the MENU_DEFAULT_LOCAL_TASK and
    // therefore should be accessed by the short route.
    $operations['edit']['href'] = $uri['path'];
  }

  if (isset($this->entityInfo['entity_keys']['status'])) {
    if (!$entity->status()) {
      $operations['enable'] = array(
        'title' => t('Enable'),
        'href' => $uri['path'] . '/enable',
        'options' => $uri['options'],
        'weight' => -10,
      );
    }
    else {
      $operations['disable'] = array(
        'title' => t('Disable'),
        'href' => $uri['path'] . '/disable',
        'options' => $uri['options'],
        'weight' => 20,
      );
    }
  }

  return $operations;
}

To get the same links, you should define a custom class that extends ConfigEntityListController and implements EntityControllerInterface, adding in the getOperations() method the necessary code.


Editing own content for content type giving me access denied For content type "XYZ" for a user that has "Edit own XYZ" content I get an access denied message when attempting to edit content that was created by user. Do I need any further access permissions? I can delete and view my own content, just not edit.

The "input format" on the body field might be set to one that you don't have access to, example  "Full HTML",  "PHP", etc.

Check that you (your role) has that access. Look here: "admin/settings/filters"

If you don't have access to the "input format" used on the body field then you can't edit that content.

I recently ran in to something close to this, I was surprised to find this as the solution. Hope this works for you.


Bandwidth Optimization options locked I'm running a largely default Drupal 8.0.0-RC2 site. At /admin/config/development/performance the "Bandwidth Optimization" settings for "Aggregate CSS Files" and "Aggregate Javascript files" are disabled, so I cannot change their state. Extensive though fruitless googling suggests this is unusual, but I'm stumped on where to start. I'm using the Drude environment for my site.

There is a problem with the public directory, it is not configured or it is not writable. You can check this with drush:

drush ev "var_dump(is_dir('public://'), is_writable('public://'))"

Result should be:

    bool(true)
    bool(true)

If these two conditions are true, then the checkboxes will be available.


Display an image search api page result I'm trying to display an image on the search api page result. I tried the following way: Displaying Images in Search Results, but I'm getting a "Notice: Undefined index: node...template.php" error. Off course after changing the preprocess function to theme_preprocess_search_api_page_result. Am I getting this error because the following preprocessor works only for the search module? Is there another way to add an image to the search api result?

I'm using the following modules version:

Search API 7.x-1.17
Solr search 7.x-1.10
Search Api Page 7.x-1.2

You first have to add the image to the index. Then preferably reindex.
Usually for some reason the image fields are hidden on the page, where you add the fields to the index.
The page in Drupal 7 would be under Search and metadata > Search API > Your index, edit > Fields
/admin/config/search/search_api/index/NAME_OF_INDEX/fields

And your image field you may add from the bottom - the section is called "Add related fields" and then you should choose your field and click "Add field". Afterwards you may click the checkbox to the field - in order to add it to the index.

The approach with node_load is a very bad one because that would load stuff from the database, where the idea of Search Api and in this case the connection with Apache Solr - is to get everything directly from the Solr.


How do I remove a DIV from the rendered result of a BEF exposed form? I'm using Bootstrap as my theme and Better Exposed Filters to generate check boxes for term filters that are exposed to my visitors/users.  Unfortunately, Bootstrap adds a "form-group" class to all elements of a form that aren't radio buttons and/or check boxes.  BEF (or something) adds a DIV around each of the check boxes and thus Bootstrap adds the form-group class and that messes with the formatting of the check boxes.

So it looks like:

 <input type="checkbox" name="field_list_crit_tags_tid[]" id="edit-field-list-crit-tags-tid-591" value="591"  multiple="multiple" class="form-control" /> WAAC

I need to remove either the DIV entirely or figure out a way to NOT put the form-group class on that particular div.

why not just write CSS that targets this item and removes any css applied by the default bootstrap .form-group ?

For example the rule could look like:

div.from-type-bef-checkbox.form-group {
  /* then "undo" whatever .form-group is doing -- you can see whatever it's
     doing by using Firebug or Google Chrome and inspecting the Element
     on the page.

     for example:
  */
  margin: 0 0 0 0;
}

By fixing just the CSS and not removing the css class or the div entirely you dont break or worry about upgrading these modules (of course you'll still have to check this CSS fix works in newer versions of the theme).

You can do this in your theme by adding or using a default custom stylesheet provided by your theme.


How to create product bundle or similar to that? I have a plan to create a e-commerece website for Computer Assembling.
I have exp in Prestatshop and few other CMS (e-commerce) framework.
In that i found Drupal 7 is having the best one like durpalecommerece. So I selected Drupal 7 as CMS framework.
I download few modules ubercart and tried e-commerce module also.

But its not meeting my requirements. My requirement is

Homepage - User can see All default PC set (Monitor, CPU, Keyboard and Mouse) with price.
Select PC, Next page description will display.
Defualt Product piece is 1, but the user can increase more.
Based on the increase Rate will be changed.

Above steps are working fine. Below steps are not working.

Homepage - If user doesn't happy with default PC set, User can build there own PC
Select "Build own PC".
List of Monitor companies and inches will display.
User selects one monitor and click,
It will redirect to CPU Parts.
User will select Mother board, ram, hardisk ... one by one
On click "NEXT" redirect to shopping cart....

How to achive Product bundle here to get calculate amount in cart

For building a e-commerce website you should try the drupal commerce module or commerce_kickstart (If you are novice with drupal then commerce_kickstart is the option).
Drupal Commerce

  Core Features

  Create product types with custom attributes
  Dynamic product displays
  Order management, line item
  Payment method API, allowing many different payment gateways
  Tax calculation / VAT support
  Discount pricing rules
  Deep integration with systems like D7's Fields, Views,Rules and Entity API.

Commerce Kickstart

  Commerce Kickstart is the quickest way to get up and running with
  Drupal Commerce. It includes the latest versions of Drupal core,
  Drupal Commerce, and the other modules it depends on. It also gives
  you a set of options to create a fully-featured demo store out of the
  box complete with an attractive theme, catalog and search
  configuration, and a custom back office interface.
  Who should use Commerce Kickstart? Anyone who wants to skip weeks of
  configuration to build a commerce site on the Drupal Commerce
  framework.


How to override items per page in cloned view? I have some Views page and there is a pager with 10 items limit per page. I cloned this View and I want to have 6 items per page in this cloned View, but this is not possible. Every time I try to change it, it's changed on the main View as well.

How I can override this for cloned View? Is there any way to do it programmatically somehow?

You can do this with the Views UI.

Click on Display a specific number of items

Then at top in For select This block/page (override)

PS: When you add fields, contextual filters, etc... anything under/besides a BOLD/Bold section, you need to do this there too, as each section has its own For setting.


How can I add static text into a Views exposed filter block? I have a views exposed filter block that I'm using as a search form. I'm wondering how I can display static text within the block. Here's what my Block looks like:

Essentially I want to display the title (Find A Venue) to the left of the fields, and then display the word "or" between the two. If somebody knows how to move the block title to the left of the filter fields instead of above, I suppose that that would serve my purpose well enough as well. Although, it would be nice to know how to display the static text regardless.

You can do this with Better Exposed Filters.

Enable the module and then navigate to your view edit page.  Under Exposed Form, click Basic, which is next to Exposed form style, and change it to Better Exposed Filters.  Add a Description of "or" to your title.  This will place the text on the page; you will then need to style it with CSS to place it where you want.


What is the purpose of the PHP class FileTransfer? What is the purpose of the PHP class FileTransfer? In which cases, should a module deal with that class or one of its child classes?

FileTransfer is an abstract class for transfering files that specific implementations should extend. The available implementations are FTPFileTransfer, SSHFileTransder and LocalFileTransfer, which are used to transfer files using different methods.

What separates it from the "traditional" file transfer is that it is designed to operate on directories that are not writable by the web-server.

An obvious example is the update manager, which, by using these classes, is able to dowload and install module and theme updates automatically.

A module might interact with one of these classes in order to transfer files via FTP or SSH.


How can I turn a field into a link? I've got a content type with fields whose values are URLs. I'd like to use a view to display these as links, using the field label as link name, something like {field_label}.

I've got the field values displaying correctly. I just can't figure out how to turn them into links like above (or if this is even possible).

How can I achieve this?

You can use REWRITE RESULTS with REPLACEMENT PATTERNS

Any Text

Example
If i want to edit any node

Any Text


Error trying to update database after module update After I update a module, and click at http://omroepzuidplas.nl/admin/update/ready on the 'run' button to do the database updates. Drupal sends me to this url:

http://omroepzuidplas.nl/http%253A//omroepzuidplas.nl/authorize.php%3Fbatch%3D1?op=start&id=2796

Which result in an 404 page not found error.

I use Drupal 7.50 on CentOS7.

The problem you are having is likely either that the RewriteBase is not set in .htaccess, or the base_url is not set in settings.php.  Likely you can bypass the settings problem if you go directly to http://omroepzuidplas.nl/update.php.

To do database updates you have to be logged in as User 1 (often called admin or super admin, but it could have any user name).


allow user to choose from his own referenced nodes I have two content types: business listing, product listing.
"Product listing" has an Entity Reference field. This field points to the nodes of "business listing".
I want to allow user to choose from his own "business listing" nodes (during adding a "product listing" node).
I have created a view to list the nodes of "business listing" type and have Added a Entity Reference display to the view. Then have selected the view Under "Entity selection".
Now, I have a problem in adding proper contextual filter.
I have added a contextual filter of "Content: Author Uid" and selected "provide default value".

a) if I select "USER ID from logged in user" as default value:

This solution will break if an admin is editing the node. The field will then show only nodes the current user (admin) has created.

b) if I select {"User ID from URL" and "Also look for a node and use the node author"}:
This solution will break if an user is adding a new node. The field will not show any nodes!

How can I achieve this?

No need to write any code for this.
Use reference_option_limit module properly in your content types & when you create view and provide default value 'User ID from URL' - Please mark the checkbox 'Also look for a node and use the node author' to true.

Enjoy !!!


Replacing initial view of a panel with a content view I have a Panel that is supposed to show initially a Taxonomy view and a set of filters for a Content view. If the user hits any of these filters, my taxonomy view fades out and shows my content view.

Is it there any easy way of doing this, without having to create a personalized template file with some javascript under the hood?

I Finally ended up showing both views, and having them hidden depending on the status of the exposed filters via Jquery.


Display different menu links based on page/theme I have a custom main theme for my website along with a Blog theme using themeswitcher. All content in my /blog directory uses the Blog theme.

Question:
I would like to display different links in the main menu when users are on my blog theme vs. main website theme. If I choose to display the Primary Menu in my blog theme all of my main website links show up. Are there any menu Modules that allow enable/disable links based on directory and/or pages?

I there an easy way to do this?

You will need to mange the links in 2 different menus. for example Main Menu for all website links and Blog Menu to have the links related to Blog pages.

Disable the Main Menu and the Secondary Menus from your theme settings.

Now goto blocks pages and configure the main menu block scroll down to bottom

under Show block on specific pages

select All pages except those listed and type blog/*

now save this block configuration and goto configure Blog Menu scroll down to bottom and select Only the listed pages and type the same in texarea ( blog/* ) and save the block configuration.

Now depending on your URL pattern it will display your required menu.


How to theme a specified node? I need to add some php codes into my "About" page.

Is it possible to make a template for a specified page?

I know that I can insert php code into textarea, but I like to do it in real php file.

Yes, you can use templates for this; there's an explanation of how it works on Drupal.org.

To override the page template for a specific node you would use a template file with a name like:

page--node--1.tpl.php

Where 1 is the nid of your node.

The name of the file is based on the path of the page you want to provide the template for, essentially with / characters changed to --. So for the path '/node/1/edit' the template file would be named:

page--node--1--edit.tpl.php

The easiest way to start the new template file is just to copy the existing page.tpl.php source into your new file, and add/edit what you need.

If it's the node specifically you want to theme (and not the whole page), you can provide template files for it in much the same way. There are more examples in the link above, but basically for node/1 the file would be:

node--1.tpl.php

Remember to flush the caches when you add the new template file so the changes get picked up.


How to use PHP Evalution in rules scheduling I have a rules component that i want to trigger on specific time that is set by end user.
in my case i have a form where user create rental property and select the rent date there. then i have another form of alerts where user can set alerts related to rentals. like user wants alert before 2 days of rental date. I am able to set the rental date but unable to get the value of alerts section to check what value the end user has set to get an alert. I tried to put sql query in 'PHP Evaluation section' but in scheduling section it shows the blank date. Rule that i have creatrted:

component: Schedule reminder to end user
Rule: Schedule rental alerts
action: schedule component evaluation
      data-selector:node:field-rental-start-date
      php evaluation: $query = db_query("SELECT field_days_before_the_rent_value FROM field_data_field_days_before_the_rent");
foreach($query as $result){$res = $result->field_days_before_the_rent_value;}
return $value - $res;

Please help me here how i can get the field_days_before_the_rent_value.

After struggling so many days I found the solution that how we can do scheduling using php evaluation. To do this I have simply pick the value in data selector(under my rule) that is set by user in his rental form as shown in my 1st screen short. Now I need to schedule that rental date according to the alerts set by user in alert section (screen short2) where i was stuck.Under PHP evaluation section we have to use $value variable that returns the value that we selected in data selector.In case of dates  it returns the timestamp not the actual date. So then I used PHP code to add/substract the days according to the user set in alert section and succeed to do scheduling.

I hope it will helpful for others.


Is it possible to get node template suggestion per views row on Drupal 8 I need to theme the first row of a view page with a different image size and the theme debug suggested me:

node--view--article--page-1.html.twig

This is new on drupal 8.

I was wondering if is possible to get template suggestions per row number.

This is probably not a simple task for a template name suggestion, because at the time of rendering the node is unaware of where it is placed in the view.

So a better approach might be to use two different view modes, one for the first and one for the rest of the nodes. Then use a row style plugin to switch the view modes, for example the module Views Parity Row.

If this is only to apply CSS, then don't try to add row classes to the node. Add them to the views row container and target elements inside of the node with multiple CSS selectors.


Allow users to set permissions for profile fields I would like users to be able to determine whether a field is displayed publicly. For example, their real name is required for the site, but I don't want to force users to display it.

Without information on what version of Drupal you are using or what you are using for profiles, here is a suggestion for each type of profile on Drupal 6:

Using the core profile module, check out Profile Privacy

Using Content Profile, take a look at CCK Privacy


How to add wrapping elements & classes to a table in a view? I'm building a custom theme using bootstrap 3, I need responsive tables. Yes, I'm aware of responsive_tables but I didn't like it. I want to use bootstrap's native .table-responsive. for that I need to wrap table like this:

    ...

I need to add couple more classes to the
 element.

How to do that?

You can add css class to the whole view (go to your view edit page -> Advanced -> Other -> Css Class). It will print something like this:

       ...

In views UI there is no option to add class to
 element, but you can create/copy a template file (e.g. views-view-table.tpl.php, you can copy it from views module, look in "Theme information" in your view for more specific details) in your theme, clear caches and edit it as you wish.


Alter the exposed filters of a view, based on the view result I have a view that displays matching nodes, based on contextual arguments.

I'd like to create an exposed filter that filters by node title, displaying a drop down (select) menu with options for every node in the result set.

I can modify / set the contents of the exposed filter using hook_form_alter, but the views query hasn't executed when this hook is called, so I don't have access to the result set.  If I use hook_views_post_execute then I have access to the result set, but the exposed filters form has already been rendered.

I know that I could write an EntityFieldQuery to select the nodes and set them within hook_form_alter, but that isn't very DRY as I would effectively be re-writing (and executing) the same query that Views will be executing anyway.

What's the best practice way to achieve what I'm looking for?

Since this has gone unanswered, I decided to get creative and it's very easy with Entity Reference, Views Reference Filter and optional Rules.

Add an entity reference field to the content type that will reference its own node. So node/5's field will reference node/5. This can be done with Rules
automatically. Old nodes can be updated with VBO if needed.
In your view, Add > Entity Reference with the exact same filters
etc. That should be automatic. Remove unwanted fields. Save the view.
Go back to your regular view, add an exposed filter (only for that pane) for the entity reference field we just created with (reference filter) written beside it.
In the exposed filter's settings, choose the Entity Reference view we just created. If it's just using contextual filters, don't worry about sending arguments.

The logic: The view will process the entity reference view first and provide its results to the first view as an exposed filter. I just tested it and it works perfectly. Takes about five minutes.


Ajax Quiz or Ajaxify my site im using Drupal 7 and the Quiz module for making some quick courses.

It works fine, but i would love to make them with ajax transitions instead of doing it by the old form way.

I have seen the ajax quiz module, but it doesnt seem to work. any other recommendation? there's any other module i could use in order to ajaxify my quizzes or my whole site? Thanks.

You can try Quiz Drag Drop module

  This module allow you to add drag drop type of question in quiz
  module.

  By using this module admin can upload images with their titles and
  later all the titles will become placeholder. User need to drag and
  drop images on the correct placeholder to get points.

  This module is an attempt to enhance Quiz module features by
  introducing another type of question.


Is the tags section valid in the info.yml file? I see in the devel.info.yml file a section named tags

tags:
- developer

But I can't find it on the documentation page. Is the tags section valid in the info.yml file or is it just an error?

I do not think it is valid yet. There is an issue on this

https://www.drupal.org/project/drupal/issues/1868444


How do I enable and use a view mode for a product type? In default commerce2 (drupal 8) I want to add second product-type view mode, to show in views - like teaser version, including add-to-cart btn with variations. I have additional field in Product type Default (in some custom product types too) and I want to limit them in this second view mode.

Seem like Product type (Default and customs) no options to add other view mode and in views is available Default view mode for Product. Product (type) is not listed in Structure > Display modes > Views modes.

edit:

lamp stack, php-7.0, composer instalation from http://docs.drupalcommerce.org/v2/getting-started/install.html, act as uid 1

admin/commerce/config/product-types/default/edit/display

missing "Custom display settings" above "Save" btn

admin/structure/display-modes/view

Missing "Product (type?)" in list

Adding the answer to the question here as provided by @Bojan Zivanovic in a comment above. You can add View modes for products by clicking on the + Add view mode blue button at the top of the page.


Resolve the error "An illegal choice has been detected..." I have written code like below and all works fine, but while submitting the form I get the error below. I am trying to filter the second dropdown based on the first drop down selection.

  An illegal choice has been detected. Please contact the site administrator.

How do I overcome that error?

function dynamic_location_dropdown_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'product_node_form') {

  $location_options = array();

  if(isset($form['field_destination']['und']['#default_value'][0])) {
    $destination = $form['field_destination']['und']['#default_value'][0];
  }
  else {
    $destination = 0;
  }

  $location_options = dynamic_location_dropdown_locations($destination);

  $form['field_destination']['und']['#ajax'] = array(
    'event' => 'change',
    'wrapper' => 'squadron-wrapper',
    'callback' => 'dynamic_location_dropdown_ajax_callback',
    'method' => 'replace',
  );
  $form['field_product_location']['#validated'] = true;
  $form['field_product_location']['und']['#prefix'] = '
';
  $form['field_product_location']['und']['#suffix'] = '
';
  $form['field_product_location']['und']['#options'] = $location_options;
  }
}

function dynamic_location_dropdown_ajax_callback($form, $form_state) {
  $country_id = $form['field_destination']['und']['#value'];
  $form['field_product_location']['#validated'] = true;
  $form['field_product_location']['und']['#options'] =  dynamic_location_dropdown_locations($country_id);

  return $form['field_product_location'];
}

function dynamic_location_dropdown_locations($destination_id) {
  $nodes = array();
  $nodes[''] = '- None -';
  if($destination_id != '') {
    $select = db_query("
      SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
      FROM {node} node
      LEFT JOIN {field_data_field_location_country} field_data_field_location_country
      ON node.nid = field_data_field_location_country.entity_id
      AND (field_data_field_location_country.entity_type = 'node'
      AND field_data_field_location_country.deleted = '0')
      WHERE (( (node.status = '1')
      AND (node.type IN  ('location'))
      AND (field_data_field_location_country.field_location_country_nid = $destination_id)))
      ORDER BY node_title ASC
    ");
    $nodes[''] = '- None -';
    foreach ($select as $node) {
      $nodes[$node->nid] = $node->node_title;
    }
  }

  return $nodes;
}

The problem is most likely because of a requirement for FAPI AJAX which is documented in AJAX Forms in Drupal 7, though can be easily missed.

  Changes to the form must only be made in the form builder function (ajax_example_autocheckboxes() in the example here), or validation will fail. The callback function must not alter the form or any other state.

The fact that you're setting the form element [#options] in the AJAX callback is definitely a problem. The AJAX callback should only return the array or HTML to be printed, not change the form. That callback should only contain the return statement.

The changes to your form should be made in the form_alter. Also, you should use the form_state array to check whether a value has been selected for your first dropdown. This will be updated during an AJAX request.

I recommend looking at the examples module, as well as these pages for more information on AJAX in FAPI. It can definitely be tricky.

AJAX Forms in Drupal 7
AJAX Framework


Force rebuild of aggregated css/js I have manually removed all aggregated css and js files from sites/default/files.

I would like Drupal to regenerate these, but it does not. Drupal is still looking for the old files, the ones I have deleted.

Clearing the cache does nothing.

How do I force Drupal to recognize that the files are missing and need to be recreated?

In D7 you might want to clear also the variables drupal_js_cache_files and drupal_css_cache_files:

drush vdel drupal_js_cache_files && drush vdel drupal_css_cache_files

Other than that, do you have any other cache on top of drupal (varnish?). Your pages could be cached with the reference to the old JS files. Is your site broken (404 on CSS/JS files) or is it just referencing the old ones? Usually drupal regenerates aggregated files if it can't find it.


Receive error message for radio buttons ."An illegal choice has been detected. Please contact the site administrator." I have created a multi step form, in which I have added radio buttons dynamically by using data from the database. The radio buttons added here are not required. But still I get the following error. I have created a custom module.

  An illegal choice has been detected. Please contact the site
  administrator.

Kindly help me resolve this issue. This is not a duplicate issue. Other issues listed have mentioned that the radios button are used as required field in that case.
Please find the code added :

$opt = array(
        'f' => 'Friend or Business Associate',
        'b' => 'Brochure',
        'c' => 'Company',
        'a' => 'Another Columbia Asia Hospital',
        'ad' => 'Advertisement',
        'an' => 'Another Doctor',

);
$step1['questions']['learn_abt'] = array (
        '#type' => 'radios',
        '#title' => t ( 'In How did you first learn about the Hospital' ),
        '#options' => $opt,

);

I somehow fixed the issue. Normally if it is not a required field we don't need to add the following code.

  '#required' => FALSE,

But adding this code fixed my issue. Please let me know if there is any better or correct way to fix this.


Nothing displaying for Drupal main menu I'm trying to output the main_menu in to a custom theme on the page.tpl.php template however nothing is displaying when I add <?php print theme("links", $main_menu) ?>

However when I do a var_dump on the $main_menu I get

array(2) { ["menu-218"]=> array(2) { ["href"]=> string(7) "" ["title"]=> string(4) "Home" } ["menu-335"]=> array(2) { ["href"]=> string(6) "node/1" ["title"]=> string(4) "Home" } }

What might I be doing wrong? I'm new to Drupal so be kind please :D

I do have features[] = main_menu in my .info file.

Try adding the following lines to your template file. Works for me.

$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
print drupal_render($main_menu_tree);


Parsing XML files to populate form fields I need conceptual clarification. I have fields of a form that I want to populate by letting a user use an XML file so my custom form module can parse and assign XML to form fields. I do not need to keep the XML file permanently.

First question: When using the file field widget on my form, after I select my file and the file name appears on the form, Drupal or the browser seem to have it stored in memory somewhere. It is possible to parse the XML file from this location in memory with a submit handler that populates the form? (So 2 submit handlers on the form, one to submit the XML to populate form and the other to submit the form to create node.)

Last question: Would this be easier if I have a form with a single file widget that uploads an XML file to a temp directory and builds + renders a form on the node after it has parsed the data?

Thanks all!

I suggest you use the Feeds module. (I believe you may need to also read up on its SimplePie integration to help with the XML.)

Basically, it provides you with the form and functionality for importing, storing, and reading your XML file. It is also designed to create a node using the info read from the XML file.

If you don't want a new node, then you can interrupt the process using hook_feeds_presave to work with the info that Feeds has read from the uploaded file. (For example, to load and populate a form with the imported info. I'm looking into doing just that, myself.)

If you didn't want to use Feeds, then read up on the File interface and File API, which let you work with the uploaded file, store it temporarily, read data from it, etc. I've found that very useful.


Publish tweets in drupal 7 site in real time I need to publish tweets from twitter in my Drupal 7 site. I use twitter module but I need to publish this tweet in real time that's not the case with this module. Any one have an idea to fix this issue ??

Try Selective Tweets. As written in comparison to another Twitter module (Tweed Feed), Selective Tweets renders Tweets almost realtime:

Tweet Feed does periodic imports of Tweets and turns them into nodes,
while Selective Tweets renders Tweets almost realtime and saves none
of them in the database as content. This is also the main difference,
with the effect that Tweet Feed has a significant delay on the
realtime Tweets. On the other hand, the Tweet Feed created nodes can
be displayed in Views which gives big flexibility in the way of
displaying Tweets.
Use Selective Tweets when you want a light weight
manner of displaying Tweets without database storing and you want no
major delay in displaying realtime tweets.


Panel Content not displaying correctly after migrating site to new server This is how it looks like after I migrated the site. I compared the new panelizer and panels folders with a backup folder that I had  to see if there were discrepancies, but the folders had the same files. I also resaved the admin page as suggested in another post, but that didn't do it for me.

I am using D7 by the way.

When you're browser builds the admin page, it makes multiple requests over HTTP to the server to fetch resources, such as css files. If you look over that list, using whatever debugging tools your browser provides, you might be able to find out which file Panels is expecting to be there, but your browser fails to find.


What are the tables that once were term_node & term_data? In Drupal 6 there are the following database tables: term_node and term_data.

What are the equivalent tables for Drupal 8?

All tables by the taxonomy module are prefixed with taxonomy_ since Drupal 7.

term_data is now taxonomy_term_data but also taxonomy_term_field_data, as it is a translatable entity. Never interact with those tables directly, use the entity API.

term_node is taxonomy_index, but it is only a secondary index you can read from there, but the primary storage are the entity_reference fields that point from nodes or any other entity type to taxonomy_term. So if you want to change values, you need use the entity API as well.

Taxonomy works very different than in Drupal 6, where you had to enable a vocabulary per-node type. Now terms work exactly the same as any other refeence, between nodes and other nodes, nodes and users and so on. The only left-over of the old system is that an index table is maintained specifically for node -> taxonomy references.


Adding variables to all templates? I'm looking for a way to inject a feature flag variable so that it is accessible in all Twig templates, but I can't figure out how to do it. I've tried adding variables in preprocessing hooks in my .theme file, but this doesn't seem to do to the trick. For example:

function mytheme_preprocess_page(&$variables) {
  $variables['some_feature_flag'] = 'test_value';
}

function mytheme_preprocess_html(&$variables) {
  $variables['some_feature_flag'] = 'test_value;
}

My template for the node contains {{dump(some_feature_flag)}}, which evaluates to NULL. I can't find a way to get this working.

So generally, preprocess hooks impact the specific theme item or template, so hook_preprocess_page() impacts the page.html.twig and hook_preprocess_html() does so for html.html.twig.  You mentioned your twig template for node, to add variables to that you would need to implement hook_preprocess_node().

Your question was adding variables to all templates, I believe for that you would use just hook_preprocess() (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_preprocess/8.2.x) - though I have never tried it.  I imagine it would be called for every theme call so that could create a lot of overhead.

And don't forget to 'Clear all caches' under admin->config->development->performance when you create new preprocess hooks or template files.


Pager in Render Array In a custom module I have a block defined and the function that builds the block returns a render array. In that render array I am looking to create a pager for my content since it is a listing of items.

If I run pager_default_initialize during my query building like so this automatically adds a pager to the top of the block.

$total = $query->countQuery()
  ->execute()
  ->fetchField();

$page = pager_default_initialize($total, $per);

$query->extend('PagerDefault')
  ->limit($per)
  ->range($page * $per, $per);

I want to have more control over the pager, like adding it to the bottom of the block. If I remove the pager_default_initialize from the query building code like so, I can stop the pager from automatically being added.

$total = $query->countQuery()
  ->execute()
  ->fetchField();

$page = pager_find_page();

$query->extend('PagerDefault')
  ->limit($per)
  ->range($page * $per, $per);

So, the question is, how do I add the pager to my render array so it renders the pager at the bottom of the block?

My render array currently looks like this:

$content['results'] = array(
  '#type'       => 'container',
  '#attributes' => array(
    'class' => 'results',
  ),
);

if ($data->rowCount()) {
  foreach ($data as $record) {
    $content['results'][] = array(
      '#theme' => 'CUSTOM_NODE_THEME',
      '#node'   => node_load($record->nid),
    );
  }
  if ($per > 0) {
    $content['results']['pager'] = array(
      '#theme' => 'pager',
    );
  }
}

The theme_pager() is not being run when the block is rendered.

Any help would be awesome!

Here is the solution. I knew as soon as I asked the question I would find the answer!

First off, the query building code must not run pager_default_initialize, like so:

$total = $query->countQuery()
  ->execute()
  ->fetchField();

$page = pager_find_page();

$query->extend('PagerDefault')
  ->limit($per)
  ->range($page * $per, $per);

The pager render array should be created like so:

$content['results']['pager'] = array(
  '#pre_render' => array('CUSTOM_PRE_RENDER'),
  '#theme' => 'pager',
  '#variables' => array(
    'total' => $total,
    'per' => $per,
  ),
);

And then run pager_default_initialize in the custom pre render function:

function custom_pre_render_intialize_pager($_element) {
  pager_default_initialize($_element['#variables']['total'], $_element['#variables']['per']);

  return $_element;
}

This code will only work to add a single pager to the block and may not work if there is more then one pager on the page.


Create test and development copy of a production site I have a Drupal8 site on my hosting account. I created a copy from the database;
I create a copy of the code.

Both the copies I used should be a copy of my production site. I imported the SQL into a new database. I changed the settings of the copied Drupal code to point to my new database.

When I go to the browser and look at local install I can only get to the install page.

Can anyone please point out where I am going wrong?

You have a problem with your settings.php file.

Check if the name is correct.
Check if the database is set correctly.
Try to access in command Line to the database.
Check rights of your files.
Try to clear the cache with drush cr.


Views and CSS : how to exclude the exposed filters from CSS? I'm using CSS to make a masonry effect in Views. And it works, but... The exposed filters and the pager get "caught" in the masonry effect instead of being on top (and bottom) of the results.

Question : how to set the CSS so that the exposed filters and the pager stay out of the results.

Thanks!

ps.: I know about Masonry views, but I prefer CSS.

The CSS:

In Views "Other" : CSS Class

.brick-user {
    margin: 1.5em 0;
    padding: 0;
    -moz-column-gap: 10px;
    -webkit-column-gap: 10px;
    column-gap: 3em;
    font-size: .85em;
}

Settins : Row class

.brique-user-item {
    display: inline-block;
    background: #fff;
    border: 1px solid lightgrey;
    padding: 15px;
    margin: 0 0 1.5em;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;

}

You could use the "Exposed form in block" setting under Advanced settings to get the exposed filter out of the masonry markup and put it a region above or beneath your masonry view.


Import a single yml configuration file Is it possible to import one single configuration file by specifying its path, or a group of Yaml files contained in a specific module?

You can use

$ drush cim --partial --source=only-few-configs/

Your help says:

$ drush cim --help
Import config from a config directory.

Examples:
 drush config-import --partial             Import configuration; do not remove missing configuration.

Arguments:
 label                                     A config directory label (i.e. a key in $config_directories array in
                                           settings.php). Defaults to 'sync'

Options:
 --partial                                 Allows for partial config imports from the source directory. Only updates and new
                                           configs will be processed with this flag (missing configs will not be deleted).
 --preview=<list>                          Format for displaying proposed changes. Recognized values: list, diff. Defaults
                                           to list.
 --source                                  An arbitrary directory that holds the configuration files. An alternative to
                                           label argument

Aliases: cim


Is it possible to redirect a user to avoid showing an AJAX batch processing error? I'm trying to allow users to cancel their accounts without requiring e-mail confirmation as described in this question.

Currently, when I use the following code, the user account is cancelled properly, but the AJAX display shows a nasty error.

  else {
    // Cancel the account
    user_cancel($form_state['values'], $account->uid, $form_state['values']['user_cancel_method']);

I tried adding drupal_goto('user/logout'); after user_cancel(), but this immediately logs the user out and the account is not cancelled.  What I would like to do is cancel the account, log the user out, and somehow not display this error.

I found the cause of the error-- I had a custom rule that sent an e-mail to the admin when the account was cancelled.  By deleting this rule, the error disappears and the user is logged out properly.


Why is my MONTH view still showing a DAY as the title? UPDATE: I see the issue was not fixed in the current release so am especially interested in any suggestions for workarounds. For example, maybe I could hide the default header with CSS and add the correct title in the view.

ORIGINAL QUESTION: I know this was a bug in the 7.x-2.x-dev version of the Date module, but it seems to have been patched. I am running 7.x-2.8 (the latest) in which it should be fixed.

Why am I having this problem, and more importantly how can I work around it? I am working on a site where I only have access to the site administration, and not the server (ie: I can't patch the module myself).

It appears that the fix isn't in the latest release (7.x-2.8) yet and is instead in the current (7.x-2.x-dev) version. According to the comment #70 in that thread you posted, the patch is meant to be applied to the current release and not the latest dev (which is why it failed). If you run the patch in comment 70 against your 7.x-2.8 version it should correct the issue. As you stated that isn't an option, you can try to have the drupal update page grab the latest dev.

You can always check the release date for different branches on the project page. For example, Date currently shows the 7.x-2.8 branch as having been released on July 29th, 2014 while the latest commit, 7.x-2.x-dev, was released on June 16th, 2014. Hope that helps


Next/previous links in a view based on contextual filter in the url I have a page view in a Drupal 7 view with contextual filters in the URL.  something like /events/%1/%2 - the first parameter is the year, the second is a taxonomy term. So /events/2014/3 is all the events in 2014 in category 3.

I want to provide next and previous links based on the year (the first filter parameter). Is this even possible?

Not sure what your strengths are, but you could easily accomplish this with a custom php block.  If you did something along the lines of

<?php
$previous = arg(2) - 1;
$next = arg(2) + 1;
?>
<a href="/events/<?php print $previous . '/' . arg(3)?>/">Previous
<a href="/events/<?php print $next . '/' . arg(3)?>/">Next

I would clean up that code and use the l() function to create a link, but that is the general concept.


How do I invalidate cache for a block for anonymous users on a schedule? At the top of every page of page of my organization's site resides the current hours of operation and current "now open"/"now closed" status, using Views block and Office Hours module).
At this time of night on a Wednesday when logged in, I correctly see that the hours are reflecting tomorrow's hours and that the organization is now closed:

However when logged out, I see that the current day's hours (now over) and "NOW OPEN". It's six hours after closing time and the 5 minute page cache time in performance settings does not seem to be respected for anonymous page views:

What can I do to force an anonymous cache clear (overkill?) or invalidation of a block for anonymous users, perhaps on a schedule? I'm aware that the built-in Page Cache module may be caching full rendered pages for anonymous users while Dynamic Page Cache module makes it usable for logged in users. Shouldn't Page Cache respect the page cache maximum age set in the Performance settings page? Most people viewing the current hours at the top of every page are anonymous users.
For now I'll manually clear the cache, making the status update properly (not ideal).

At the top of the issue queue of Office Hours is this issue:
Fix javascript in D8-version of office_hours module
The problem is, you need this issue resolved, because for anonymous users javascript has to work.
If you want to build your own module, follow @oknate advice and use a lazy builder in a custom block plugin and install BigPipe to get the javascript part for anonymous logged-in users.
Updated question:
For anonymous users you can instead of disabling the Internal Page Cache set an expires header to the response as suggested by @Berdir's comment. See https://drupal.stackexchange.com/a/196557/47547


Add hook after registration form submit I'm trying to club Drupal & Magento together. So I want to make the registration seamless. If any user register in Drupal they want to register in Magento automatically using a custom module in Drupal. I have scripts to register in Magento by sending data to Magento script file.

I want to know how to make a AJAX call to that script file, using a custom Drupal module. I'm using Drupal 7 version.

You can use hook_user_insert, in which you can easily execute CURL, in hook_user_insert you will have all your data regarding the user.


User Edit Page for different elements I want to customize the user edit page.  I want to separate the elements (eg. user password, user picture, user email) and put them each on a separate edit page.  I tried the panels module, but that only allows me to move the entire form.

Is there a way to separate these form elements on different pages. For instance a change password page, a change user picture page and add the email into an existing user profile edit page?

There are basically two main directions you can go if you want to 'expand' user profiles:

You can either add fields, field groups and eventually group them in tabs or thelike.
Or you try the module Profile 2 wgich is basically the successor of the core profile module.

Both approaches can be fruitful – both will let you spread user profiles over different 'pages' (or tabs). But I'm not sure how fine-grain you can actually go with these two approaches – and if you can actually 'diconnect' the change password ui from the rest. I usually try to keep the core info on one page – and 'the rest' (contact and bio etc.) on sub-pages (tabs).


Remove one of the two "Apply to selected items" submit buttons with Node Bulk Operations If you make a view and add the Node operations bulk form, two "Apply to selected items" boxes are automatically generated like this:

How do I get rid of one of these?
I turned on twig debugging, but the template that is outputting the button is core/modules/system/templates/container.html.twig, which is not something that I can easily customize to remove one of the buttons.
How I created the view:

Create a new view of content showing fields.
Add Node operations bulk form under Fields.
Save the view.

This is intentional functionality for some workflows (for long lists of results).
If you wanted to get rid of the button, you could hook_form_alter it away. Form IDs and array structure are dynamic based on your view so you'll have to adjust accordingly based on the view & action button to remove (this can be found in the Views UI, if not known).
/**
 * Implements hook_form_alter().
 */
function MODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // @TODO: Determine view_id / display_id / field_id for a specific VBO form:
  if ($form_id == 'views_form_' . $view_id . '_' . $display_id) {
    // HEADER ACTION BUTTON:
    //unset($form['header'][$field_id]['actions']);
    // FOOTER ACTION BUTTON:
    //unset($form['actions']['submit']);
  }


Taxonomy Menu Associated with a single content type I have a single Taxonomy used for all Content Types in the site.  I have one Content Type called "Books" for which I'd like to build a Taxonomy Menu for just this content type.  As I looked through Taxonomy Menu for Drupal 6, I saw a note that indicated it had some association with views.

Is it possible to use a view to let Taxonomy Menu build a view of terms from with the count of "Books" in each?

Please take a look at https://drupal.org/project/views_groupby. You should be able to:

Create a new view that has a filter of 'books' content type
Add a filter to ensure the node is published
Add a views group by to group on taxonomy term
Use the SQL count funtion built into views group by

Hope this helps


Where are Cache settings stored? I assumed the settings from the function system_performance_settings were stored in variables, but couldn't figure out which.

If you trace the code from the system_performance_settings, you'll see that is uses system_settings_form for form generation, which uses system_settings_form_submit form submit handling, which in turn does

foreach ($form_state['values'] as $key => $value) {
  if (is_array($value) && isset($form_state['values']['array_filter'])) {
     $value = array_keys(array_filter($value));
  }
  variable_set($key, $value);
}

So to find any individual variable name, your best bet is to

drupal_set_message($key);

in that function.


Remove/Rename Home tab Drupal 7 I was wondering if it is possible to either remove or rename the "Home" tab Drupal puts in by default. The site is being used as a store/shopping cart and for it's purposes does not need a convention "Home" tab.

Go to /admin/structure/menu/manage/main-menu and it can be deleted from there.


Script exits on drupal_bootstrap_full when run from system cron I have a script that imports data into custom entities created in a drupal 7 database. It needs to run daily so i've added it to my system crontab (running CentOS 6.7). The problem i am having is that when it's run from cron (the script is executable and there's a symlink to it added in /usr/sbin) it runs but fails when the drupal bootstrap is run.  It works flawlessly when run from my user id, the service account user id, another persons id, and on so i know that the script is written correctly. There is no error reported to the console (grabbing std_out and std_err output in my cron command) and there are no php errors logged.  I am at a loss of where to look for the answers i need to find out why it's failing.  I assume it's something to do with the environment when run from cron but i've confirmed the shell is bash as expected and i'm not using any environment variables that aren't set explicitly within the script.  Where can i look for more answers?

Here's My crontab:

55 16 * * * svc_load cs-import >> /var/log/import-log-`date "+\%Y.\%b.\%d"`.log 2>&1

Here's the relevant lines to load drupal from my script.  I see all the echo's print out except the last "drupal loaded". I even tried an or die() after the bootstrap function but it didn't do anything, there must be a crash of some sort that aborts the script before php can process the die() function.

// Drupal Connectivity
echo "Start Loading Drupal\r\n";
define('DRUPAL_ROOT', dirname($parent_dir)."/httpdocs");
echo "Set Drupal Root\r\n";
require_once (DRUPAL_ROOT.'/includes/bootstrap.inc');
echo "Included Bootstrap.inc\r\n";
drupal_override_server_variables();
echo "Overrided Server Variables\r\n";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
echo "Drupal Loaded\r\n";

I have PHP logging on, here's the relevant lines from php.ini but the file size never increments when I run this script (it does on other errors).

log_errors = On
log_errors_max_len = 1024
error_log = /var/www/vhosts/dev/logs/php_errors.log

Thank you in advance for any help you can provide!
~Lindsay

I found the issue is i have multiple PHP versions installed on my system because my hosting company is running plesk. PHP 5.2 is a base version and it looks like drupal loads something that makes php5.2 fail.  After upgrading my script to point to the proper 5.5 version of php everything is running as expected.  Thanks to all who replied.


Content types disappear In some lists my content types all disappear. This especially affects Apache Solr for me. But also Views and Rules dont show the content types in some lists.

Interesting is that:

One content type is shown("Rezept") which is created by a custom module
All content types are shown correctly the moment i clear the cache.

Views:

Apache Solr Module:

The moment i clear the cache they show up correctly. But as soon as the cache clearing is finished and i reload the page, they disappear again:

Views while clearing the cache:

Apache Solr while clearing the cache:

The problem was caused by Domain Access Module. Since i didnt needed it anymore, i deactivated it.


Form element with type = value odd behaviour I have 2 forms on the site, each of them has an array, that I want to store inside the form to use in form_submit function:

$form['store'] = array(
  '#type' => 'value',
  '#value' => $fields
);

But in one form_submit function this works:

$fields = $form_state['values']['store'];
unset($form_state['values']['store']);

In another one it doesn't work, giving an error:

  Notice: Undefined index: store in scores_search_form_submit

While this code works:

$fields = $form_state["complete form"]["store"]["#value"];
unset($form_state["complete form"]["store"]);

Why does this happen?

You can use form properties:

$form['#mystore'] = $fields;

The form properties are not sent to the client, but are available in the submit hander. For example, core use $form['#node'], $form['#user'], etc.

Updated:

http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html#val

  Note that as of Drupal 6, you can also simply store arbitrary
  variables in $form['#foo'] instead, as long as '#foo' does not
  conflict with any other internal property of the Form API.

Updated 2:

Your problem may be related to this issue: http://drupal.org/node/1381830


Exposed Filters in more better way i have a view  with lot of exposed fields for searching  ... (50 +)

i am looking for some thing like this.

with  "add more " button you can add only the fields you want to search in ..
possible ?

thanks

May be this can help - Views Dependent Filter.

  Allows the presence of exposed filters on a view to be 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.


Can a database be tested to see if it is inconsistent? We all know that Drupal doesn't really support the concept of foreign keys in the database, and likely never will1.

We also know that it is possible for modules to not do the right thing, or that users will periodically do crazy things like

DELETE FROM node_revision
WHERE vid = 123

in an effort to "keep the database tidy".  When this happens, hooks don't run, and there is orphaned data in the database.  Mostly, this data is harmless, but occasionally it causes really weird behavior and can bring out bugs in code.

Are there any decent methods for detecting whether you have have dead and/or inconsistent data in your database?

1 The Drupal 7 Schema API supports them for documentation, but not enforcement.

As I was writing up a description for a sandbox project, I ran across a sandbox project for doing this:

http://drupal.org/sandbox/anton_krechetov/1345066

It currently only works for Drupal 6, and there haven't been any commits since Nov 2011, but it looks promising.


Update node with services doesn't work for text_list widget I'm setting up a REST server with Drupal 7 and Services 3.x.
Everything work fine (authentication, node creation, etc..), except that I can't update a text_list field of a node.
I've tried to use &node[title]=testnode&node[type]=story&node[field_test][0][it][value]=testtting as suggested in the Services Handbook. The node is updated (I get the system message for successfully updating), all fields are updated, except the selectlist.
Anyone facing the same problem has found a solution?

Maybe how you are updating the node i.e node_save() , The $node object that needs to be passed might not have the correct structure for the select list,

$node->body[LANGUAGE_NONE][0]['format'] = 'something';

You can always try to node_load($nid) and watchdog it to see the structure of your select field, and then verify if you are creating the $node object correctly before doing node_save().

This is just my guess, I can provide more correct answer once I can see the relevant code.

Cheers


Moving drush installed directory to production site? I am installing Open Social on Drupal 8 on my own Ubuntu Linux instance with Nginx, MySQL and PHP 7. Got the "Quick install" instructions using composer and drush completed successfully.

As a relative n00b to Drupal, there is a small gap in the documentation. You can complete an installation on a server using drush and you get a "site built" message - with everything in a directory in my user account. I'm looking at that, and looking at /var/www/html (which is where my public facing web server successfully serves traffic) and I think - eh - what now? The documentation does an exit stage left right there.

Same in the standard Drupal docs. The main clue is where you get vectored off to the procedure to create a dev site from a running production one (ie: the wrong way around). Which sort of suggests that you put the whole tree in the /var/www/html directory into an html/ subdirectory, but then hand edit settings.php to match the database credentials on your newly restored db backup.

So, to get the site running internet facing, is it as simple as moving the whole tree in my local directory under html/ to /var/www/html recursively, and then dragging a settings.php file up to the top level from ./sites/default/settings.php, then editing in the database credentials?

If I do move the website wholesale, nginx just http 500's the web site. Just working through some of the directory assumptions that composer uses... getting autoload.php failing to find a file at line 17.

The answer is that you have to copy the html/ and vendor/ directory trees from your project under var/www, and in theory it works. Except for me that it doesn't, as it just steps onto the next error where the stylesheet doesn't load properly (error in MIME types)... but that's the next story!


Cannot update core with composer after switching to core-recommended I tried to update core from 8.9.0 to 8.9.1 with composer require drupal/core-recommended:8.9.1 but I get the following error:
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Can only install one of: drupal/core[8.9.1, 8.9.0].
- Can only install one of: drupal/core[8.9.1, 8.9.0].
- Can only install one of: drupal/core[8.9.1, 8.9.0].
- drupal/core-recommended 8.9.1 requires drupal/core 8.9.1 -> satisfiable by drupal/core[8.9.1].
- Installation request for drupal/core-recommended 8.9.1 -> satisfiable by drupal/core-recommended[8.9.1].
- Installation request for drupal/core (locked at 8.9.0) -> satisfiable by drupal/core[8.9.0].

This is pretty confusing, I thought drupal/core was replaced by drupal/recommended?

I tried again with composer require drupal/core-recommended:8.9.1 --update-with-dependencies and it started to update core. Unfortunately drupal/core-composer-scaffold was not touched so I had to update it directly with an extra composer command.
Also I noticed that both of these were updated, I hope it is right:
- Updating drupal/core (8.9.0 => 8.9.1): Downloading (100%)
- Updating drupal/core-recommended (8.9.0 => 8.9.1)


Cannot install Drupal 8 on Windows 8 XAMPP PHP 5.6 Additional uncaught exception thrown while handling exception

Cannot install D8 in latest XAMPP workstation on Win8. Can install D7 though.

I did increase max_allowed_packet = 64M

You have comments disabled in your opcache configuration. Add the following line

opcache.save_comments=1 in php.ini or if opcache has its own config file

Please consult this for more details.


Unblock an automated blocked user I used Login Security module to block users after some login failures. It works fine however I need to unblock such users after certain time like after 1 hour/day. How would I do that as it has configurations to delete attempt from database but user isn't unblocked and it has to be active manually.

Please see below attached screen shot of module configuration.

I just developed a small module named as Auto Unblock Users to unblock users.

This will only work if the user is blocked by Login Security module.


Migrate dashboard goes to content dashboard I am clicking on "configure" under Modules > Migrate UI and it is just taking me to admin/content. According to the migrate_d2d module page, the migrate module should have a dashboard.

  Enabling the migrate_d2d_ui module will add an "Import from Drupal"
  subtab to the Migrate dashboard

I made sure to give the admin user permissions to use the module and I cleared the caches.

I am using Drupal 7.50 on the site I am migrating data from and 7.54 on the new site.

I am not sure why it happened but I was able to resolve this issue by uninstalling and then reinstalling migrate module.


How to display registration form fields based on the taxonomy term? I have three taxonomy terms. And I want to display different fields in the registration form based on the taxonomy term.

I want something like this.

taxonomy term 1:
Registration form fields: Name, Email, Password, City, phone

taxonomy term 2:
Registration form fields: Name, Email, Password, Country

taxonomy term 3:
Registration form fields: Name, Email, Password, State, phone

Is it possible? if yes then please guide me.

On Drupal 7 you've a new API named State API. You can use it to hide or show your fields.


Roles Machine name instead of role id I have custom module code that check the user role and based on user role, user fields updated,

for example

if(array_key_exists(12,$user->roles)) {
    //Manger
    $role =  array(8=>8);
} elseif (array_key_exists(13,$user->roles) ) {
    // super Manger
    $role =  array(14=>14);
} elseif (array_key_exists(11,$user->roles)) {
    //section manager
    $role =  array(14=>14,8=>8);
}

so when I want to move this module to other site and import roles using feature, the ids will changed.

so how can I use machine name for roles instead of ids.

Regard,

just make sure when you move your roles that you spell them the same!
then you can use the traditional

// Load the currently logged in user.
global $user;

// Check if the user has the 'editor' role.
if (in_array('editor', $user->roles)) {
  // do fancy stuff
}

or the more flamboyant

function user_has_role($roles) {
    //checks if user has role/roles
    return !!count(array_intersect(is_array($roles)? $roles : array($roles), array_values($GLOBALS['user']->roles)));
};

if (user_has_role(array('moderator', 'administrator'))) {
  // $user is admin or moderator
}

see here for more answers to the simple question Check if a user has a role


How can I migrate user profile content? I am using user_save() to migrate users from another application into Drupal, but my profile fields are not updating.

Does anyone have any suggestions as why this isn't working, or how I can get it to

        $newUser = array(
          'name' => $row->user_name,
          'pass' => $row->user_password, // note: do not md5 the password
          'mail' => $row->user_email,
          'status' => 1,

          'profile_title'=>$row->user_title,
          'profile_firstname'=>$row->user_first_name,
          'profile_lastname'=>$row->user_last_name,
          'profile_jobtitle'=>$row->user_job_title,
          'profile_orgname'=>$row->user_organization,
          'profile_telno'=>$row->user_contact_no,
          'profile_faxno'=>$row->user_fax_no,
          'profile_streetaddress'=>$row->user_address1.$row->user_address2,
          //'profile_address2'=>sanjay,
          'profile_city'=>$row->user_city,
          //'profile_state'=>sanjay,
          'profile_postalcode'=>$row->user_postal_code,
          'profile_country'=>$row->iso,
          //'profile_stateprovince'=>$row->sanjay,
          //'old_user_id'=> $row->user_id,
          'init' =>$row->user_initial,
        );
        user_save(null,$newUser);

I think User import module can help you with that


Views: no results text not showing when contextual filter is set & no results returned I have the following setup:

Block view
Contextual filter: Author UID -> Provide default value -> User ID from logged in user.
Fields: various
Filters: various
No results behaviour: text

I want the user to see a list of nodes that they have created. If no nodes are found, I want the No results text to show. Currently, it's all working fine if nodes are found. However, if no results are found, the entire view is hidden. Is this standard behaviour? How do I make it display the No results text?

I just had a similar issue, I had a block view showing the current category:

Block view
Contextual Filter - Taxonomy term: Term ID - Provide default value (term id from url)
fields
filters
No results - Global text field

Like you, because the contextual filter was set to provide default value I never saw the no results text.

SOLUTION

Edit the contextual filter and scroll down to the bottom, under

  "When the filter value IS available or a default is provided"

Check Specify validation criteria.
Leave validator as default.
Change "Action to take if filter value does not validate" to "display contents of No result found".

Bingo, on the Overview page with no term passed I get the no results found text, and when I go to a category page it picks up the term and displays the correct content.


Multiple Instances of Entity Form I am working on a module with a form that allows multiple "members" to be submitted. The form allows the number of members to be specified, then displays a set of member fields that many times. This is working well, but the set of fields for each member is fixed.

I'm looking at whether it would be possible to turn it into an entity form to allow the set of fields for each member to be configured.

Is it possible for an entity form to display several sets of fields on one form, and have them all submitted together?

Any pointers on how to start?

Here is what I would do:

Create that many entites as you would like to able to submit with entityTypeManager (members)

Create their form objects with EntityFormBuilder->getForm($entity)

Set out all the elements you don't need (their submit buttons)

Add them to form like this:
$form[$custom_form_id] = array(
'#type' => 'markup',
'#markup' => render($created_form),
'#prefix' => '',
'#suffix' => ''
);

In your submit, call the children form submit functions.


integration Webform and registration module I want integrate Webfoem and registration user module.so , When a user fill a webform, some fields in that webform put in user table , and he/she insert in user list in my site.
and I should active it our delete from users.

I have multiple Webform for registrations, and I want for each form change user role.

There are two contributed modules that may provide what is needed (quotes included are from their project pages):

Webform register:

  ... adds a Webform component that collects user registration details and creates a new account. This is useful when you only want authenticated users to submit webforms, but you do not want to create an extra hurdle for people before they fill out your webform.

  Webform Register can help you keep the flexibility of Webform, while reducing duplicate entry for your visitors. Because the user registration page can be extended through Drupal's built-in user profile fields or with the help of Content Profile, the Webform Registration can help you collect user-specific, oft-repeated information such as Name, Address and Organization information and store it in a profile entry for each visitor. Meanwhile, information that's only pertinent to the individual webform, such as survey data or preferences for a single event, are collected by standard Webform behavior.

Webform Registration:

  ... born from the need to allow visitors that came to the site to fill out a sweepstakes from which needed to not only submit values to Eloqua, using the eloqua module, but also create a new user.

  At the time the Webform register module did not provide enough flexibility for what we needed to do. Which was have many different field names (used for eloqua mapping) and still keep track of which ones held the values for email, username and password.

  How is this module different from Webform register:

  Maximum webform integration and flexibility
  You can add and fully customize every field that will be used for registration.
  If you are in a hurry, just add en email field and this module will handle the rest via a very user friendly and intuitive interface.
  Only the email field (webform component) is required, all the other components can be either generated by this module or omitted depending on your needs.
  Optionally you can specify all the labels and descriptions for all five fields (components): email, username, password, password confirmation and email confirmation


Filter View on Partial Term Name Across All Vocabs Hello im sure i used to be able to do this with D6 and Views 2. Struggling to achieve it now.

I was wanting to create a content view that is filtered on partial matches of a term name across ALL my vocabs. Say i filtered on 'science' then the view will show content tagged 'science videos' from my Video Vocab and also, for example 'science chat' from my 'tags' Vocab.

Using D7 and Views 3 i dont seem to have the option to filter on name only ID and ID is limited to one vocab.

Does anyone know if i am missing something here?

Thanks

sorted. Add relationship Taxonomy term: Name in a TERM view and viola


Query with join doesn't work I have custom tables and want to execute this query.

select displayname from foolzz_users_profile
join foolzz_user_has_user on (fk_user1=1 or fk_user2=1)
where fk_users_uid != 1;

The "1" numbers will be replaced with the users uid.
This is my query in the module.

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$uid = $user->get('uid')->value;

$query = \Drupal::database()->select('foolzz_users_profile', 'e');
$query->fields('e', array('fk_users_uid,displayname'));
$query->join('foolzz_user_has_user','d','d.fk_user1=:uid OR d.fk_user2=:uid',array(':uid' => $uid));
$query->condition('e.fk_users_uid', $uid, '<>');

$friendlist = $query->execute()->fetchAssoc();

I'm searching for hours and still couldn't get it to work.

A couple of things...firstly

$query->condition('data.fk_users_uid', !$uid);

!$uid returns false when used on a positive non-zero integer in PHP (and true for zero, the anonymous user).

You probably meant:

$query->condition('data.fk_users_uid', $uid, '<>');

Secondly, you're using the same alias for both tables. That'll never work. Change the one in the join to data2 or something:

$query->join('foolzz_user_has_user', 'data2', 'data2.fk_user1=:uid OR data2.fk_user2=:uid', array(':uid' => $uid));


Grouped exposed filters just don't work on tags So I created a nice gallery view and I wanted to add an exposed filter on tags so that my users could filter the content in it.

I created the proper tags ("photo" and "video" for example), created my tags filter using the "autocomplete" setting, checked the "Expose this filter" combobox and checked the "Grouped filters" radio.

Then, I added my two corresponding rows, giving them the respective values "is one of" => "photo" and "is one of" => "video", and left the default row to "Any". I have two nodes containing the tags "photo" for one, and "video" for the other.

Yet when I save everything and go to my gallery view, not only do I not get anything displayed even on the "any" filter, I get this error message:

Unable to find term: all

When I try to use my filters I don't get anymore things, but these messages:

Unable to find term: 1

Unable to find term: 2

These numbers are written in the "?field_tags_tid=" of my URL when I click my exposed filter buttons, but they are not even the corresponding tids of my two tags: "photo" is 11 and "video" is 12...

Even weirder: when on the admin side I change settings of my tags filter to "Dropdown" instead of "Autocomplete", this time I DO get the correct content displayed on my view for the "any" filter, but still nothing for the "Photos" and "Videos" filter, which still point to "?field_tags_tid=1" and "?field_tags_tid=2". But this time, no errors displayed.

Sadly, I cannot even try to put the right tid in my URL. I get the following error:

An illegal choice has been detected. Please contact the site administrator.

Is this drupal thing completely broken or am I just terribly unlucky?

Delete all your existing filters. I think you have misunderstood how they work.

Then add a single filter on the term reference field (field_tags?), expose to visitors, reduce duplicates, and make sure the filter is NOT required. Do not check anything else!

Submit, save your view, and you should have an exposed filter with the options '-Any-', 'Phpto' and 'Video'.

EDIT:

After much discussion, step by step:

Go to /admin/structure/taxonomy and set up a vocabulary calling it whatever you wish (lets say 'media'). Then add terms to the vocabulary like 'Photo', 'Video' etc. If you have already done this, skip to step 2.
In your content type, go to 'Manage fields' and add a term reference field to the type (lets call it 'Media') using the media vocabulary.
Go to /admin/modules and disable Better Exposed Filters.
Edit your view and delete all the current filters in the view. Save the view.
Now add a filter on the taxonomy reference field (eg field_media). Click Add and configure fiter, on the first modal select 'Dropdown' and click 'Apply and Continue'.
On the next modal, check 'Expose this filter to visitors, to allow them to change it'. The 'Filter type' should be 'Single filter'. Make sure 'Required' is not checked. Leave the operator as 'Is one of'. The only other box you should select is 'Reduce duplicates. Now click 'Apply' and save your view.

You will now see a dropdown list with all the terms in the vocabulary you created, plus the option -Any- at the top.


List ALL Taxonomy Terms with Views I am trying to figure out how to use views to list out ALL my taxonomy terms that are grouping node titles.
Example:

Taxonomy Term 1
- Node Title 1
- Node Title 2

Taxonomy Term 2
- Node Title 3

Taxonomy Term 3
-Message: There are currently no Node titles at this time, please check back

Taxonomy Term 4
- Node Title 4
- Node Title 5

Create a 'taxonomy term' view
Add 'Taxonomy term: Content with term' as a relationship (don't make it required, otherwise unused terms won't show up)
Add two fields, 'Taxonomy term:Name'(mark this excluded from display since we will group them in the next step) and 'Content:Title'
Go to Format settings: set 'grouping field Nr.1' to 'Taxonomy term:Name'
Now you get the data you want, you can use your preferred approach to style them.


Display node in multiple context I'm using Drupal 7, and this problem have been tormenting me these past few days :

let's say I'm using the basic content type Article, with basic view mode : full and teaser.

Now I'm creating a new content type Magazine, which reference multiple Article (with the module entity reference). On Magazine full view mode, I have set that every Article will be diplayed in teaser and linked to its content.

Easy isn't it ? Everything work fine. Noted that the red block in the sidebar are the same (with contexte module), and as the title.

Now I'm creating another new content type Book, which also reference multiple Article. On Book full view mode, Article are also displayed as teaser linked to  its content.
And now we have a problem when clicking on a Article from book: the sidebar and the title is from Magazine, and what I need is to display green block and title from Book.

What I get :

What I want :

Is there a way to achieve that ? By contrib or Custom ?

P.S. An article can be referenced in Book, or in Magazine, or both, or neither of them.

You can add query string or another argument to the link of article, for example:

node/[nid]/magazine or node/[nid]?ct=magazine
node/[nid]/book or node/[nid]?ct=book

After that you need to add visibility to the Book and Magazine block that appears in sidebar.

For Book block:

node/*/book

For Magazine block:

node/*/magazine

Hope it will help.

P.S. You can add argument or query string to the link of article through template_preprocess_node function by changing $vars['node_url'].

P.P.S. Just figured out that you can only use new argument, not query string.


Reloading module's services.yml I am trying to reload the .services.yml file of a custom module without having to reinstall the module.

Is there a Drush command or another way to achieve this?
Does drush cr also clear the services.yml files information? It's really hard for me to tell.

Ok. After testing and more research "drush cr" does the job. Service.yml is reloaded after clearing the cache.


I can't show the body content with full HTML My fresh installed Drupal 8 site can't display articles that use full HTML.

Is that normal?

Using the Full HTML input format, it appears like this.

I have to change the input format to Basic HTML, to make the body appear.

Is my installation complete?

Notes

I also tried pasting a different paragraph from a different website to see what happened, but the body content did not display.
I'm currently using Drupal core 8.1.3. What does missing filter mean? I found this in the information of text format.

  Full HTML: Missing filter. All text is removed.

The error message you see (Full HTML: Missing filter. All text is removed.) means that one of the filters you selected on admin/config/content/formats/manage/full_html is missing; this usually happens when you uninstall the module implementing it. As explained in Missing filters result in Exception when the format is used, in those cases, Drupal doesn't show the text using the input format containing the missing filter.

That is not a problem. Just go to admin/config/content/formats/manage/full_html and save; the reference to the missing filter will be removed, and you will be able to see the body text again. In fact, the form builder for the input format form contains the following code. (See FilterFormatFormBase::form().)

  // Create filter plugin instances for all available filters, including both
  // enabled/configured ones as well as new and not yet unconfigured ones.
  $filters = $format->filters();
  foreach ($filters as $filter_id => $filter) {
    // When a filter is missing, it is replaced by the null filter. Remove it
    // here, so that saving the form will remove the missing filter.
    if ($filter instanceof FilterNull) {
      drupal_set_message($this->t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => $filter_id)), 'warning');
      $filters->removeInstanceID($filter_id);
    }
  }

The message clearly says The filter is missing, and will be removed once this format is saved. So, saving should fix the issue.
If this doesn't work, remove another filter from the input format, save, re-add the same filter you removed, and save again. At least, this should clear the eventual cache Drupal uses for filters or input formats.


Install new site from existing config plus data migration I need to install a new site on drupal 8 from existing config plus data like content, users.

I used config installer to install a new site from existing config.

How to make it import content after complete configuration import.

New ideas and other solutions are welcomed.

After doing some research I found multipurpose corporate profile a distribution which does the job and accelerates the development process.

It deserves discovering its key features.


Show node field as a carousel using jCarousel module programmatically? I have a content type with a fiel called: fotos-carousel (image type) which I want to show as a carousel. I can't use views to do this.

I installed the jcarousel module and read the documentation to add a carousel programmatically.

Then I create a tpl file to change the output of this field: field--field-fotos-carousel.tpl.php

and add this code:

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php foreach ($items as $delta => $item) : ?>
  <?php
    $items_carousel[]='';
  ?>
<?php endforeach; ?>
<?php
            $options = array ('visible' => 1,'scroll' => 1,);
            print theme('jcarousel', array('items' => $items_carousel, 'options' => $options));
            jcarousel_add('.jcarousel-id-1', array('vertical' => TRUE));
        ?>

The output (ul, li, images) is fine but the carousel is not loaded (jquery)

Anyone has done this before? What am I missing?

Have you try with this module: http://drupal.org/project/field_slideshow It will help you to build a carousel with the content of a field.

As field slideshow is not the best options, because you need field collection.

Another option is this other.

Use a normal image field.
Build a block view with the images from the node.
With Display suit, you can choose what fields you can show or hidden, you can hidden the imagefield. And also use Display Suit (admin/structure/ds/fields) to become the views block as a field for the content type.

The last step is to enable the new field.