How to have your comments line say different things depending on the number of comments
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>');
}
?>
April 16th, 2002 at 10:36 pm
Yea! Just what I've been looking for!
April 29th, 2002 at 8:19 pm
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
January 23rd, 2003 at 3:15 pm
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!
January 24th, 2003 at 8:22 am
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">');
January 24th, 2003 at 2:10 pm
truly fabulous, jennifer, as always
February 9th, 2003 at 1:38 am
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 <MTEntryIfAllowComments> tags as you said. Any ideas?
-Richard.
September 18th, 2003 at 1:47 am
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.
February 11th, 2004 at 5:17 pm
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!