My favorites | Sign in
Project Logo
          
New issue | Search
for
| Advanced search | Search tips
Issue 31: txp:if_article_id on article list context
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by maniqui, Aug 25, 2009
When on individual article context, the following snippet work as expected:
if I'm viewing article X, then article X title is not linked on the
generated output. Great!

<txp:article_custom file_id="_%" section='<txp:section />' >
  <txp:if_article_id>
    <h3><txp:title /></h3>
  <txp:else />
    <h3><a href="<txp:permlink />" rel="bookmark" title="Read this
extract"><txp:title /></a></h3>
  </txp:if_article_id>
</txp:article_custom>

But then, if I'm on article list context, I get no ouput at all for any of
the two "branches" on the conditional tag.

Tag trace (for the sake of brevity, I've copied just one loop and of the
above code):

bc. <txp:article_custom file_id="_%" section='<txp:section />' wraptag="ul">
		[attribute 'section']
		<txp:section />
		[/attribute]
		[SQL (0.000875949859619): select *, unix_timestamp(Posted) as uPosted,
unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod
from textpattern where 1=1 and Status = 4 and Posted <= now() and Section
IN ('xxxxxx') and custom_1 like '_%'  order by Posted desc limit 0, 10]
		[article 26]
		</txp:if_article_id>
		<txp:article_id />
		<txp:if_article_id>
		</txp:if_article_id>
		<txp:permlink />
</txp:article_custom>

If you need additional info, please, tell me.
Thanks.


What version of the product are you using? On what operating system?

I'm on TXP 4.2.0 RC (r3269) on Ubuntu Linux.
Comment 1 by maniqui, Aug 25, 2009
BTW, this is current "workaround":

<txp:article_custom file_id="_%" section='<txp:section />' >
  <txp:if_article_list>
    <h3><a href="<txp:permlink />" rel="bookmark" title="Read this
extract"><txp:title /></a></h3>
  <txp:else />
    <txp:if_article_id>
      <h3><txp:title /></h3>
    <txp:else />
      <h3><a href="<txp:permlink />" rel="bookmark" title="Read this
extract"><txp:title /></a></h3>
    </txp:if_article_id>
  </txp:if_article_list>
</txp:article_custom>
Comment 2 by maniqui, Aug 25, 2009
Let me deviate a little from the original issue.

This is "worst" that what I would have expected. The above workaround won't work, as
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>

I've tested the above snippet both on 4.0.8 stable and 4.2.0 RC (r3269) and got the
same output, so I'm still asking myself it this is a bug or just how things are
supposed to work.

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 widgets that are
both used on both contexts (lists or individual articles). 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?
Or I'm totally confused, or this is a bug, or things changed, or I need to sleep.
Sorry for my english.


Comment 3 by julian.landerreche, Aug 28, 2009
Back to the initial issue, anyone may argue that using if_article_id outside an
individual_article context may not make any sense, and may be considered invalid. 

Using it inside an individual_article context, the question means: "is the article id
(the one for current URL) equal to X? (where "id" attribute value defaults to current
article if not specified)

Using it inside an article_list context, the question could mean: "on the current
URL, is it there any article_id value?" (which, of course, it should return false).

A few more thoughts on all this:

Regarding issue on #c2 (if_article_list being "true" inside article_custom, even on
individual article context), let me insist: it's a bug.

Regarding if_article_id, i spotted this scenarios on different scenarios

A) if_article_id on *individual_article* context:

A.1) <if_article_id> (no id attribute) is used _outside_ an <article_custom> tag =>
keep current behaviour: test currently being viewed article's id against default
attribute value. 
This case always return true, as the id attribute defaults to currently viewed
article id.

A.2) <if_article_id id="X"> is used _outside_ an <article_custom> tag => keep current
behaviour (test currently being viewed article's ID against "X"). 
May return true or false.

<my brain may be reaching a dead-end street below here>

A.3) <if_article_id> (no id attribute) used _inside_ an <article_custom> tag => keep
current behaviour: test article's id of current <article_custom> loop against a
default value (which equals the id of the article currently being viewed). 
May return true or false.


A.4) <if_article_id id="X"> is used _inside_ an <article_custom> tag => keep current
behaviour: test article's id of current <article_custom> loop against "X". 
May return true or false.

(being that every point above says "keep current behaviour", I'm not yet sure where
I'm heading to nor what's my point :P)

B) if_article_id on *article_list* context:

B.1) <if_article_id> (no id attribute) is used _outside_ an <article_custom> tag =>
new feature: return false.

B.2) <if_article_id id="X"> is used _outside_ an <article_custom> tag => new feature:
return false.

B.3) <if_article_id> (no id attribute) used _inside_ an <article_custom> tag => new
behaviour: return false
See original post on this thread: currently it doesn't return nor true nor false, and
workaround on #c2 is not currently possible.

B.4) <if_article_id id="X"> is used _inside_ an <article_custom> tag => keep current
behaviour: test article's id of current <article_custom> loop against "X". 
May return true or false.


Ok, I'll stop by now, sorry if this is too much non-sense.
Comment 4 by maniqui, Oct 31, 2009
Some ongoing discussion related to commend #2 here:
http://forum.textpattern.com/viewtopic.php?id=32216
Sign in to add a comment

Hosted by Google Code