Views Accordion - Opening a specific row with a link

Goal: create link that goes to a new page and opens a specific accordion drawer.

Using the Views Accordion module in combination with a little custom code accomplished this. Here's a step by step guide.

Create your view

-add this header with input filter "php code":

$view = views_get_current_view();
$nid_arg = $view-> args[0];

-add a 'Global NULL' argument to the view.

-add the field 'Node: NID'. Rewrite the output of this field to be:

If using views 3, I'd recommend setting all html wrapper, label, and html element settings to 'none'.

Add jQuery code to custom js script

-this can really be added anywhere as long as it's loaded on the view page

//open views accordion drawer based on GET argument
if ( $('#nid-argument') != ''){
vacc_nid = $('#nid-argument').html();
$('html, body').animate({ scrollTop: $('#accordion-nid-'+vacc_nid).parent().siblings('.accordion-header').offset().top }, 500);


finally, add this css to hide the helper elements:

nid-argument, .accordion-nid {

display: none;

Now when you navigate to the URL my-view-path/[nid], it will open the accordion drawer with [nid].

It's messy, but it works, and it's not very resource intensive.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.