Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
if_article_list inside article_custom always evaluates true
I’ve already reported this on TXP Google Code but so far, there wasn’t any official feedback about it.
I’ll copy part of my comments there, to illustrate this issue:
If_article_list inside article_custom always evaluates to true, even when on
individual_article context.
In other words, article_custom is considered a “list” context.
Try this snippet on your page template (change “a-section” value for a valid section
on your TXP install).
<txp:if_article_list>
this is a list
<txp:else />
this is an individual article
</txp:if_article_list>
<txp:article_custom section="a-section">
<txp:if_article_list>
this is a list // this always evaluates to list, even if in individual article context
<txp:else />
this is individual article // it seems that this place can never be reached
</txp:if_article_list>
</txp:article_custom>
Personally, I consider it a bug, as it doesn’t seem to fit in the “standard” TXP way
of identifying contexts.
Yes, if you are “standing” inside an <txp:article_custom />, your context may be seen
as a list, as article_custom returns list of articles.
But then, a common usage for <txp:article_custom /> is to generate list of articles for widgets that are
used on both contexts (article list or individual article). Inside those widgets you
may want to test if you are rendering it on a list or on an individual article.
Does it makes any sense?
—
I hope to put this on the radar of the many clever minds on this forum.
Thanks for reading.
Offline
#2 2009-10-31 01:35:50
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_article_list inside article_custom always evaluates true
Hi Julián,
I’ve been looking at your issue at Google Code before, and I don’t agree it’s a bug. As you said, article_custom always renders an article list, so I kind of see it as expected behaviour. If you want to check for individual article context, the conditional tag should be placed outside of the article custom tag:
<txp:if_individual_article>
<txp:article_custom>
<txp:if_article_id>
<txp:else />
<h4><txp:title /></h4>
<txp:excerpt />
</txp:if_article_id>
</txp:article_custom>
<txp:else />
<txp:article_custom>
<h4><txp:title /></h4>
<txp:excerpt />
</txp:article_custom>
</txp:if_individual_article>
Offline
Re: if_article_list inside article_custom always evaluates true
Hi Els, our Queen of Tags,
thanks for the feedback.
article_custom always renders an article list, so I kind of see it as expected behaviour.
Yes, we all agree that article_custom
always renders a list of articles, even if it’s just one article. And you affirm that, because of rendering a list of articles, it has to return true for if_article_list
.
If you follow that path of reasoning, then it should also return true for if_individual_article
, because each iteration done by article_custom
renders an individual article. Think about it: we all use article tags (title
, body
, etc) inside article_custom
(or in a form), so that place (the contained tags or form) already belongs to the “individual article” dimension. So, again, following that path of reasoning, if_individual_article
should return true.
Of course, that’s not what happens here, because only if_article_list
returns true, and I still consider it wrong. If article_custom
is true for setting an article_list context (wrong), why anyone would want to test for if_article_list
inside of it? We don’t need that “feature”.
Sorry for stressing the point. I hope you have been convinced by my prose.
Historically and semantically (it sounds pompous!), if_article_list/if_individual_article tested for the current page context. By this bug, we are losing TXP powers: there is no way —inside an article_custom
tag— to test which is the current page context (article_list vs individual_article).
If you want to check for individual article context, the conditional tag should be placed outside of the article custom tag.
Yes, it’s a workaround, but it leads lotz of extra code.
Offline
Re: if_article_list inside article_custom always evaluates true
To add some more thoughts to this.
On this issue, the behaviour of txp:article_custom
differs from the behaviour of txp:article
.
Inside the form/contained-tags called by article
, you can properly test for if_individual_article/if_article_list, as this snippet from the default form confirms:
<txp:if_individual_article>
<h1 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h1>
<txp:else />
<h3 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h3>
</txp:if_individual_article>
You may argue that article
is page context sensitive while article_custom
is page context insensitive, and that’s why if_article_list/if_individual_article behave differently inside of them. Wrong!
The article_custom
insensitivity is related to the articles it has to fetch (it fetches what it’s told to fetch on its attributes, fully ignoring the context).
But it shouldn’t be insensitive on the inside (the form/contained tags used to render those fetched articles).
Please, let me know if I explain myself.
Offline
#5 2009-10-31 16:36:10
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_article_list inside article_custom always evaluates true
maniqui wrote:
If you follow that path of reasoning, then it should also return true for
if_individual_article
, because each iteration done byarticle_custom
renders an individual article.
I don’t agree :) article_custom
never ever renders an individual article.
Inside the form/contained-tags called by
article
, you can properly test for if_individual_article/if_article_list
Yes of course, the article
tag can render lists as well as individual articles.
I hope you have been convinced by my prose.
Mmm… I’m afraid los reyes de las etiquetas are disagreeing for the very first time… ;) As I said, I have been looking at your reasoning at Google Code before, more than once, and I haven’t posted there because I don’t know if it’s the right place to start a discussion. But now that you posted here, I’m very interested to hear the opinion of others. Devs?
Offline
Re: if_article_list inside article_custom always evaluates true
I don’t agree :) article_custom never ever renders an individual article.
Hehe, ok, we have a different worldview here.
Each article returned by article_custom
is an/one individual article.
But you may also have a point, if we considered that if_first_article
and if_last_article
are used on the render-form/contained-tags to test a “property” of current iteration, (first/last article), which is related to a list of articles.
But the point is that if_article_list
losts its power of testing the page content when inside article_custom
, because it changes its behaviour: article_custom
forces if_article_list
to “believe” the context is an article_list. Testing if article_custom
is an article_list is something no one needs: we all know it’s a list of articles (list of articles != article_list page context) .
Let unleash the power of if_article_list
/@if_individual_article@ inside article_custom
! We need it!
maniqui wrote:
Inside the form/contained-tags called by article, you can properly test for if_individual_article/if_article_list
Els wrote:
Yes of course, the article tag can render lists as well as individual articles.
Consider this: when you are at an individual_article page context (to say it easier: when you are on an article’s permanent link), you can use if_individual_article
/@if_article_list@ anywhere on the page template, that is, outside the article
tag, and it behaves exactly the same as if it’s being used inside the article
tag. In both cases it tests for the current page context.
On the other hand, if_individual_article
/@if_article_list@ behave differently when used inside article_custom
, and behave on a way, imho, that not only doesn’t provide any benefits but also constrain the possibilities.
—
Los reyes de las etiquetas… or el rey de las galletas?
Offline
#7 2009-10-31 17:28:34
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_article_list inside article_custom always evaluates true
Cookie king??
Offline