Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-04-27 10:48:57

Konijn
Member
Registered: 2005-06-18
Posts: 33

Comments count problem

Hey,

When i use <code><txp:comments_count /></code> and there are no comment’s yet, it outputs nothing.
How can I display it 0 ?

Thx

Last edited by Konijn (2006-04-27 10:49:27)

Offline

#2 2006-04-27 11:01:05

Konijn
Member
Registered: 2005-06-18
Posts: 33

Re: Comments count problem

I added this
<code>
if ($com_count == 0){ return 0; }else{ return $com_count ; }
</code>

in taghandlers.php

Offline

#3 2006-04-27 14:44:05

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Comments count problem

Konijn,

I think another solution could be:
<txp:if_comments><txp:comments_count /><txp:else />0</txp_if_comments>

This way, you dont have to hack any file so when upgrading to a new txp release, you dont have to remember to do the hack:

more info about if_comments


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2006-04-27 17:20:14

Konijn
Member
Registered: 2005-06-18
Posts: 33

Re: Comments count problem

I tried to use it, but it didn’t returned the comments_count.

Offline

#5 2006-04-27 17:30:22

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Comments count problem

Oh!

It worked for me.
Did you put the suggested snippet inside an article form?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2006-04-27 17:32:17

Konijn
Member
Registered: 2005-06-18
Posts: 33

Re: Comments count problem

Yes, I will try again.

Offline

#7 2006-04-27 17:34:12

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Comments count problem

My full snippet is the following:

<pre><code>
&#60;txp&#58;if&#95;comments&#95;allowed&#62;
&#60;li&#62;&#60;a href&#61;&#34;&#60;txp&#58;permlink &#47;&#62;&#35;comentario&#34;&#62;&#60;txp&#58;if&#95;comments&#62;&#60;txp&#58;comments&#95;count &#47;&#62;&#60;txp&#58;else &#47;&#62;0&#60;&#47;txp&#58;if&#95;comments&#62; &#60;txp&#58;comments&#95;invite textonly&#61;&#34;1&#34; showcount&#61;&#34;0&#34; &#47;&#62;&#60;&#47;a&#62;&#60;&#47;li&#62;
&#60;&#47;txp&#58;if&#95;comments&#95;allowed&#62;
</code></pre>

Last edited by maniqui (2006-04-27 17:34:35)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2006-04-27 17:39:18

Konijn
Member
Registered: 2005-06-18
Posts: 33

Re: Comments count problem

Thx; it works now.
You can see the result here on my personal site: http://www.freshface.be/

Offline

Board footer

Powered by FluxBB