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.
With the Navigation anchors, you can use the following: www.example.com/type#type-page-1
This works well; however, the problem is if you add more content that is sorted above this item, your #[content-type]-page-1 will link to a different expanded field than you intended.
I would love to see a way to use www.example.com/type#type-node-380 as another way of doing an anchor. This way it is linked to the actual node you want expanded in the view, rather than the position of the node that is to be expanded.
Thanks.
Comment | File | Size | Author |
---|---|---|---|
#17 | deep-linking-anchors-1127224-6-rel7.x-1.0.patch | 2.91 KB | Anonymous (not verified) |
#6 | deep-linking-anchors-1127224-6.patch | 2.63 KB | jantoine |
Comments
Comment #1
Manuel Garcia CreditAttribution: Manuel Garcia commentedFirst, this would be extremely complicated to implement, as views can list any entity type, and you'd have to pass this to the JS and have it do a lot of work on this. Not desireable just for that case... at least in my opinion.
The only way to do this would be to rework how the anchors are built, and do it outside of js. Also a lot of work, and we'd be entering very muddy watters, stepping into how views normaly renders itself. This means a lot of potential for bugs, and much more code to maintain, just for this case.
So I'm setting this to won't fix, this module focuses on integrating views with jquery ui accordion, let's keep it clean and fast.
Comment #2
Jej CreditAttribution: Jej commentedHi,
I agree with Ryan. This feature is quite unusable as the row id can change anytime depending on the accordion content. It should rely on a drupal indexing (ex. node id) rather than a simple row count.
J.
Comment #3
jantoine CreditAttribution: jantoine commentedI also agree that anchors are not very useful when they can change as the view is populated with more content. With everything moving towards entities, I think one approach could be to use "#type-id" of the entity as the anchor text.
Comment #4
Manuel Garcia CreditAttribution: Manuel Garcia commentedI'd be willing to consider this feature if someone comes up with a reasonable patch that addresses the concerns I mention in #1.
Comment #5
jantoine CreditAttribution: jantoine commentedI just got 8 hours to work on this project and will be tackling it Monday morning.
Comment #6
jantoine CreditAttribution: jantoine commentedThe attached patched creates a unique anchor for every result of a view in the form of "view_machine_name-view_display_name-result_entity_type-results_entity_id". It has been tested with users, nodes and terms. It has been tested with paged output, although this doesn't make sense for deep linking as the "page" URL parameter could change.
An unsupported case was found with views that do not include any fields from the base table in the query. In this case we default to the current functionality. If deep linking is enabled an error message is displayed alerting the user to the issue and how to fix it.
Comment #7
ibot CreditAttribution: ibot commentedThank you for this patch, i was about to lose some teeth about the accordion-linking
- it is working fine here!
Comment #8
GHaddon CreditAttribution: GHaddon commentedThanks, this was exactly what i needed, i would also recommend adding and id with the same value after the hash so the browser will scroll down in the same way the anchor attribute works.
We managed to get this functionality by adding a rewrite in the nid field of the view
<div id="services-page-node-[nid]">[title]</div>.
Which works in the same way but it would be nice if this was default functionality.
It would be great if this patch could be committed as future updates will now mean having to reapply the patch every time we have to update.
Comment #9
Dustin Bons CreditAttribution: Dustin Bons commentedGreat patch. Could we integrate a view setting to select a field to use as anchor?
Comment #10
kirkofalltrades CreditAttribution: kirkofalltrades commentedI just wanted to throw this out there. I've implemented patch from #6 and field rewrite from #8. Works great! However, in IE7 it fails to expand the specified header. I installed the latest version (7.x-1.0-rc2) and the latest version of Views and reapplied the patch and same result; all looks well but IE7 doesn't work properly.
Not a huge deal, I've styled it so all is expanded for IE7. Just wanting to confirm if others see this behavior and can come up with a reason why, perhaps.
Thanks,
Kirk
Comment #11
JordanMagnuson CreditAttribution: JordanMagnuson commentedGreat patch. Just applied it against 7.x-1.x-rc2.
Would be great to get this rolled into the latest release.
Comment #12
jackhutton CreditAttribution: jackhutton commentedThis turned into a hassle for me;
The views accordion leaves off the closing tag in Internet explorer 8 & 7; took me a while to figure that out ;
your post above gave me the idea to cut bait. expand them all for ie 7&8 w a custom ie style sheet.
thanks put me on the right path to get it done.
Comment #13
ippy CreditAttribution: ippy commentedHi
Thanks to everyone who contributed on this issue. We benefited from your sharing - using the patch in #6 plus GHaddon's suggestion in #8, plus a bit of jquery in the footer to make the "click".
So we added a little blog post/recipe to help anyone else faced with this problem.
It can be read here: http://netuxo.co.uk/blog/ippy-gray/linking-specific-views-accordion-rows...
Ippy
Comment #14
mastoll CreditAttribution: mastoll commentedSuperb work, @ippy and all contributors.
@ippy, where can I ask you about your theming of the Views Accordion on http://tescopoly.org/faq?
Comment #15
Manuel Garcia CreditAttribution: Manuel Garcia commentedNavigation and navigationFilter options have been removed from jquery.ui.accordion 1.10, in favour of active, which as a setter only takes a integrer as argument, to open a certain accordion row.
So this means that even if we get this working properly, it will not work with newer versions of the plugin.
I'm setting the status to Needs work to leave the door opened for someone that knows the proper way of working with the (current) plugin (if at all possible), but I doubt this will get in.... sorry!
Comment #16
seanenroute CreditAttribution: seanenroute commented@mastoll one of the best stylesheet for cleaning up the accordion page (and other jquery items) comes from the Seven administrative theme.
Check out jquery.ui.theme.css in the seven theme that comes with Drupal 7.
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch at https://drupal.org/node/1127224#comment-5919394 does not apply to release 7.x-1.0
Updated patch attached.
Comment #18
JordanMagnuson CreditAttribution: JordanMagnuson commentedHere's a post discussing linking to a specific accordion link using 'active': http://stackoverflow.com/questions/588030/link-to-open-jquery-accordion
It seems like something like that could be adopted to work with this module.
Comment #19
ippy CreditAttribution: ippy commentedFor anyone arriving here long after the last comments were made...
The patch (updated 11 months ago and posted at #comment-8848837 by Andreas) will also just about apply to the latest Views Accordion (7.x-1.1) - though its a few lines adrift it will succeed. Also, the recipe at http://netuxo.co.uk/blog/ippy-gray/linking-specific-views-accordion-rows... has been updated with a brief postscript inc a link to a live implementation
Comment #20
larynIn case it's helpful, this same issue was opened in the Backdrop version's queue, and a PR submitted which is largely based on the patch here, I understand. It's working and committed there, functioning with jQuery UI 1.12.x.
https://github.com/backdrop-contrib/views_accordion/issues/2
Comment #21
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedThanks for the heads up @laryn - its been a while since I looked at this issue, but my guess is that the concerns I raised on #15 probably still stand.
That said, I'd be willing to have another look if someone ported the patch here - Not sure if people are still interested, but could be.
Comment #22
crutch CreditAttribution: crutch commentedI worked on this issue for quite a while today and found a working solution for my case posted here.