scriptygoddess

20 Jun, 2002

collapse extended entries

Posted by: kristine In: Bookmarks

I've seen this used several places – Aarondot.com: A better way to display Extended Entries. This allows you to javascript to contract the "more" section of your post right on the index page. Cool idea!

19 Responses to "collapse extended entries"

2 | Sherry

June 20th, 2002 at 2:07 pm

Avatar

I use it on my blog and absolutely love it!

3 | Promo

June 20th, 2002 at 4:30 pm

Avatar

I just added it, after I cleaned up the variable names a little bit! Love this one!

Pleasepleaseplease one of you Goddesses figure out how to use this same idea to expand and collapse in-line comments.

With sugar on top?

4 | kristine

June 20th, 2002 at 4:56 pm

Avatar

Promo, ya know, when I saw this code, I actually thought of your site and how you display comments and how nice it would be. :) Really truly! I'll look at it tonight after work and modify it for you, I'm very sure this would work well for you, and I'm pretty sure I can get it to work :)

5 | Promo

June 20th, 2002 at 5:06 pm

Avatar

Oh you are about to rock my world!

Wouldn't it be cool if you could make it be collapsed if more than X comments were left? Like for the Monday Mission I'd much rather have them collapesd, but for other entries it would be nice to have a few comments showing.

But heck, I will take whatever I can get! Thanks for thinking of me. Wheeeee!

6 | Kymberlie R. McGuire

June 20th, 2002 at 10:40 pm

Avatar

That was quick and easy! Thanks for the code!

7 | zalary

June 21st, 2002 at 12:26 am

Avatar

i am sooo glad you girls posted this here. i've actually been searching everywhere for this script, after seeing it on a few blogs. and if it would work with inline comments – that would be so cool. maybe i'll play with it myself just for kicks!

yay! thanks again :)

8 | Christine

June 21st, 2002 at 10:58 pm

Avatar

You beat me to the punch – I had bookmarked it, but since I had just made a couple of other posts at the same time I hadn't posted that one yet – then Kymberlie told me that you posted it … which amused me because great minds think alike! Yeah!

9 | Jennifer

June 22nd, 2002 at 8:28 am

Avatar

Promo – I think I figured out how to do what you want…

You still use that same function… and where you want the comments to go put this:

<MTEntryIfAllowComments>
<span id="thankYourMother<$MTEntryID$>" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="ChristIsImmanentInAllThings(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;">Show Comments Here »</a><br /></span><div id="coconutsKillMorePeopleThanSharks<$MTEntryID$>" style="display: none"><MTComments>
<p><$MTCommentBody$></p>
<p>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></p><br /><br />
</MTComments><a href="#<$MTEntryID pad="1"$>" onclick="ChristIsImmanentInAllThings(<$MTEntryID$>,0);return
true;">« Hide Comments</a></div>
<MTEntryIfAllowComments>

That will allow you to collapse/hide comments on every post… if you ONLY want that displayed for CERTAIN posts… I can do that too… it's just a little more involved.

I'm using this now on my blog

Hehehe… the above is using his code. I'm sure I don't have to tell you that I changed some of the variable names in the code in my blog 😉

10 | Jennifer

June 22nd, 2002 at 8:32 am

Avatar

one thing I just noticed though… if you have both an extended entry AND comments – it doesn't seem to work. I'll have to play with it a bit to figure out why.

11 | Jennifer

June 22nd, 2002 at 8:51 am

Avatar

ok – now I've got it… if you want to do BOTH, you'll need to make a seperate function for the comments. Do a search and replace on the variable in the function and the comment code snippet and change the name to something different.

That's it. It's working on my blog now. :)

12 | Lynda

June 22nd, 2002 at 11:19 am

Avatar

Jennifer, I'm not sure if you'd need to make a separate function, but since the javascript is calling up each thing in reference to its mtentryid, you'll probably have to add a "c" or another distinguishing character onto the end of the the ones for comments so it knows its separate.

Like this:

