Textpattern Forum

You are not logged in. Register | Login | Help

#1 2009-01-28 21:01:10

nabrown78
Moderator
From: Boston, MA, USA
Registered: 2006-10-04
Posts: 289
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

#2 2009-01-28 21:17:02

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,960
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

#3 2009-01-28 23:05:49

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,397
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

#4 2009-01-28 23:17:55

nabrown78
Moderator
From: Boston, MA, USA
Registered: 2006-10-04
Posts: 289
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

#5 2009-01-28 23:22:51

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,397
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

#6 2009-02-26 23:48:05

masa
Member
From: Reykjavik, Iceland
Registered: 2005-11-25
Posts: 1,079

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

#7 2012-06-20 23:20:47

pompilos
Member
From: Spain
Registered: 2005-06-07
Posts: 111
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

#8 2012-06-21 20:02:45

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,397
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

#9 2012-06-24 01:01:07

pompilos
Member
From: Spain
Registered: 2005-06-07
Posts: 111
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

#10 2012-06-24 14:28:25

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,397
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

Board footer

Powered by FluxBB