Using Contents tag to pull titles from another page
Posted
#4988
(In Topic #1115)

Standard member

...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).
Posted

Site director

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.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted

Standard member

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.

Posted

Site director

Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Posted

Standard member



1 guest and 0 members have just viewed this.