Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-01-21 12:26:25

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

if category number attribute

Although I would not need it, I am wondering if the number attribute present in the if_article_category would also be of use for the if_category tag.

At the moment we can detect the presence of category2 by using txp:variable either by targeting it directly or the <txp:page_url type="3" />. The problem with the second is that sometimes, in some schemas, type="3" might not necessarily correspond to the 2nd category.

Since we already have the number attribute for individual_articles, would it be very hard to implement for article_lists?

example

<txp:if_category number="2">

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2020-01-21 22:37:15

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

Re: if category number attribute

I don’t see how this attribute is expected to work in permlink modes other than section/category? And even the latter does not provide section/cat1/cat2/ URL, unless you construct it manually.

Offline

#3 2020-01-22 08:06:27

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: if category number attribute

etc wrote #321251:

I don’t see how this attribute is expected to work in permlink modes other than section/category? And even the latter does not provide section/cat1/cat2/ URL, unless you construct it manually.

Hi Oleg,

I may be wrong but I see it working in a similar way to the if_article_category number="1" method. Even when using messy schemas, situations may arise where some conditional will be needed in order to parse particular content.

Here is an example where

  • cat1 = computers
  • cat2 = laptop/desktop/tablets/whatever
<txp:if_category number="1">
	<txp:if_category number="2">
		<p>desktop computers</p>
	<txp:else />
		<p>computers</p>
	</txp:if_category>
</txp:if_category>

Edited to correct the logic

Last edited by colak (2020-01-22 08:17:18)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2020-01-22 10:24:19

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

Re: if category number attribute

Hi Yiannis,

I mean Category1/2 are just custom fields, there is no such notions outside the individual article context. And there is no indication in URL (save section/category mode) what should be considered as Category1/2. We currently have only one category parameter c recognized by txp.

Offline

#5 2020-01-22 16:14:39

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: if category number attribute

etc wrote #321257:

Hi Yiannis,

I mean Category1/2 are just custom fields, there is no such notions outside the individual article context. And there is no indication in URL (save section/category mode) what should be considered as Category1/2. We currently have only one category parameter c recognized by txp.

Hi Oleg, I do not want to push the idea but to understand the issues surrounding it. Is my interpretation of your response correct?

The txp:if_category tag checks if articles are in either cat1 or 2 and works perfectly to filter article lists. What you are saying is that the CFs of categories are not sufficiently separated in the txp codebase, with c checking both of those fields.

ps. Thankfully we also have the undocumented CFs should the need arise:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2020-01-22 16:58:06

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

Re: if category number attribute

colak wrote #321270:

The txp:if_category tag checks if articles are in either cat1 or 2 and works perfectly to filter article lists.

You probably mean <txp:if_article_category />? <txp:if_category /> has nothing to do with article Category1/2, it only checks if we are on some category landing page or inside a category list, optionally testing its name/parents. Moreover, its type attribute is not necessary article, it can be set to image etc where Category1/2 have no sense.

Offline

#7 2020-01-22 17:28:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: if category number attribute

I actually meant txp:if_category. But your explanation is now clear. Although I was aware of the type attribute, admittedly I did not think of it as I only used it once and forgot about it as it works just fine;). I can now understand the complexities of the feature request.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB