Link to search page with advanced search fieldset expanded!

Create the link: Advanced Search

Or you could even add it to the search box with jQuery (I'm adding it to a Custom Search block here): /* jQuery to expand advanced search field is contained in js_injector rule (in db) */ $('Advanced Search').appendTo('.block-custom_search_blocks .form-item');

Then, add a jQuery script. I used JS Injector to add this only to the 'search*' pages. //wait until the rest of the jQuery has been loaded $(document).ready(function() { //break apart url to get anchor var url = document.location.toString(); if (url.match('#')) { var anchor = '#' + url.split('#')[1]; }

//click collapsed fieldset to expand if (anchor == '#advanced-search'){ $('.search-advanced legend').find('a').click(); } });

Unfortunately setting a new rule in JS Injector and using jQuery does not work. I am using JS Injector 7.x-2.0. Even something simple as alert('test'); does not work when using $(document).ready(function() { alert('hi'); });

It is too bad since JS Injector sounds promising. Maybe they will fix this in Drupal 8.

Add new comment

Plain text

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