Updated Show/Hide script - (with additional links in the same line)
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:
December 30th, 2003 at 10:05 pm
where exactly would i put this code?
December 30th, 2003 at 10:10 pm
The javascript part can go between your <head></head> tags.
The rest can go after your your post (and your more link and/or drop down…) in your template.
My suggestion is make a test template page - dump the code in and see what happens. The best way to learn is by doing just that - putting code in - test. Move code. Test. Change code. Test. etc. etc.
December 30th, 2003 at 10:17 pm
d'oh, I posted the comment on the wrong entry. I ment to ask that on the php code you posted before this
December 30th, 2003 at 10:18 pm
One additional note - it goes BEFORE your ending </MTEntries> tag…
December 30th, 2003 at 10:19 pm
December 31st, 2003 at 9:11 am
Thanks for the updated Code link (tweezer's edge). I was unaware it had been updated.
Anyway, after installing that I went back and recreated the Expanding Comments code as well (as I used the old combined script) It wasn't hard and only required changing a couple of variables.
Thnaks for posting the updates..
December 31st, 2003 at 9:14 am
I guess I should clear it up..
I made my version without PHP and basically used just the included Javascript from Tweezer's Edge script.
December 31st, 2003 at 6:11 pm
Weapons of Mass Destruction found…in Texas Coming soon? Mini-IPods for around $100 Mini-IPod a good idea or bad? This is not a photo of a Mini-Ipod No, Virginia, there is no Mini-IPod Blog Madness 2003: Enter your best blog…
December 31st, 2003 at 7:02 pm
Since publishing my post "Improved Extended Entry Script and Template Code for MT", a couple of complaints have surfaced regarding what I wrote. In an MT Forum thread, LisaJill posted a link to my post. In response, Girlie (a forum…
January 5th, 2004 at 9:52 pm
Hey guys, I have a question. I used the hide anything script to made my sidebars retractable, but with the new update, it doesnt work anymore. Here is the code:
<span id="varP1234"><a href="#my_favorite_blogs"
onclick="showMore(1234,'#my_favorite_blogs');return false;">Favorite
Blogs »</a><br /></span><div id="varXYZ1234"
style="display: none">
<$MTInclude module="Blogroll"$>
<p> <a href="#my_favorite_blog" onclick="showMore(1234,0);return
false;">« Hide Favorite Blogs</a></p></div>
January 5th, 2004 at 9:53 pm
What happens is that when I click on the link, nothing happens.
January 5th, 2004 at 10:03 pm
Your "showmore" function needs three variables passed into it (the original "showmoreanything" required two)
In the new version it looks as if the third variable being passed is simply 'this' - I'd have to test it, but I wonder if that alone would do it…
so:
showMore(1234,'#my_favorite_blogs',this);
and
showMore(1234,0,this);
but I haven't tested it so I'm not sure…
January 6th, 2004 at 2:44 pm
I have coded my index page to hide/show comments and it works great with the following exception.
I also have the extended entry code on the page, if their is an extended entry on a post clicking on "show comments" will extend the entry, vice open comments. Is a work around available?
January 6th, 2004 at 3:03 pm
The way I did it originally is I had to have TWO seperate functions - one for comments, and one for expanded entries. I will try to play around with it tonight to see if that's still neccessary (ideally, it would be nice if we didn't have to do that…) - If I get it to work - I'll do a new post with whatever code I come up with…
January 6th, 2004 at 9:26 pm
Updated with a new post and revised function and code here:
http://www.scriptygoddess.com/archives/004618.php
January 17th, 2004 at 11:52 am
Hey, sweet site!
I am triying to use this function to show/hide links placed at the end of my page. I have included the javascript in the head of my template, and implement the links as suggested, but I have (2) main problems:
January 17th, 2004 at 1:49 pm
I don't actually see this code on your page… (??)
January 17th, 2004 at 2:10 pm
? really? it's behind the 'Links (click to show)' in the first post (Entitled 'test'. Though I am not using the full php implementation, I attempted hardcoding the IDs in my initial run, and combining it with the MTProcessTags feature later to allow for quick posting of links to the blog (without using up the extended entry and excerpt fields).
Thanks alot! all help is appreciated
January 17th, 2004 at 2:16 pm
I'm trying out this new code to implement expandable content by using this elements. Links (click to show) " style="display: none"> Hide Comments Links (click to close list) » October 5, 2002 10:53 PM: A Sample » Another Sample Hi…
January 17th, 2004 at 10:32 pm
I mean when I view source - I don't see any of this code in there… I can't find the javascript function, or even see where your implementation is… You've got a lot going on in there…