Using Contents tag to pull titles from another page

Post

Posted
Rating:
#4674 (In Topic #945)
Joe

...and the correct syntax to use

I'm trying to list a table of contents on page A using the titles placed within page B. I believe I can do this with the contents tag, but I'm unsure of the correct syntax to use for the Files field under Advanced.

According to the field:

Composr said

A page name prefix to determine which Comcode pages to search for Comcode titles in (if blank it will just search the Comcode field the tag is placed inside). These titles will form the table of contents.

Can someone tell me what "prefix" I'm supposed to use? Entering the Comcode-page codename here doesn't seem to work. I've also tried adding .txt to the end of the codename (since the field is technically asking for a FILE here) but this doesn't do anything either.

I started guessing at what to put here, even trying to prefix the Comcode-page codename with an underscore, but again, it did not show any titles.

Also, say I'm pulling Comcode page contents as entries from a catalogue category, via main_cc_embed, I assume the contents tag isn't capable of pulling titles from those? (I haven't messed with this block yet, but it looks really interesting). If not, I was considering I could make a symbol to loop through each entries title field to populate a table of contents, but I don't think it'd be possible to allow linking to each title (as the contents tag currently does this).

Post

Posted
Rating:
#4686
You were struggling as there was a bug. I've fixed it, and tweaked the tag descriptions to make it clearer.

https://github.com/ocproducts/composr/commit/635ae3e088348ff4683780e576ec2d43a2a85151

Here's a sample usage I was just testing with:

Code

[contents zone="docs" files="tut_adv_c"][/contents]

This is essentially showing a title hierarchy from docs/pages/comcode_custom/EN/tut_adv_c*.txt.


It only works with Comcode title tags, not any raw HTML header tags. I doubt it works when doing weird things like getting content from blocks or included pages, it'll probably just ignore them.

Post

Posted
Rating:
#4750
Joe

Chris Graham said

I doubt it works when doing weird things like getting content from blocks or included pages, it'll probably just ignore them.

Unfortunately, this is the case. :(

Post

Posted
Rating:
#4768
There are some JavaScript solutions for generating tables of contents. E.g. Tocbot

Post

Posted
Rating:
#4778
Joe
Thanks Chris, I'll check that out for sure! :thumbs: ;)
3 guests and 0 members have recently viewed this.