Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-12-29 16:22:05

flea
New Member
From: BW, Germany
Registered: 2010-12-29
Posts: 3

Displaying the categories-paragraph only when categories are present

Hi,

i’m new to Textpattern and loving it so far :)

But there’s one little thing I find quite irritating: The categories-paragraph at the bottom of an article is always displayed, even when no categories are present. Furthermore, the comma – which seperates the first category from the second – gets displayed regardless of whether there are actually two categories to seperate.
It looks like this: <p class=“tags”>, </p>

I came up with a solution, but am not sure, whether it is syntactically correct.
The following code replaces the corresponding code in the default form.

<txp:if_article_category>
<p class=“tags”><txp:category1 title=“1” link=“1” />
<txp:if_article_category number=“2”>
, <txp:category2 title=“1” link=“1” />
</txp:if_article_category>
</p>
</txp:if_article_category>

If this is, in fact, correct and there isn’t a similar function in Tetxpattern already, I propose to include this change into the core.

Greetings

Offline

#2 2010-12-29 17:33:29

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

Re: Displaying the categories-paragraph only when categories are present

flea wrote:

If this is, in fact, correct

Yes it’s correct. I would add number="1" to the first if_article_category tag.

and there isn’t a similar function in Tetxpattern already, I propose to include this change into the core.

Everyone makes changes to the default article form, it’s hardly realistic to add all possible options to it. Anyway, as a new user you found out how to do it pretty quickly, so where’s the need? ;)

Offline

#3 2010-12-29 18:01:38

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Displaying the categories-paragraph only when categories are present

Els wrote:

where’s the need? ;)

I’m quite chaotic, and I tend to not always allocate my categories top to bottom when I in fact probably should. But some article whose cat2 is set but which hasn’t a cat1 set would not be covered.

flea, TXP is slim, minimalistic and written to be as flexible as possible, and thus tends to rely on plugins. There’s one for multi condition testing, though I admit it’s quite a big gun if you’re aiming solely for a comma. But your proposal feels quite similar ;) (like Els already said).

Last edited by uli (2010-12-29 18:09:00)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2010-12-29 20:13:24

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

Re: Displaying the categories-paragraph only when categories are present

uli wrote:

But some article whose cat2 is set but which hasn’t a cat1 set would not be covered.

I’m sure there is a way to cover that using variable and if_variable ;)

Offline

#5 2010-12-30 10:06:28

flea
New Member
From: BW, Germany
Registered: 2010-12-29
Posts: 3

Re: Displaying the categories-paragraph only when categories are present

Everyone makes changes to the default article form, it’s hardly realistic to add all possible options to it.

Well, yeah. It’s just… in my mind, not displaying the comma is explicitly better than showing it. They are not two options, where one user might like it better this way and another one likes it better the other way.

Anyway, as a new user you found out how to do it pretty quickly, so where’s the need? ;)

The need is not to bother new users with this little thing. I like twiddling around with the code, just because I can – but it seems wasteful to force every user to do it for every little glitch. Again, this all under my assumption, that not displaying the comma is explicitly better.

I’m quite chaotic, and I tend to not always allocate my categories top to bottom when I in fact probably should. But some article whose cat2 is set but which hasn’t a cat1 set would not be covered.

Ok, but that would just raise the need for a more elaborate code. Unless it relies on plugins – that would, in fact, be a big gun.

Offline

#6 2010-12-30 10:35:46

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

Re: Displaying the categories-paragraph only when categories are present

uli wrote:

But some article whose cat2 is set but which hasn’t a cat1 set would not be covered.

Checks if both categories are set:

<txp:if_article_category number="1">
	<!--
		Mr. 1 is here
	-->
	<txp:if_article_category numer="2">
		<!--
			Mr. 2 greets Mr. 1
		-->
		This is a comma:
		<span class="superLargeComma">,</span>
	</txp:if_article_category>
</txp:if_article_category>

Offline

#7 2010-12-30 11:27:46

flea
New Member
From: BW, Germany
Registered: 2010-12-29
Posts: 3

Re: Displaying the categories-paragraph only when categories are present

Gocom wrote:

<span class=“superLargeComma”>,</span>

Hell Yeah! :D

Offline

Board footer

Powered by FluxBB