Drupal 7 – Display Suite Extra switch view mode doesn’t take content id from URL for contextual filter

With Display Suite Extra, we can turn on the View mode switcher which allows site visitor to view different view mode of a content type ajaxly.
display-suite-extras-contextual-nid-filter-1
 

Now i got 2 views blocks with nid being set as contextual filter. I have added the 2 blocks on 2 different view modes and I expect the blocks will only show the content of the current node. But when the other view mode is loaded thru Ajax, it the the contextual filter doesn’t work.

One workaround is to get the nid from the url and set it as the default input of the contextual nid filter.

// Get the nid from the ajax call request
if (isset($_GET["id"])) {
  return $_GET["id"];
}
return null;

 

display-suite-extras-contextual-nid-filter-2
 

Done =)

Reference: Switch View Modes not working with views looking for NID from url

Advertisement

2 thoughts on “Drupal 7 – Display Suite Extra switch view mode doesn’t take content id from URL for contextual filter”

    1. I think it’s possible. In the PHP contextual filter code, you could load the the node content base on the nid and return the the term id if it exists.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.