I know there is a slim chance of being able to do this with Views 2 core, but this is something I really need to try to accomplish.
I have a somewhat long view that is a food menu for a restaurant, I need to put id tags where the taxonomy grouping occurs so that I can use my sub-menu to jump right to the 'bookmarked' id section.
The specific page view can be seen here: http://d430602.u51.quantumized.net/menu/delivery-menu | Each heading is generated by views using a grouped taxonomy term. Ideally, I'd like to auto-generate a id="term#" with the tax term so that I can create the bookmarks to jump to that section. Is this possible in any way?
I have achieved the effect with the 'dinner menu', but it uses many attachments and I had to hard-code the id tags into the headers. This works, but is ungraceful and defeats the purpose of the CMS. Long views with many attachments will be very hard to organize and maintain.
Any ideas?
Thanks~
Comments
Comment #1
merlinofchaos commentedAssuming you're using the unformatted style, override views-view-unformatted.tpl.php for your view. The $title is printed in that template (or whichever style you're using for this) -- you can re-format that into an anchor and/or link as you need. It may require a little effort to reformat the link text into something suitable to use with an href, but views_css_safe() might be a decent start. Maybe with a strtolower() as well.
Comment #2
3cwebdev commentedWorks like a charm! Thank you so much (again) for the help and tips. Views and it's template system is awesome :)
Comment #3
merlinofchaos commentedThis probably needs to make its way to the handbook on the Snippets page.
Comment #4
3cwebdev commentedJust for reference, in case anyone else is looking for a similar solution. Uses the first word of the title, converted to lowercase.
Example output:
The code I used in views-view-unformatted.tpl.php:
Comment #5
merlinofchaos commentedComment #6
merlinofchaos commentedIf it hasn't happened in a year, it probably won't happen.
Comment #7
3cwebdev commentedThis snippet has been tested and added to the Views snippet documentation: http://drupal.org/node/588804