Using Contents tag to pull titles from another page

Post

Posted
Rating:
#4988 (In Topic #1115)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured 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).
Online now: No Back to the top

Post

Posted
Rating:
#5000
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
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.


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

Was I helpful?
  • 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.
Online now: No Back to the top

Post

Posted
Rating:
#5072
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured 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. :(

Online now: No Back to the top

Post

Posted
Rating:
#5098
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
There are some JavaScript solutions for generating tables of contents. E.g. Tocbot


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

Was I helpful?
  • 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.
Online now: No Back to the top

Post

Posted
Rating:
#5108
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Thanks Chris, I'll check that out for sure! :thumbs: ;)
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,827 members
  • Our newest member is LowfareMart
Back to Top