Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-07-06 15:04:20
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Multiple Excerpt Forms & Conditionals
I am trying to use two different excerpt forms which will be called up according to category.
Here is the conditional code in my page template:
<code><txp:if_article_list>
<txp:if_category name=“Releases”>
<txp:article limit=“5” form=“releaseExcerpt” />
<txp:else />
<txp:article limit=“5” form=“excerpt” />
</txp:if_category>
</txp:if_article_list>
<txp:if_individual_article>
<txp:if_category name=“Releases”>
<txp:article limit=“1” form=“releaseNew” />
<txp:else />
<txp:article limit=“1” form=“default” />
</txp:if_category>
</txp:if_individual_article></code>
This is my default excerpt form:
<code><div class=“article”>
<h3><txp:permlink><txp:title /></txp:permlink></h3>
<p class=“date”><txp:posted /></p>
<p><txp:excerpt /></p>
<txp:if_comments>
<ul>
<li><a href=”<txp:permlink />#discuss” class=“comments”><txp:comments_count /> Comments</a></li>
<txp:else />
<ul>
<li><a href=”<txp:permlink />#discuss” class=“comments”><txp:comments_invite />0 Comments</a></li>
</txp:if_comments>
<li><a href=”<txp:permlink />” class=“readMore”>Read More</a></li>
</ul>
</div>
</code>
Here is the other specialized excerpt form.
<code><div class=“article”>
<h3><txp:permlink>”<txp:title />” by <txp:custom_field name=“Artist” /><txp:if_custom_field name=“Featuring”> feat. <txp:custom_field name=“Featuring” /></txp:if_custom_field></txp:permlink></h3>
<img src=“img/releases/covers/<txp:custom_field name=“HCM#” />.jpg” />
<p class=“date”><txp:custom_field name=“Season” /></p>
<p><txp:excerpt /></p>
<ul>
<li><a href=”<txp:permlink />” class=“play”>Play Demos</a></li>
<li><a href=”<txp:permlink />” class=“readMore”>Read More</a></li>
</ul>
</div></code>
Note: Most of my articles override the default form and I can’t seem to make them display any other way.
Looking forward to your wisdom,
Ace
Offline
#2 2006-07-06 17:00:09
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Multiple Excerpt Forms & Conditionals
After poking through Textbook, I decided to use listform for article lists:
<code><txp:if_article_list>
<txp:if_article_category name=“Releases”>
<txp:article limit=“5” listform=“releaseExcerpt” />
<txp:else />
<txp:article limit=“5” listform=“excerpt” />
</txp:if_article_category>
</txp:if_article_list>
<txp:if_individual_article>
<txp:if_article_category name=“Releases”>
<txp:article limit=“1” form=“releaseNew” />
<txp:else />
<txp:article limit=“1” form=“default” />
</txp:if_article_category>
</txp:if_individual_article>
</code>
Still does not work. I even went into my articles and changed the form to default, but for some reason my conditional tags have no effect on their appearance whatsoever. Perhaps I havent nested them correctly…gonna have another poke around…
Offline
#3 2006-07-06 17:13:48
- Ace of Dubs
- Member

- Registered: 2006-04-17
- Posts: 446
Re: Multiple Excerpt Forms & Conditionals
I finally got it, thanks to zem:
http://textpattern.com/faq/24/how-do-i-show-only-an-excerpt-in-article-lists
<code><txp:if_article_list>
<! — list page: display the short version — >
<txp:excerpt />
<txp:permlink>read more</txp:permlink>
</txp:else />
<! — article page: display the complete article — >
<txp:body />
</txp:if_article_list></code>
It didn’t even occur to me that a conditional inside my article form would solve the problem. This solution is even better because now I only need one form for all my articles. Genius!
Offline
Pages: 1