custom markup for ToC items?
luco - July 29, 2009 - 19:35
| Project: | Table of Contents |
| Version: | 6.x-3.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
hey there,
I'd like to know if I can use custom markup for ToC items. the use case is for views which return tables (more than one per page). I'd need the tables' captios to work as ToC items.
clicking on a certain item would take me to where the corresponding table is on the page. therefore, I wouldn't need ToC to look for H1, H2, H3 etc. but rather any or even CSS classes/IDs.
can do?
cheers,
Luciano

#1
Well... TOC searches for H1 to H6 to generate the links.
Instead, you can add a header (i.e. H2) to your table titles (it is easy with the Rewrite feature).
Then it will add the TOC from that.
This is assuming you are using the insert_view module and that the filter for the TOC is after the insert_view.
Thank you.
Alexis Wilke
#2
thanks for the reply!
actually, I can't. I'm using tables as a style plugin and taxonomy terms as grouping fields. it automatically causes them (taxonomy terms) to be rendered as table captions and there's no rewrite for that. I could rewrite the _fields_, which go as table cells, but there's plenty of them for each table - and a single caption ;]
plus AFAIK you can't (or shouldn't) place block-level elements inside each other - both
<caption>and<h1>through<h6>are block-level.therefore your approach, even if possible, would create incorrect markup.
I'm sure you put a quite the lot of time in this module and I don't mean to cause you trouble. I'm just reporting a use case you might not have considered for a more complex situation. I'd be happy to patch the module if I spoke fluent PHP ;]
anyway, for the time being we'll just have to do without; but I hope you reconsider my suggestion in a future release.
cheers,
Luciano
#3
Luciano,
Could you give me a link to your site?
Thank you.
Alexis Wilke
#4
not yet, unless I wanna get fired: there's a whole lot of non-disclosure around the project. ;]
once it's released, I'll be glad to show you.
a coworker edited the corresponding views TPL. now it outputs H3 inside table captions. he thinks I'm being too uptight about my XHTML. lol
#5
I was just thinking that when I write a technical document for software projects, I often have tables and images (figures). And I like to have TOCs for those.
Is that would you are after? i.e. one TOC for the H1 to H6 entries, one TOC for tables (using captions) and one TOC for figures (using titles or the <caption> tag?)
Thank you.
Alexis
#6
actually there's a broader solution in modules like Cufón or Dynamic Rendering.
these replace common titles with flash and/or javascript for special fonts in your website.
in order for that to work, you tell the module: "I want H1.title, caption and #main .content h3 to be replaced with special fonts".
it's really not much more complicated than that.
you can install Cufón or Dynamic Rendering and check out its admin page, I think it's a great solution.
in this way, a ToC user could have exactly the titles he/she wants in the index. could be anything - table captions, images, subtitles, you name it. what do you think? feasible?
#7
luco,
For the TOC to work, we need a name reference (<a name="some name">). That is used so the link in the TOC sends you to the item you choose.
I think that there are limits to what we can do because of that.
For instance, if I create a figure and I want the TOC to send me to the figure, I don't want to be send below where the caption is, but at the top of the figure. These are things to consider because I probably want the caption in the TOC...
Now, I'm not too sure about Cufón and DR, they look interesting, but that's a quite different type of module.
One day, I think I will add support for classes. That way you could say: "TOC all 'figure' classes." I don't see the point of supporting identifiers since each identifier is to be unique so you'd have to specify all of them in the TOC!? Why not add a class to all of those items?!
Thank you.
Alexis
#8
yes, you're right: that would create a ToC with every ID on the page listed. not nice.
but the classes idea could fly, especially if we can add levels for indexing.
eg "first-level", "second-level" and so on:
- first-level
- first-level
- second-level
- second-level
- second-level
- first-level
- first-level
as for captions, they're really the only way to group tables in views, and you can't add classes to that - unless we edit their TPL. I've checked the views interface over and over, there's no two ways about it.