Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2024-01-11 13:05:45

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#26 2024-01-11 13:19:06

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

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

#27 2024-01-11 13:22:31

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#28 2024-01-11 13:23:13

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

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

#29 2024-01-11 13:26:09

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

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

#30 2024-01-11 13:26:37

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Making nested lists

etc wrote #336358:

That’s what you could try instead

Bingo. Thank you.

Offline

#31 2024-01-11 13:42:29

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#32 2024-01-11 14:29:28

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Making nested lists

That works, and I’ll take your word for it. Thank you.

Offline

#33 2024-01-11 16:22:32

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#34 2024-01-11 16:43:12

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

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

#35 2024-01-11 17:23:30

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#36 2024-01-11 18:02:02

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

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

Board footer

Powered by FluxBB