Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to add the title of the node on the left of the header which would expand like it normally does and a link on the right of the header which would link to some other content when the link is clicked (+ TITLE | LINK ). Is there a way to do this with Views Accordion?
Comments
Comment #1
GuyRus CreditAttribution: GuyRus commentedI'm after the same functionality. I've got the links in there (add all the fields you want in the header and exclude from display then rewrite the title output) but when clicked on the links don't do anything due to the header onClick overriding them.
Wondering if you came up with a solution for this?
Comment #2
michaelw_dc CreditAttribution: michaelw_dc commentedOne way to tackle this is to capture the click on the link with jQuery and set the window.location to the href of the link. I created a javascript file, "links_within_accordion_header.js" and added it in via my theme's .info file (it was just a one-page site, so it was fine having it on every page of the site).
jQuery(document).ready(function() {
jQuery(".ui-accordion a").click(function() {
window.location = jQuery(this).attr('href');
return false;
});
});
Comment #3
narkoff CreditAttribution: narkoff commented#2 worked for me. Thanks. I used the JS Injector module to limit the jQuery to certain pages.
Comment #4
anil280988 CreditAttribution: anil280988 commentedViews Nested Accordion can be use for this purpose. I creates a new view style, Views Nested Accordion, which inherits the Views Accordion style.
https://www.drupal.org/project/views_nested_accordion
Comment #5
satutama CreditAttribution: satutama commentedI tried #2 with JS injector, doesnt matter where i put it and how i put it, it just doesn't work.
And then i tried #4, and still it doesn't work.
I managed to make the link work by forcing the link in the rewrite results of the header field.
I'm using 2 fields as a header, and instead of: [field_1] [field_2]
I put [field_1][field_2]
Comment #6
urmila26 CreditAttribution: urmila26 commentedHi
i have tried by using jquery , it is working good.
but without using jquery , should i add link for accordion header in drupal 7??