<MTEntryIfAllowComments>
<span id="thankYourMother<$MTEntryID$>c" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="ChristIsImmanentInAllThings(<$MTEntryID$>c,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;">Show Comments Here »</a><br /></span><div id="coconutsKillMorePeopleThanSharks<$MTEntryID$>c" style="display: none"><MTComments>
<p><$MTCommentBody$></p>
<p>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></p><br /><br />
</MTComments><a href="#<$MTEntryID pad="1"$>" onclick="ChristIsImmanentInAllThings(<$MTEntryID$>c,0);return
true;">« Hide Comments</a></div>
<MTEntryIfAllowComments>

I don't see a need to create a separate function though.

13 | Lynda

June 22nd, 2002 at 11:19 am

Avatar

By the way, Here's how to do it with pMachine

A bit more difficult.. :)

14 | Jennifer

June 22nd, 2002 at 11:34 am

Avatar

Yeah, I tried that, but it didnt' work… both putting a unique character BEFORE or AFTER the MTEntryID. It would just send you to the individual entry.

15 | zalary

June 22nd, 2002 at 9:55 pm

Avatar

i was playing with it yesterday – and i added a seperate function to make the comments work – but i think it works best just to display the comments and not the actual commenting form – as i couldn't get the "remember me" cookie to work.

add to script: (you could probably consolidate this into the original, but i didn't)

<script>

function ThyWordisaLamp(youBet, justInCase){
aarondotrules = ('justtestingthisout' + (youBet));
getitoutofhere = ('morethanenough' + (youBet));
if( document.getElementById ) {
if( document.getElementById(aarondotrules).style.display ) {
if( justInCase != 0 ) {
document.getElementById(aarondotrules).style.display = "block";
document.getElementById(getitoutofhere).style.display = "none";
} else { document.getElementById(aarondotrules).style.display = "none";
document.getElementById(getitoutofhere).style.display = "block"; }
} else { location.href = justInCase;
return true; }
} else { location.href = justInCase;
return true; }
}
</script>

then for your comment link:

<MTEntryIfAllowComments>
<span id="aarondotrules<$MTEntryID$>" class="extended"><a href="javascript:(void);" onclick="ThyWordisaLamp(<$MTEntryID$>,'<$MTEntryLink$>#comments');return false;" target="_self">comments (<$MTEntryCommentCount$>)</a>
</span>

<div id="justtestingthisout<$MTEntryID$>" style="display: none">

<p align="center"><a href="#<$MTEntryID pad="1"$>" onclick="ThyWordisaLamp(<$MTEntryID$>,0);return
true;" target="_top" onmouseover="window.status='collapse this entry '; return true;" onmouseout="window.status=' '; return true;">collapse comment display</a>
<MTComments>
. . . (your stuff)
</MTComments>

</MTEntryIfAllowComments>

16 | Dreama

June 23rd, 2002 at 1:30 am

Avatar

I have yet to see this actually work — that's in IE 5 for Mac OS 9. Click the links and nothing happens. I don't know if the people who I have encountered trying the script have done something wrong, or if it's just not functional for IE/Mac. Worth checking into, though.

17 | Jennifer

June 23rd, 2002 at 11:36 am

Avatar

Hmm… Dreama – have you tried it on my site? If it doesn't work – then it might not work on IE 5 for Mac. Wonder if it works on IE 6 tho. (I don't have access to a mac to test stuff out on – I will at my new job though…)

18 | Dreama

June 23rd, 2002 at 11:52 am

Avatar

Jennifer — it is working on your site, if this is what you're using to display comments inline. Funny. I've seen it in three other places thus far, and none of them worked.

(Btw, IE 6 is not available for any Mac OS yet, and I don't think that Microsloth has even given a release date for it yet. 5.1 or some such is the latest version we have.)

19 | Promo

June 24th, 2002 at 12:47 am

Avatar

Wonderful! I look forward to adding this tomorrow, but I have 2 requests.

1) Could a Goddess please make a cumulative post of the "collapse comments" version (with better variables?) and make it a new entry here at SG.com? I fear others who may want this would never find it in the comments in this entry.

2) Is there a way to either: a) use this on some entries and not others? or b) have it auto-collapse (hide comments) after a given number of comments (like 5, for example)?

If not no problem, this is just what I wanted, thanks so much!

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