30 Dec, 2003
Updated Show/Hide script – (with additional links in the same line)
Posted by: Jennifer In: MT Tips n Tricks
Long title. Sorry. 😀
Someone wanted to use the show/hide comments script but have more than just the "show comments"/"hide comments" text in the same line. Basically – what they wanted was :
Permalink | Show Comments(3) | Add Comment | Trackback(2)
Where the "Show Comments" would drop down and do the show/hide comments – and it would only be there IF there had been comments to display. (for this last part, to use this script, you need to be running PHP on your page)
I know this is a very particular case – but there's pieces in here you could probably cut, mix, and match.
First, you need to get the updated version of the show more comments script here. (Side note: to Mr. Tweezer's complaint in his post about my not making it easier for him to use my scripts… I'm sorry- I'll refund your money… oh wait – this site is free and actually here for my OWN PERSONAL reference… Sometimes I even drop code here without explanation – just so I can grab it later. The "disclaimer" in the sidebar also says "we are volunteers, not paid tech support. In the end, you're on your own." Seems he decided to take that part down. How nice.)
In any case instead of using the show more comments function I've posted previously, use his revised one instead (function name changed to work seperately for comments):
<script type="text/javascript">
function showMoreComments(entryID, entryLink, htmlObj) {
extTextDivID = ('extText' + (entryID));
extLinkDivID = ('extLink' + (entryID));
if( document.getElementById ) {
if( document.getElementById(extTextDivID).style.display ) {
if( entryLink != 0 ) {
document.getElementById(extTextDivID).style.display = "block";
document.getElementById(extLinkDivID).style.display = "none";
htmlObj.blur();
} else {
document.getElementById(extTextDivID).style.display = "none";
document.getElementById(extLinkDivID).style.display = "block";
}
} else {
location.href = entryLink;
return true;
}
} else {
location.href = entryLink;
return true;
}
}
</script>
Now put this code below your entries in your template: