Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » Excerpts?!!!

#1 2006-08-20 16:58:42

elduderino
Member
From: Whitstable. south-East England
Registered: 2006-01-02
Posts: 175
Website

Excerpts?!!!

Hi there,

I want to include excerts of articles on my default page. My current set up has the latest article displayed on the front page using the <code><txp:article /></code> tag. When you click the comment or permlink you’re taken to the individual article page.

Ive read the text book about this but i cant make head or tail of it to be honest.

What i want is three excerts to the last 3 articles or so and when you click thier permlinks you’re taken to the individaul pages.

Any ideas

Offline

#2 2006-08-20 17:30:35

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: Excerpts?!!!

There are a few ways to solve this problem. Personally I like to streamline things with conditional tags inside my default article form… basically using one form for two different situations.

This first part will dictate the behavior of my articles on the main landing pages.
<code>
<txp:if_article_list> <h3><txp:permlink><txp:title /></txp:permlink></h3> <txp:article_image /> <p class=“date”><txp:posted /></p> <txp:excerpt /> <txp:if_comments> <p><a href=”<txp:permlink />#discuss” class=“comments”>Comments (<txp:comments_count />)</a></p> <txp:else /> <txp:if_comments_allowed><p><a href=”<txp:permlink />#discuss” class=“comments”>Comments?</a></p> <txp:else /></txp:if_comments_allowed> </txp:if_comments> <p><txp:permlink>Read More</txp:permlink></p
</txp:if_article_list></code>

Notice how I also set up some conditional code for comments. If there are already comments, we get a link to them labeled Comments (#of comments). If there are no comments yet but they are allowed for the article, we get invitation text in the form of “Comments?”. If comments are not allowed we see nothing.

The second part shows how my form behaves on individual article pages:

<code>
<txp:if_individual_article> <h2><txp:title /></h2> <txp:article_image /> <p><txp:posted /></p> <txp:body /> <txp:if_comments> <h2>Make a Comment</h2><div id=“comments”><p><txp:comments /></p> </txp:if_comments>
</txp:if_individual_article></code>

Once my form is set up, I then go to my page template and call it up like so:

<code><txp:article listform=“default” limit=“3” /></code>

Keep in mind if you want to call up articles from other sections outside the current one, you should use article_custom instead…

<code><txp:article_custom listform=“default” limit=“3” section=“whatever” category=“whatever” /></code>

If like me, you find that article_custom tag is limited for more advanced applications, definitely check out chh_article_custom plugin. For now, I think you have enough to chew on. :)

Offline

#3 2006-08-20 18:04:42

elduderino
Member
From: Whitstable. south-East England
Registered: 2006-01-02
Posts: 175
Website

Re: Excerpts?!!!

HI there,

Thanks for the reply. Ive got that working great1 I really like the conditional bit in your code. Im going to use it!

Thanks

Offline

  1. Index
  2. » Archives
  3. » Excerpts?!!!

Board footer

Powered by FluxBB