Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Excerpt in only some articles
thought i would share this: decided that i wanted an excerpt option to longer articles, But these are few and would only occur occasionally .
I wanted to add a read more to the full article if there was an Excerpt in the article, and not have the “read more” appear in every article. I accomplished it this way:
<div class="entry-inner"> <txp:body /> <!-- article has an excerpt so we want a Read More link --> <txp:if_excerpt> <a href="<txp:permlink />" title="<txp:title />">» Read more</a> <txp:else /> </txp:if_excerpt> </div>
I know this is probably obvious to many ..
…. texted postive
Offline
#2 2015-04-13 11:15:15
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: Excerpt in only some articles
<txp:if_excerpt>
<txp:excerpt />
<a href="<txp:permlink />" title="<txp:title />">» Read more</a>
<txp:else />
<txp:body />
</txp:if_excerpt>
Offline
Re: Excerpt in only some articles
GugUser wrote #289943:
<txp:if_excerpt>...
does not create the solution that my version does. It outputs the body AND excerpt. i only want the excerpt in the permalink of the single article.
What i do is output the complete articles BUT if there is an excerpt add the read more link to the full article (Single Article)
so in the default Page form :
<txp:article form="defaultV2015" limit="3" /><!-- 3 ARTICLES -->
in the defaultV2015 form i have:
<txp:body /> <txp:if_excerpt> <a href="<txp:permlink />" title="<txp:title />">» Read more</a> <txp:else /> </txp:if_excerpt>
and in the Single form i have:
<txp:body /> <txp:if_excerpt> <div itemprop="description"> <txp:excerpt /> </div> </txp:if_excerpt>
i may be doing this in an unconventional way but it seems to work.
…. texted postive
Offline
#4 2015-04-13 22:58:55
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: Excerpt in only some articles
You can do what you like, logically, but I don’t understand why you show <txp:body />
and at the same time a more link to the <txp:excerpt />
, if it exists, etc.
But, for me, it doesn’t matter.
Offline
Re: Excerpt in only some articles
I was never anticipating having longer articles so i started out by only needing the <Body> tag. The n i found i needed it for longer articles.
I don’t want to ever show the <excerpt> except when it appears o the Single listing.
I believe that the conventional approach is to show the <excerpt> as the main output and then link to the FULL listing where both the Body and Excerpt text are shown. i ended up doing it backwards. I am using <excerpt> to add to the body for the complete article.
…. texted postive
Offline
Pages: 1