Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: soo_toc table of contents generator
Hi Destry,
Did you try using the labeltag and label attributes? I also sightly amended your yields.
<section id="contents">
<hr class="startrule">
<txp:soo_toc <txp:if_yield name="levels">level='<txp:yield name="levels" />'</txp:if_yield>
<txp:if_yield name="wrap">wraptag='<txp:yield name="wrap" />'</txp:if_yield>
label="Contents"
labeltag="h2"
/>
<hr class="endrule">
</section>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: soo_toc table of contents generator
Slightly confused. Your short code yield is looking for the wrap attribute but you’re passing in wraptag. Might this work better? …
<txp::contents wrap="ol" levels="4" />
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: soo_toc table of contents generator
Bloke wrote #327854:
Slightly confused. Your short code
yieldis looking for thewrapattribute but you’re passing inwraptag. Might this work better? …
I took it that Destry used a shorthand for wraptag in his yield name.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: soo_toc table of contents generator
I’ll have to think about this one a bit. Currently, if soo_toc has a wraptag other than ul (the default) or ol, it returns a simple (i.e., non-nested) listing of all h# elements, using the wraptag and break as usual for Txp. So that’s what’s happening here.
So maybe a quick-and-dirty solution would be something like this:
<section id="contents">
<hr class="startrule">
<h2<txp:if_article_id id="3"> class="nosync"</txp:if_article_id>>Contents</h2>
<txp:if_yield name="wrap"><txp:yield name="wrap" />
<txp:soo_toc level='<txp:if_yield name="levels"><txp:yield name="levels" /></txp:if_yield>' wraptag="ol" />
<txp:else />
<txp:soo_toc level='<txp:if_yield name="levels"><txp:yield name="levels" /></txp:if_yield>' />
</txp:if_yield>
<hr class="endrule">
</section>
assuming that ol is always the wraptag you want in this case. Not pretty, but perhaps it will work?
Code is topiary
Offline
Re: soo_toc table of contents generator
A lot of people at the in-laws, apparently. ;)
colak wrote #327855:
I took it that Destry used a shorthand for wraptag in his yield name.
Correct. I was just naming the yield tag, but using the plugin’s wraptag attribute and passing in a value of ol.
But, Colak’s code works!
I don’t know why, but using the plugin’s label and labeltag attributes instead of straight markup made the problem go away.
(I also changed the h2 to h1 to be consistent with similar section headers (back matter sections), and that allowed me to remove three ugly CSS lines. But that’s a different thing.)
Thanks, gents. Back to your nog.
Last edited by Destry (2020-12-25 17:15:23)
Offline
Re: soo_toc table of contents generator
Bloke wrote #327854:
Might this work better? …
<txp::contents wrap="ol" levels="4" />...
Actually, you might be right. I thought I knew what I was doing, but it was still throwing a wrench. I just made it all consistent wraptag now through the naming and it seems okay.
Offline