2009-01-28 21:01:10

nabrown78
Moderator
thêta
Real name: Nora Brown
From: Boston, MA, USA
Known languages: A little Italian. Un poco!
Website

Link list with parent/subcategories

I have a parent category “Resources” which has some subcategories like “Donation” and “Recycling”.

I am trying to output a list of the Resources links with this:

<txp:linklist category="Resources" sort="category" form="Links" limit="999" />

But it returns nothing, because the links are in the subcategories. But logically, it should output the links, because if they are in a subcategory of Resources, then they are also in the category Resources, right?

Do you agree this should be the behavior? Would it be difficult to hack it to make it happen?

I’d like my client to be able to add subcategories and links within them, and have them show up automatically in the list.

Thanks for any ideas.

Offline

 

2009-01-28 21:17:02

jakob
Moderator
omega
From: Germany
Known languages: en, de
Website

Re: Link list with parent/subcategories

I think in the past I always used mem_glinklist to achieve this, though in the meantime there’s probably a way of doing it without a plugin (perhaps using if_different?).


TXP Builders – finely-crafted code, design and txp

Offline

 

2009-01-28 23:05:49

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: Link list with parent/subcategories

I think this will work:

<txp:category_list type="link" parent="resources" exclude="resources" sort="title" wraptag="ul" break="li">
	<txp:category title="1" />
	<txp:linklist category='<txp:category />' wraptag="ul" break="li">
		<txp:linkdesctitle /><!-- or whatever you have in your link form -->
	</txp:linklist>
</txp:category_list>

Note: Don’t use capitals in category (or section) names!


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

 

2009-01-28 23:17:55

nabrown78
Moderator
thêta
Real name: Nora Brown
From: Boston, MA, USA
Known languages: A little Italian. Un poco!
Website

Re: Link list with parent/subcategories

Oh, brilliant. Yes I think that’s going to work.

Yeah – what is up with the lowercase/uppercase thing? I could have sworn that Category names were automatically changed to lowercase (while capitalization was retained in the Titles) but that doesn’t seem o be the case in 4.0.7.

Does this cause problems in urls? Are there other issues? If it causes problems, shouldn’t they automatically be string-to-lowered?

Els thanks for your category_list!

Offline

 

2009-01-28 23:22:51

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: Link list with parent/subcategories

This was changed in 4.0.8: names of newly created sections and categories are now converted to lowercase.


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

 

2009-02-26 23:48:05

masa
Member
rho
Real name: Martin Sammtleben
From: Reykjavik, Iceland
Known languages: is, en, de

Re: Link list with parent/subcategories

Thanks Els,

this was exactly what I was looking for – very clever use of the new Textpattern features!
You are smart :-)

Offline

 

2012-06-20 23:20:47

pompilos
Member
zêta
Real name: Jose
From: Spain
Website

Re: Link list with parent/subcategories

Hi, Els.

I want to do exactly the same that nabrown78 wanted. I’m using the code you pasted below, but it doesn’t work for me. I obtain a bullet list of subcategories of links, but no link at all.

Perhaps the problem is that your proposal is very old, and some things have changed in the way TXP works. I’ m using TXP 4.4.1. Do you have some idea to fix it? Thanks in advance.

Last edited by pompilos (2012-06-20 23:21:34)

Offline

 

2012-06-21 20:02:45

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: Link list with parent/subcategories

Hi José, I don’t see why that code would not work in 4.4.1. What it does is produce a list of links that are in subcategories of (in the example) category ‘resources’. I assume you checked that such links exist?
Can you post a tag trace please?


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

 

2012-06-24 01:01:07

pompilos
Member
zêta
Real name: Jose
From: Spain
Website

Re: Link list with parent/subcategories

Hi, Els.

Here is what I obtain with a tag trace using the code you posted (and yes, the links of these subcategories exist):

<p><p class="category_list">
	Subcategory 1
	<txp:linklist category='subcategory-1‘ wraptag=“ul” break=“li” form=“Links” /&gt;<br />
<br />
	Subcategory 2
	<txp:linklist category='subcategory-2‘ wraptag=“ul” break=“li” form=“Links” /&gt;<br />
</p></p>

Is perhaps a problem with quotation marks? And what is creating these typographic quotation marks?

Last edited by pompilos (2012-06-24 15:57:02)

Offline

 

2012-06-24 14:28:25

Els
Admin
omega
Real name: Els Lepelaars
From: The Netherlands
Known languages: nl, en, (some: de, fr, es, it)
Website

Re: Link list with parent/subcategories

Ah, do you have this code inside an article? It looks like Textile is in the way. If so, disable Textile for that article, or wrap it in <notextile>...</notextile>, or start the lines of code with a space, or use notextile. (or notextile.. for an extended block with blank lines).


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

 

Powered by FluxBB