Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I display comment invite text based on number of comments?
Here’s what I would like to do and where I want to do it:
If I have 0 coments for an article, I want “No comments” to show.
I have one comment for an article, I want the text “1 Comment” to show.
If I have 2 or more comments, I want “X Comments” to show (where X is the number of comments).
Is there a way for txp to do the above out of the box? or do I need to use a plugin (or perhaps the txp:php tag)?
Thanks in advance for help.
Offline
#2 2007-05-15 07:28:15
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How do I display comment invite text based on number of comments?
You probably want something like this plugin.
Out of the box, you could do:
<txp:if_comments>
No Comments
<txp:else />
Comments: <txp:comments_count />
</txp:if_comments>
You could also do something with PHP if you wanted, but it’s usually easier to just use a plugin.
Offline
Re: How do I display comment invite text based on number of comments?
Thanks for the quick reply.
That plugin you supplied looks perfect except for the download links are all busted.
Your pasted solution isn’t what I want because it would display “1 comments” if there was only one comment and that’s grammatically incorrect (sorry, my mom is an english teacher and she’d kill me if she saw that on my page).
Thanks again.
Offline
#4 2007-05-15 14:18:24
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do I display comment invite text based on number of comments?
slackorama wrote:
because it would display “1 comments” if there was only one comment
No it wouldn’t. It would display “Comments: 1”.
Here is another plugin that would work, but unfortunately also that download link is dead :(
Last edited by els (2007-05-15 14:20:42)
Offline