scriptygoddess

13 Apr, 2002

How to have your comments line say different things depending on the number of comments

Posted by: Jennifer In: How to's

Long how to description… simple script.

(This script is specific to MT)

In Javascript:

<script language=javascript>
<!–
document.write('<a href="<$MTEntryLink$>#comments">')
if (<$MTEntryCommentCount$> == 0)
{
document.write(<b>'speak up</b></a>')
} else if (<$MTEntryCommentCount$> == 1)
{
document.write('<$MTEntryCommentCount$> <b>voice</b></a>')
} else if (<$MTEntryCommentCount$> > 1)
{
document.write('<$MTEntryCommentCount$> <b>voices</b></a>')
}
//–>
</script>

or in PHP:
<?
print('<a href="<$MTEntryLink$>#comments">');
if (<$MTEntryCommentCount$> == 0)
{
print('speak up</a>');
} else if (<$MTEntryCommentCount$> == 1)
{
print('<$MTEntryCommentCount$> voice</a>');
} else if (<$MTEntryCommentCount$> > 1)
{
print('<$MTEntryCommentCount$> voices</a>');
}
?>

8 Responses to "How to have your comments line say different things depending on the number of comments"

1 | Leann

April 16th, 2002 at 10:36 pm

Avatar

Yea! Just what I've been looking for!

2 | kristine

April 29th, 2002 at 8:19 pm

Avatar

I just noticed that this tip was on the sg site :) Nah, I'm not slow LOL!

here's a thread on the MT boards that has an SSI solution for this as well as the PHP and JS that Jenn put together initially :)

3 | cal

January 23rd, 2003 at 3:15 pm

Avatar

i love this comment script….but was wondering, (due to my lack of javascripting skills)…

if you could combine the above script with the following:

<MTEntryIfAllowComments>
| <a href="<$MTCGIPath$><$MTCommentScript$>?entry_id=<$MTEntryID$>" onclick="OpenComments(this.href); return false">Comments (<$MTEntryCommentCount$>)</a>
</MTEntryIfAllowComments>

this way i could keep the comments pop-up.
thanks!

4 | Jennifer

January 24th, 2003 at 8:22 am

Avatar

Yes. Change this line in my code:

document.write('<a href="<$MTEntryLink$>#comments">')

to this:

document.write('<a href="<$MTCGIPath$><$MTCommentScript$>?entry_id=<$MTEntryID$>" onclick="OpenComments(this.href); return false">')

(of course my script needs to be put between the <MTEntryIfAllowComments> like you had)

oh, and the PHP version – change this line in my code:

print('<a href="<$MTEntryLink$>#comments">');

to this:

print('<a href="<$MTCGIPath$><$MTCommentScript$>?entry_id=<$MTEntryID$>" onclick="OpenComments(this.href); return false">');

5 | cal

January 24th, 2003 at 2:10 pm

Avatar

truly fabulous, jennifer, as always 😉

6 | Richard Ames

February 9th, 2003 at 1:38 am

Avatar

Hi Goddess- I tryed your java script above, but keep getting "Unterminated script constant" error message after I try to load the page in my browser after rebuilding MT with the script in it. I haven't a clue what that error message means. I put the script between the &ltMTEntryIfAllowComments&gt tags as you said. Any ideas?

-Richard.

7 | joi

September 18th, 2003 at 1:47 am

Avatar

i really really adore this script, but im having trouble getting it to work… can someone post a sample of what that section of code should look like once inserted into the template? ive tried it several different ways, but either my links stay the same as before, or they disappear completely. do i need something MORE than this script, or should i just have this script between ?

any help would be great! thanks :)

-joi.

8 | Kristina

February 11th, 2004 at 5:17 pm

Avatar

The php and javascript versions weren't working for me (possibly conflicting with the restricted posts hack). So I tried searching and found this MT plugin in the support forums and it worked beautifully! Just wanted to pass it on!

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements