Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
Re: Making nested lists
Destry wrote #336368:
The single block method does seem to add a bunch of
brtags, messing up the spacing, and I’m not sure where those are coming from.
Textile, perhaps?
I’ll stick with the form approach. It makes more sense to Tuco.
It’s fine, I’m just thinking out loud.
Offline
Re: Making nested lists
Textile, perhaps?
Ah, perhaps. I am using escape="textile" on the dd output because I want formatting in there.
Please keep thinking aloud. We all benefit from it. I am marveled by (and grateful for) your mastery of character magic.
Offline
Re: Making nested lists
The last piece of the puzzle for me is to have control over the order of the individual links in each list. The Sort value field in the links form doesn’t seem to be having an effect. I’ve tried numbers and letters (a, b, c, …) but the link items just keep sitting in the same position. What am I missing?
Offline
Offline
Re: Making nested lists
linksort worked. Thank you.
Offline
Re: Making nested lists
I’m adding this to the linklist block to try and output the year for the link time stamp…
<txp:evaluate query='<txp:link_date format="%Y" />'><txp:link_date wraptag="Published <+>" /></txp:evaluate>
But it outputs the day, month, and year format as set in preferences (e.g. 12 May 1992).
Incidentally, the docs say ‘any valid strftime string values’, but that seems to be deprecated now.
So I tried a value of YYYY, which seems rather common (e.g W3CDTF reference), and that still outputs the full date.
Is there a way to force just the year to output for links only?
Offline
Re: Making nested lists
It’s because your link_date tag – the one that actually outputs the published string – doesn’t have a format attribute. You don’t need that attribute in the evaluate query because it’s only testing for the existence of the tag’s content.
In fact you can probably get away with test="link_date" instead of the query:
<txp:evaluate test="link_date">
Published <link::date format="%Y" />
</txp:evaluate>
Last edited by Bloke (2024-02-14 14:36:56)
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
Online
Re: Making nested lists
Do you really need <txp:evaluate /> here?
<txp:link_date format="%Y" wraptag="Published <+>" />
Offline
Re: Making nested lists
Oleg’s is even better. Forgot we could use the UFO thing directly without it. Nice one.
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
Online