Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-10-15 02:38:21
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
if_individual_article and if_article_list
I was just looking through some tags earlier and I’m trying to understand these two better.
What makes an article an “individual artile” and what makes something an “article list”?
In the description for if_article_list it has this as an example <txp:if_article_list> ...your content here...<txp:else />...default option... </txp:if_article_list>
I understand what the conditional is saying, but don’t know what an article list is?
Same goes for <txp:if_individual_article> ...your content here...<txp:else />...default option... </txp:if_individual_article>
Thanks
Offline
#2 2006-10-15 02:57:26
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_individual_article and if_article_list
The url. If it is not an individual article (http://yoursite.com/section/my-article) then it is an article list you’re looking at (even if the “list” only consists of one article).
Offline
#3 2006-10-15 11:34:43
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: if_individual_article and if_article_list
Ok. So, how would the if_article_list and if_individual_article help me?
Like when would be a time that I would want to use them?
Most sites using textpattern as a blogging tool have an article list on the homepage, right? Just a list of excerpts of every article, with a link to “read more” or something like that. So why would I (or could I) use if_individual_article on the homepage when it’s an article list?
Offline
Re: if_individual_article and if_article_list
Both are tools for the same job. Attempt at a poor analogy: if_article_list
is your big hammer you use most often, and if_individual_article
is your smaller hammer you use in special situations. Both do the same thing, hammer nails.
if_article_list
= do stuff for article listings (ex: /section/). EX: Display most recent articles, a search box etc. Same as the else
in if_individual_article.
if_individual_article
= do stuff for the article itself (ex: /section/title). This is the equivalent of <txp:else />
in <txp:if_article_list>
. You can use it to display the article for article pages, or display certain things for article lists. I tend to use it in forms for “quick” things, like <txp:if_individual_article><h2>Article</h2><txp:else />(don't say anything)</txp:if_individual_article>
. Personally, I use if_article_list more than if_individual_article, since it’s shorter to type. They both accomplish the same thing, just in reverse.
<txp:if_article_list>
<h1>We are on an article list page.</h1>
<p>Here are some articles:</p>
<txp:article form="excerpt" limit="20" />
<txp:else />
<p>We are on a SINGLE article page.</p>
<p>Here is an article:</p>
<txp:article />
</txp:if_article_list>
<txp:if_individual_article>
<p>We are on a SINGLE article page.</p>
<p>Here is an article:</p>
<txp:article />
<txp:else />
<h1>We are on an article list page.</h1>
<p>Here are some articles:</p>
<txp:article form="excerpt" limit="20" />
</txp:if_individual_article>
See how they’re basically reverse, in terms of else
statements (else=“not true”). So, it depends on what you like to type, since either one can get the job done.
edit: fixed code display
Last edited by jm (2006-11-16 04:48:39)
Offline
#5 2006-10-16 03:43:29
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_individual_article and if_article_list
So why would I (or could I) use if_individual_article on the homepage when it’s an article list?
You wouldn’t. It only matters on the “default” page if that page is also used by section other than “default”.
Offline
#6 2006-10-17 00:19:18
- deronsizemore
- Member
- From: Kentucky
- Registered: 2005-11-02
- Posts: 324
Re: if_individual_article and if_article_list
Thanks to the both you for helping me out. I think I finally am understanding conditionals. I’ve read this and other thread what feels like a few hundred times today trying to get it straight and Mary, you were right. A light buld just went off in my head and it was like “ohhhhh…I’m a moron!” type moment. I know I’ve got a long way to go, but I actually see how conditionals work now and maybe from now on if I get stuck and someone posts some conditional statements to try and help me I wont feel like I’m looking at Chinese.
Thanks again! You guys/gals are great.
Offline