Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Making nested lists
I think it’s type
, not value
. You should also remove if_description
here, in favour of wraptag="p"
. Or pass it type
too, but this would be a waist of cycles.
And even this will not work, looking at the code.
Offline
Re: Making nested lists
I adjusted to this:
<link::category title="1" wraptag="h2" />
<p><txp:meta_description format="" type="category" /></p>
<dl><+></dl>
That did make the section description go away, but there is no output for category descriptions. Same difference if using type="category.link"
, if that matters.
Am I supposed to be adding something to the variable, and passing it along? (Says the guy who knows not of what he speaks.)
Offline
Re: Making nested lists
That’s what you could try instead:
<txp:category_list categories='<link::category />' type="link">
<txp:category title="1" wraptag="h2" />
<txp:meta_description format="" wraptag="p" />
</txp:category_list>
Offline
Re: Making nested lists
To be thorough, here’s what’s in the Links page template:
<txp:variable name="good-sites">
<category::list type="link" parent="looming-future" sort="name asc" break="," trim>
<txp:category />
</category::list>
</txp:variable>
<txp:linklist category='<txp:variable name="good-sites" />' sort="category" breakby="<link::category />" breakform="linkgroup">
<dt><a href="<txp:link_url />" rel="external"><txp:link_name /></a></dt>
<dd><link::description /></dd>
</txp:linklist>
And this in the links form:
<link::category title="1" wraptag="h2" />
<p><txp:meta_description format="" type="category" /></p>
<dl><+></dl>
It all works okay except I’m not getting this output as expected for each category label above it:
<p><txp:meta_description format="" type="category" /></p>
Edit: you beat me to the punch
Last edited by Destry (2024-01-11 13:23:42)
Offline
Re: Making nested lists
I was about to say that in order to output category information you need to be in some category context (some wrapper or URL scheme that triggers it). But Oleg beat me to it too.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Making nested lists
Offline
Re: Making nested lists
Then you can probably inverse the logic and simplify it?
<category::list type="link" parent="looming-future" sort="name asc" evaluate="linklist">
<txp:category title wraptag="h2" />
<meta::description format="" wraptag="p" />
<txp:linklist category='<txp:category />' wraptag="dl">
<dt><a href="<link::url />" rel="external"><link::name /></a></dt>
<dd><link::description /></dd>
</txp:linklist>
</category::list>
Offline
Re: Making nested lists
That works, and I’ll take your word for it. Thank you.
Offline
Re: Making nested lists
This is actually what Stef wanted to avoid (per category db calls), but he did not need to retrieve category data when outputting links. You do, so it’s one db call either per category or per link either way. I guess you have less link categories than links themselves, hence the code above should be ok.
Incidentally, I’ve found <txp:category_list />
in dev misbehaves with <+>
pattern, glad you have revived this thread.
Offline
Re: Making nested lists
etc wrote #336362:
Then you can probably inverse the logic and simplify it?
<category::list type="link" parent="looming-future" sort="name asc" evaluate="linklist">...
I didn’t see it at first, but it turns out that was actually outputting strangely. For example, categories and their associated links were appearing in triplicate (i.e. the tree was repeating 3 times).
I went back to putting this in the links Form and it works as expected:
<txp:category_list categories='<link::category />' type="link">
<txp:category title="1" wraptag="h2" />
<txp:meta_description format="" wraptag="p" />
</txp:category_list>
<dl class="linkos"><+></dl>
For now I’m just kind of testing all this with three children categories under one parent, and about ten links across them. But I expect child cats count to increase 3 or 4 times and links as well. This is a select links page, so there won’t be dozens of links.
I had not tested the idea of having two parent categories, so effectively two parent/child trees outputting. in series, but maybe that’s not even worth trying.
Offline
Re: Making nested lists
Destry wrote #336365:
I didn’t see it at first, but it turns out that was actually outputting strangely. For example, categories and their associated links were appearing in triplicate (i.e. the tree was repeating 3 times).
This is the whole code, not just the links form (unneeded here). Both work for me.
Offline
Re: Making nested lists
Ok, I see now. I should have looked closer there.
I’m always feel like Tuco here when it comes to this tag-fu.
The single block method does seem to add a bunch of br
tags, messing up the spacing, and I’m not sure where those are coming from.
I’ll stick with the form approach. It makes more sense to Tuco.
Offline