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>');
}
?>

Related posts:

  1. Simple Shortcode for Line Breaks One kind of funny thing with WordPress is that entering...

Related posts brought to you by Yet Another Related Posts Plugin.

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

1 | 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!

2 | 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.

3 | cal

January 24th, 2003 at 2:10 pm

Avatar

truly fabulous, jennifer, as always ;-)

4 | 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.

5 | 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!

6 | 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">');

7 | 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 :)

8 | Leann

April 16th, 2002 at 10:36 pm

Avatar

Yea! Just what I've been looking for!

Featured Sponsors


  • cliff: hi wonder if you can help me, pls i designed www.kouga.mobi using dreamweaver CS3 and now want to make the phonenumbers into links so that if you
  • jerey: how do i rewrite this because it tried RewriteEngine on #Options +FollowSymlinks RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FIL
  • Jennifer: So I was testing this out to see if maybe something changed in the latest version - I had a test wordpress setup - and just dumped the mycomment funct

About


Advertisements