Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-02-20 10:46:18
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
check if there's content
On my homepage I have the last 5 news-items with excerpts and “read more” butons.
Sometimes there’s nothing more than only the excerpt so I don’t need teh “read more”.
How can I achieve this?
Thanks
Offline
Re: check if there's content
I’d reverse your way of editing articles and always write an article body, while longer posts would also have an excerpt.
Then use txp:if_excerpt to conditionally include txp:excerpt and the “read more…” link from your article form.
Offline
#3 2006-02-20 13:02:08
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Re: check if there's content
Isn’t that a bit odd?
That’ll work but I would have to change all my articles and it seems a bit the wrong way to me…
Isn’t there another way?
Offline
Re: check if there's content
There’s always another way. txp:if_excerpt is just the way it was meant to be by the founding fathers of Textpattern.
Offline
Re: check if there's content
> janw wrote:
Isn’t that a bit odd?
That’ll work but I would have to change all my articles and it seems a bit the wrong way to me…
Isn’t there another way?
I would go by changing your articles…
The “excerpt” usually is an excerpt of the article body. I think the wrong way is to have an excerpt but not a body.
Check:
How do I show only an excerpt in article lists from TXP FAQs
Offline
#6 2006-02-20 23:23:22
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: check if there's content
There’s no <txp:if_body>
tag, but it wouldn’t be hard to make one as a plugin.
Alex
Offline
#7 2006-02-22 07:29:52
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Re: check if there's content
I know an excerpt is an excerpt from a body, but the solution as it’s meant to be seems strange to me.
To use body as an intro and excerpt as the body.
This is what I mean to achieve. An intro and an body.
Offline
Re: check if there's content
> janw wrote:
Sometimes there’s nothing more than only the excerpt so I don’t need teh “read more”.
I know an excerpt is an excerpt from a body
So what exactly does this excerpt excerpt, in lack of a body? I feel those two assumptions contradict themselves.
It’s not that I wanted you to change your way of generating content, but I simple do not get it how you can judge the method which works with out-of-the box Textpattern tags as “odd”.
Offline
#9 2006-02-22 07:55:07
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Re: check if there's content
In the FAQ it says:
[…]Textpattern provides two main text fields per article: the Body and the Excerpt. The Body is the main article content. The Excerpt is normally used for a summary, <strong>introductory paragraph</strong>, abstract or similar.[…]
I mean to use it as an intro. Sometimes there’s nothing more than an intro (just a small article).
If I use it that way it seems odd to me to put everything in “excerpt” and use body as an intro.
Offline
#10 2006-02-23 02:36:23
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: check if there's content
janw, I’m not sure I understand the problem here: if there is ever only an excerpt, can you not use the body field, since it really isn’t an intro nor an excerpt? i.e: if there is both, use both, if there isn’t use body?
<pre><code><txp:if_excerpt>
<txp:excerpt />
<p><txp:permlink>read more…</txp:permlink></p>
<txp:else />
<txp:body />
</txp:if_excerpt></code></pre>
Last edited by Mary (2006-02-23 02:36:39)
Offline
#11 2006-02-28 07:43:45
- janw
- Member
- From: Groningen
- Registered: 2005-11-18
- Posts: 47
Re: check if there's content
That does the trick…
Sometimes the solution is very easy :-)
Thanks a lot.
Offline
Re: check if there's content
Offline