Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txp:if_article_id on article list context #35

Closed
ghost opened this issue Oct 4, 2014 · 11 comments
Closed

txp:if_article_id on article list context #35

ghost opened this issue Oct 4, 2014 · 11 comments

Comments

@ghost
Copy link

ghost commented Oct 4, 2014

From mani...@gmail.com on August 26, 2009 00:53:46

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):

<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.

Original issue: http://code.google.com/p/textpattern/issues/detail?id=31

@ghost ghost added the imported label Oct 4, 2014
@ghost
Copy link
Author

ghost commented Oct 4, 2014

From mani...@gmail.com on August 25, 2009 16:01:46

BTW, this is current "workaround":

<txp:article_custom file_id="_%" section='<txp:section />' >
txp:if_article_list

<txp:title />


<txp:else />
txp:if_article_id

<txp:title />


<txp:else />

<txp:title />


/txp:if_article_id
/txp:if_article_list
/txp:article_custom

@ghost
Copy link
Author

ghost commented Oct 4, 2014

From mani...@gmail.com on August 25, 2009 17:07:13

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.

@ghost
Copy link
Author

ghost commented Oct 4, 2014

From julian.l...@gmail.com on August 28, 2009 18:22:02

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.

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.

@ghost
Copy link
Author

ghost commented Oct 4, 2014

From mani...@gmail.com on October 31, 2009 08:42:45

Some ongoing discussion related to commend #2 here: http://forum.textpattern.com/viewtopic.php?id=32216

@vanmelick
Copy link
Contributor

Lots of info lost during transfer from Google Code. Let's try that again:


Reported by mani...@gmail.com, 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):

<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.


Aug 25, 2009 #1 mani...@gmail.com

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>


Aug 25, 2009 #2 mani...@gmail.com

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.


Aug 28, 2009 #3 julian.l...@gmail.com

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.

makss added a commit that referenced this issue Nov 4, 2017
@petecooper
Copy link
Sponsor Member

@makss - does your commit bd35681 address this issue?

@makss
Copy link
Contributor

makss commented Nov 30, 2017

@petecooper , He has nothing to do with this issue. it looks like it's a bug of the GitHub interface. it was # 35 pull request in my repository, synchronization textpattern:dev to makss:patch-3.

@petecooper
Copy link
Sponsor Member

As this issue's ten year birthday is approaching this year, I figured it would be worth revisiting.

[…] anyone may argue that using if_article_id outside an
individual_article context may not make any sense, and may be considered invalid.

Is this the answer? @bloatware @Bloke - what is your view on this issue, please?

@Bloke
Copy link
Member

Bloke commented Jan 16, 2019

As of 4.7.0, <txp:if_article_id /> may be used as a single tag to return true (1) if there is one. It still tests for article-ness, though, so I'm not sure if this actually answers the question about using it in article list context. Tests would prove it.

@philwareham
Copy link
Member

@Bloke @bloatware is this issue still valid, given the tag changes that were done as part of the 4.8 dev cycle?

@philwareham
Copy link
Member

I'm going to close this issue - it's an extreme edge case that nobody know if resolved or not! Basically you can achieve this with other tags anyway nowadays so I don't see any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants