Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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 providesection/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
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
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 (savesection/category
mode) what should be considered asCategory1/2
. We currently have only one category parameterc
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
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
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