Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-09-12 05:13:04

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Category tree

I have emulated section tree by hand (presentational templates will remain quite steady), but I would let authors to set new categories for his articles.

Both txp:category_list and txp:popup type="c" work fine, but do not reflect subcategory dependence upon its parent category (and txp:popup also reverts ?c="messy" URLs). The following example is wrong, although I hope it will demonstrate what I am willing to achieve:

	<dl id="c-tree">
		<txp:category_list>
			<txp:if_different>
<dt><txp:category1 title="1" link="1" /></dt>
			</txp:if_different>
<dd><txp:category2 title="1" link="1" /></dd>
		</txp:category_list>
	</dl>

Offline

#2 2009-09-12 12:18:10

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Category tree

Not sure if this is what you’re after?

<dl id="c-tree">
<txp:category_list children="0">
	<dt><txp:category title="1" link="1" /></dt>
	<txp:category_list parent='<txp:category />' exclude='<txp:category />'>
		<dd><txp:category title="1" link="1" /></dd>
	</txp:category_list>
</txp:category_list>
</dl>

Offline

#3 2009-09-12 16:17:27

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Category tree

You are TxP wizard. And my redeemer, too. Because I am not a programmer, only HTML/CSS coder. That is where Textpattern especially helps. You could post this trick on Texpattern.net, Textpattern.org, or Txptips.com — I think that is the typical solution for the most of quite complex sites. Thank you very much!

Still one small problem in the output list, can you imagine — where unexpected <br /> line breaks shoot up from?

Last edited by Vienuolis (2009-09-12 16:23:22)

Offline

#4 2009-09-12 16:33:53

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Category tree

Vienuolis wrote:

Still one small problem in the output list, can you imagine — where unexpected <br /> line breaks shoot up from?

Tag reference is your friend. Look what it says about break attribute on category_list article. Yep, the default is <br /> which can be undone by setting the value to unset (adding break="" to your <txp:category_list /> -tags).

Last edited by Gocom (2009-09-12 16:35:03)

Offline

#5 2009-09-12 16:44:30

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Category tree

Done, thanks!

Offline

#6 2009-09-12 18:48:23

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Category tree

The tree is context-sensitive: full on a front page (with consistent URLs), and section-limited elsewhere (/section/?c=“some-category”). It is OK, although there are some informational pages with no content, e.g. /index. Is it possible to avoid context-sensitivity in this form?

Offline

#7 2009-09-13 10:22:20

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Category tree

Hi Vladas, try this:

<dl id="c-tree">
<txp:category_list children="0">
	<dt><txp:category section="default" title="1" link="1" /></dt>
	<txp:category_list parent='<txp:category />' exclude='<txp:category />'>
		<dd><txp:category section="default" title="1" link="1" /></dd>
	</txp:category_list>
</txp:category_list>
</dl>

Offline

#8 2009-09-15 06:07:51

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Category tree

Oh, really, thank you!

Offline

Board footer

Powered by FluxBB