scriptygoddess

24 Jun, 2002

Collapsing entries AND COMMENTS

Posted by: Jennifer In: Scripts

IMPORTANT UPDATE!!
I'm leaving this post up here for archiving purposes – but please use the latest version of the script here.

As Promo asked; Here's that collapsing entries thing-a-ma-jig hacked for comments too…

First – The original script can be found here, curtesy of Aarondot.

Here's what I did:

(Sorry, but I had to change the names of the variables… the original just wasn't my thing)

Here's the two functions you need. Put these at the top of your page (**needed on EVERY page you want to do this collapse/expand thingy**)

<script language="javascript">
function showMore(varA1, varB1){
var123 = ('varXYZ' + (varA1));
varABC = ('varP' + (varA1));
if( document.getElementById ) {
if( document.getElementById(var123).style.display ) {
if( varB1 != 0 ) {
document.getElementById(var123).style.display = "block";
document.getElementById(varABC).style.display = "none";
} else { document.getElementById(var123).style.display = "none";
document.getElementById(varABC).style.display = "block"; }
} else { location.href = varB1;
return true; }
} else { location.href = varB1;
return true; }
}

function showMoreComments(varA12, varB12){
var1232 = ('varXYZ2' + (varA12));
varABC2 = ('varP2' + (varA12));
if( document.getElementById ) {
if( document.getElementById(var1232).style.display ) {
if( varB12 != 0 ) {
document.getElementById(var1232).style.display = "block";
document.getElementById(varABC2).style.display = "none";
} else { document.getElementById(var1232).style.display = "none";
document.getElementById(varABC2).style.display = "block"; }
} else { location.href = varB12;
return true; }
} else { location.href = varB12;
return true; }
}
</script>

Then for your expandable entries thingy:

<MTEntryIfExtended>
<span id="varP<$MTEntryID$>"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMore(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;"><p>read more »</p></a><br /></span><div id="varXYZ<$MTEntryID$>" style="display: none"><p><$MTEntryMore$></p><a href="#<$MTEntryID pad="1"$>" onclick="showMore(<$MTEntryID$>,0);return
true;"><p>« hide more</p></a></div>
</MTEntryIfExtended>

then for your comments:

<MTEntryIfAllowComments>
<span id="varP2<$MTEntryID$>" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;"><p>show comments right here »</p></a><br /></span><div id="varXYZ2<$MTEntryID$>" style="display: none">
<MTComments>
<$MTCommentBody$>
<p>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></p><br /><br />
</MTComments>
<a href="#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,0);return
true;"><p>« hide comments</p></a></div>
</MTEntryIfAllowComments>

I think Zalary also had done a version of this as well… she posted it in the comments of Kristine's original post. I didn't try hers out, This is just what I did, and I know for sure it works (even on IE 5 for Mac).

95 Responses to "Collapsing entries AND COMMENTS"

1 | Jennifer

June 24th, 2002 at 8:09 am

Avatar

Promo – as for other questions:
I think there might be a way to have it "auto collapse/expand" depending on the number of comments… I'll have to play around with it. Probably using php…

I CAN think of a way to have this work only for some posts – it would involve using PHP and have it do it only for certain categories. Again, I can try this out… or any PHPers out there wanna give it a shot??

bascially here's the pseudo-code: (psudeo code is just how I plan out what I'm going to write – it will NOT work on it's own)

$cat = <mtcategory>
if ($cat == "MondayMission") {
print EOF <<<
comment script shown above
EOF;
} else {
print EOF <<<
normal comment stuff
EOF;
}

similarly for the only doing it for x number of comments and above…

$maxcomments = 5
if (<mtcommentcount> > $maxcomments) {
print EOF <<<
comment script shown above
EOF;
} else {
print EOF <<<
normal comment stuff
EOF;
}

that's the basic idea… have to play with it to get it just right…

2 | Promo

June 24th, 2002 at 9:13 am

Avatar

Thank you GoddessJenn!

I too had changed the variables the first time I added the extended collapse, not that I didn't agree with some of it, I just thought it looked sloppy.

I just added this scripty goodness and it looks great. I need to adjust my CSS but that's my problem.

Can't wait to see pseudo-code become real. This is exciting!

3 | Promo

June 24th, 2002 at 9:17 am

Avatar

BTW, thought I would add that users might want to bookend the script with:

<script language="javascript" type="text/javascript">

and

</script>

And be sure to stick it in the section.

However, if you didn't know that you probably shouldn't be mucking about in MT's source code anyways!

4 | lavonne

June 24th, 2002 at 5:13 pm

Avatar

I love it! Is there any way to still show if there are any comments and how many?

5 | Jennifer

June 24th, 2002 at 5:38 pm

Avatar

Yeah, I have that MT comments block *in addition to* the block that actually says how many comments there are and is the link to the comments section… so I didn't replace what was already there, I just ADDED that block.

6 | lavonne

June 24th, 2002 at 6:09 pm

Avatar

Ah, *that's* what I did wrong. Thanks!

7 | lavonne

June 24th, 2002 at 7:05 pm

Avatar

hmm… now clicking the "read comments here" link goes to the entry page if there are no comments, or redirects to it in a couple of seconds after showing the comments on the main page.

8 | lavonne

June 24th, 2002 at 7:12 pm

Avatar

oops – and the same thing happens when i click 'read more' – it loads the entry onto the main page and then redirects to the entry page. worked fine before i put the default comment code back in the template.

here's the code currently in my template [i added the blurs using dreamweaver — could that be the problem?

<MTEntryIfExtended>
<span id="varP<$MTEntryID$>"><a href="<$MTEntryLink$>#<$MTEntryID pad="1 onFocus="if(this.blur)this.blur()""$>"
onclick="showMore(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return
false;">
<p>read more »</p></a></span><div id="varXYZ<$MTEntryID$>" style="display: none"><p><$MTEntryMore$></p>
<a href="#<$MTEntryID pad="1 onFocus="if(this.blur)this.blur()""$>" onclick="showMore(<$MTEntryID$>,0);return
true;">
<p>« hide more</p></a></div>
</MTEntryIfExtended>

<div class="posted"><a href="<$MTEntryLink$>#" onFocus="if(this.blur)this.blur()"><$MTEntryDate
format="%I:%M %p"$></a> <MTEntryIfAllowComments> | <a href="<$MTCGIPath$>mt-comments.cgi?entry_id=<$MTEntryID$>" onclick="OpenComments(this.href); return false" onFocus="if(this.blur)this.blur()">Comments
(<$MTEntryCommentCount$>)</a> <span id="varP2<$MTEntryID$>" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1 onFocus="if(this.blur)this.blur()""$>"
onclick="showMoreComments(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return
false;"><br />
read comments on this page »</p></a><br /></span><div id="varXYZ2<$MTEntryID$>" style="display: none">
<MTComments>
<$MTCommentBody$>
<p>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></p><br />
</MTComments> <a href="#<$MTEntryID pad="1 onFocus="if(this.blur)this.blur()""$>"
onclick="showMoreComments(<$MTEntryID$>,0);return true;">« hide comments</a></div>
</MTEntryIfAllowComments>

9 | Jennifer

June 24th, 2002 at 7:31 pm

Avatar

You've lumped them both into ONE block. You need TWO seperate mtentryifallowcomments blocks

Rather than cut and paste your code… here's essentially what I'm doing on mine:

<MTEntryIfAllowComments>
<a href="<$MTEntryLink$>#comments"><$MTEntryCommentCount$> comments</a>
</MTEntryIfAllowComments>

<MTEntryIfAllowComments>
<span id="varP2<$MTEntryID$>" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;">show comments right here »</h4></a><br /></span><div id="varXYZ2<$MTEntryID$>" style="display: none">
<MTComments>
<$MTCommentBody$>
<h4>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></h4><br /><br />
</MTComments>
<a href="#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,0);return
true;"><h4 align="right">« hide comments</h4></a></div>
</MTEntryIfAllowComments>

10 | lavonne

June 24th, 2002 at 7:59 pm

Avatar

ok, got it – thanks. i think the blur was part of the problem, too. once i removed those and followed your instructions, it worked fine.

thanks so much!

11 | Thursday

June 24th, 2002 at 11:06 pm

Avatar

i tried the expandable comments & it didn't work. I tried to restore the orignal config using the default templates & that didn't work either. could someone please be kind enough to copy the "function OpenComments" bit off of the top of their index.html (.shtml or .php – whatever it may be) and email it to me. This is causing me much grief.

Thank you

12 | bran

June 25th, 2002 at 2:21 pm

Avatar

i have to say–first thank you for changing the variable names. second, thanks for the expandable comments. you rock, Scripty Jen!

13 | Cis

June 26th, 2002 at 12:39 pm

Avatar

The comments expand is great. I'm not using it on my main page since I like having pop-up comments, but it works so great on my category archives.

14 | lavonne

June 26th, 2002 at 1:49 pm

Avatar

Well, now I've screwed it up and I can't figure out how to fix it. I missed my popup comments, so I tried to put the code back and remove the expandable comments code. kept getting a message that said the entry id was wrong–and it was. the leading two zeroes of the id were gone for some reason.

finally, i put the basic comment code back, which leads to the individual entry page — which of course, defeats the purpose of the expanding entry code, which i LOVE.

can anyone figure out why the entry id was missing the first two zeroes? sorry the code is no longer there to see, but maybe someone has come across this problem before and solved it. thanks.

15 | Simply Sara

June 29th, 2002 at 10:47 am

Avatar

Thanks so much for this Jennifer, too cool! :)

16 | girlie

July 13th, 2002 at 3:02 pm

Avatar

Is there anything that can be done to stop the page from jumping when you click "hide more"?

17 | robyn

July 16th, 2002 at 5:11 am

Avatar

Just wanted to say a belated thank you — I just got this up on my site (minus the expandable comments) and it seems to work well on my PC and Mac. THANKS!

18 | Jennifer

July 16th, 2002 at 9:32 pm

Avatar

girlie – see the part that says this:

<a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" …etc.

that #<$MTEntryID… is what is making it "jump".

You still have to specify a location for it to be at when the link is clicked. The "jumping" you are seeing is the page moving that current entry to the top of the screen…

You could play around with adding in your own "anchors" based on the MTEntryID and maybe an extra code… and placing it wherever you would prefer the page to "jump" to…

If that doesn't make sense, we can take it offline – email me and I"ll try to explain it better.

19 | girlie

July 16th, 2002 at 9:39 pm

Avatar

It makes perfect sense, Jennifer. I knew it was jumping to the Entry ID location name. I just must not have noticed the "jumping" on other sites, which is why it took me by surprise when I tested it.

I'll play with it some more, and let you know if I come up with anything "worthy".

=)

P.S. You might want to edit your comment – in came across fine in my email but the code sample got eaten and made a link out of the whole comment here on the page!

20 | Jennifer

July 16th, 2002 at 9:51 pm

Avatar

Fixed.
*yawn*
a sign I should go to bed! LOL! Didn't even follow my own instructions for watching those < >! Thanks for the heads up! :)

21 | Meredith

July 27th, 2002 at 11:51 am

Avatar

Wow, it worked perfectly on the first try. Thank you!

22 | maddy

July 28th, 2002 at 6:31 am

Avatar

It worked, easy as! Thanks!Now what other scripts do I "need"? 😉

23 | Donna

August 3rd, 2002 at 10:42 pm

Avatar

It worked beautifully – I just said thanks to Aaron (but I used your variable names, Jenn, so I'm saying thanks to you too.

24 | Promo

August 8th, 2002 at 5:23 pm

Avatar

How could this open/collapse tool be used on an include page? I have a long list of people who do the MM, but I would like it to be "hidden" in a collapse, just like the comments are.

So say I wanted to pull in this:
<?php include("phpdir/thisdir/thatpage.php"); ?&gt

and the full page is there, but collaped. Can that be done with this?

25 | Tina

August 12th, 2002 at 9:26 am

Avatar

Try as I may, I just can't get this code to work in any of its incarnations – it just wants to go to the individual entry page and nowhere else. In short, erm, help?!

26 | bmd

August 14th, 2002 at 5:20 am

Avatar

I'm having the same problem as Tina, namely that when I try to use this code to expand/collapse my comments, it simply loads the Individual archive page for the entry in question.

I'm sure it's not a browser issue since I can see this working on other pages.

I'm very confuzzled.

27 | Tina

August 14th, 2002 at 5:44 am

Avatar

Jen figured it out for me, and I'm a bit surprised I didn't think of it (I'm not that incompetent with cutting and pasting ;)), which I believe has now been fixed on this page – try cutting and pasting the part that goes between the <head> tags again. Worked for me this time around. :)

28 | Jennifer

August 14th, 2002 at 5:49 am

Avatar

After working with Tina I realized that people may not realize that the first part needs to go INSIDE <script> tags… I've since updated the script to avoid confusion… so look at the script again, and try it again…

29 | bmd

August 14th, 2002 at 10:58 am

Avatar

I'm fairly sure I had it in script tags, but I'm feeling adventurous so I'm going to try it again!

30 | bmd

August 14th, 2002 at 10:58 am

Avatar

I'm fairly sure I had it in script tags, but I'm feeling adventurous so I'm going to try it again!

31 | Tina

August 14th, 2002 at 11:10 am

Avatar

I wonder if it's possible to stick all the Javascript used on a site into one file and link to it, rather than having to paste it all directly into the <head> tags… or rather, I know it's possible, but what extension would I need? Just because my header files look so messy right now because of it. Yes, I'm a neat freak. 😉

32 | bmd

August 14th, 2002 at 11:16 am

Avatar

I have it working. Not sure why it wasn't working before, but I think it's fine now. Thank you for the script, and thank you for your help :)

33 | bmd

August 14th, 2002 at 12:16 pm

Avatar

Me again!

Sorry to keep bugging you, I have the code all up and running, but it doesn't seem to update until I do a rebuild. Is there a workaround for this? Obviously I might not rebuild every day and it would be good for people to be able to see all the comments all the time.

34 | bmd

August 14th, 2002 at 12:31 pm

Avatar

please, ignore me. It's been a long day, and I've figured out what was wrong.

I'm not going to say because it's so easy that it's embarrasing!

Back under the rock with me.

35 | theresa

August 21st, 2002 at 1:37 pm

Avatar

I used your code and it works great! Thanks so much for sharing :)

36 | Tina

August 24th, 2002 at 5:34 pm

Avatar

Howdy again. :) Just wondering, is there any way I can apply this to images on a navigation bar? I'm working on my theatre society's website right now, and it'd be a really handy feature to have a list of previous shows in image form drop down when the visitor clicks on the link (basically because I'm not using frames if at all possible). Ta very much so. :)

37 | David

August 27th, 2002 at 9:27 pm

Avatar

You so rock! That was almost too easy. Thank you so much.

38 | Jennifer

August 27th, 2002 at 10:08 pm

Avatar

P.S. To have this only display when there are in fact comments..

put this:
<?
if (<$MTEntryCommentCount$> > 0) {
?>

before the
<MTEntryIfAllowComments>
<span id="varP2<$MTEntryID$>" class="extended">….etc etc.

and then add
<? } ?>
at the end – AFTER the:
…..<p>« hide comments</p></a></div>
</MTEntryIfAllowComments>

39 | David

August 28th, 2002 at 1:47 am

Avatar

Jennifer – cool tip; thanks! One note to newbies/sleepies – Jennifer's tip requires that your web server supports php and that your template has an extension that the server is configured to recognize as a php file.

40 | Quadsk8

August 29th, 2002 at 3:27 pm

Avatar

Great tip Jennifer, that cleans up my main index a little.

Do you think that everybody understands that all additional and comments data needs to be loaded in the browser but is just not visible? (and slows things down when you have for example a lot of pictures in your additional entries)

For that reason I only make the 3 most recent entries expandable {MTEntries lastn="3"} and the rest (of my 15) as in the default template {MTEntries lastn="12" offset="3"}

41 | Jennifer

August 30th, 2002 at 11:23 pm

Avatar

Oooh! Excellent tip Quadsk8… Going to do that on my blog RIGHT now…(my blog is taking forever to load these days) :( I suspect that's the reason why…

42 | Carolyn

September 1st, 2002 at 4:06 am

Avatar

I implemented this trick a while back, and have been quite pleased with it. Unfortunately, I've made some changes to my site, and am now encountering problems. The collapse/hide part of the code now generates a 404 error message. I suspect this is connected to the addition of
<base href="http://www.koenighaus.net">
to my header info. What do I need to change to make things work right again? Thanks!
Carolyn

43 | Quadsk8

September 1st, 2002 at 2:03 pm

Avatar

Yes, that must be the reason!
(Is the King not at home?)
Why do you need this base-URL?

44 | Carolyn

September 1st, 2002 at 3:04 pm

Avatar

Well… the site is physically located at
http://www.koenighaus.net/indepundit,
but can also be accessed via
http://www.indepundit.com.
We changed the name server setup for indepundit.com this week (from a url-forwarding to direct access or whatever you call it). Now when you use indepundit.com, the browser looks at http://indepundit.com/filename for any relational filepaths listed. Since the files weren't loading that way, and I didn't want to manually change all the filepaths to absolute paths, I added the base-url. So far, the collapse/hide issue is the only problem I've found. Is there a better way to resolve the filepath issue, or a way to fix the MT code?

Thanks!
Carolyn Koenig

45 | Anonymous

September 1st, 2002 at 5:04 pm

Avatar

Well, you could try with the "Hide Comments" to make it link to href="<MTEntrylink>#<MTEntryId>" ?
(Because only href="#123" will now point to http://www.koenighaus.net/index.html#123 which does not exist)
Does that work?

46 | Quadsk8

September 1st, 2002 at 5:10 pm

Avatar

(That was me just now: sorry)
BTW there seems to be a lot of styling and Jacascript (moreover.com) in your body which officially should be in your head, doesn't this give any trouble?

47 | Carolyn

September 2nd, 2002 at 1:52 am

Avatar

Thanks for the tip. It didn't work, but did point me in the right direction. I added
href="/indepundit/<$MTEntrylink$>#<$MTEntryID pad="1"$>"
and that seemed to do the trick. I guess I just needed to point it to the right directory! Thanks for your help.

As for the styling and Javascript… it's probably where it is because I don't know any better… but hasn't caused any noticeable trouble. Would there be any advantage to moving it?

48 | Quadsk8

September 2nd, 2002 at 5:57 pm

Avatar

Well… it's just that it does not follow the rules, IE doesn't care much about the rules, so it will probably look good. But there are still a few non-IE users somewhere in the corners of our world wide web….
There are quite a few experts in the MT-community who could probably better explain all usability/accessibility/compatabilty issues than I can…

49 | randy

October 13th, 2002 at 12:34 am

Avatar

Hello. I've tried installing the codes as described at the top of the page. I put the first script coding after the chunk of code that begins with "<script language="javascript>…, and replaced the code for<MTEntryIfExtended> and <MTEntryIfAllowComments> .

I can't get it to work. Any post changes as follows: 1) the posting comment feature is lost, i.e., when you click on Show Comments Right Here, no facility to enter a new comment appears.

2) Instead of "read more>>" appearing, I get this: " read more ť"; when I click to expand, it changes to "Ť hide more".

3) Instead of "show comments right here>>" appearing, I get this: " show comments right here ť". It expands and at the bottom, I get: " Ť hide comments."

4. When I click on any Recent Entry, it simply expands and fills the entire page with that entry (same thing that happens when I click on "More" without any of this code).

I have no idea what's wrong (not being a scriptyanything!). If anyone has any idea or help, I'd appreciate it. I'd like to have the "more" and "comments" function work somewhat like this site: http://www.abstrusities.com/

50 | Jennifer

October 13th, 2002 at 7:31 am

Avatar

Someone else made this same mistake before so I'm putting it in red in the hopes that other people may see this comment before making the same mistake
for the comments expand collapse part: do NOT replace your existing code that brings people to the page or pop up that allows them to comment. this will only display the COMMENTS on the page, NOT the form

as for the other problems it sounds like you didn't put the code in right. Without seeing what you did (you took it off your page) I can't even begin to guess… Maybe set up a "test" page where you have it in place?

51 | Jennifer

October 13th, 2002 at 7:51 am

Avatar

Here is the code I'm using. I've included the MTBody tag for reference…

<$MTEntryBody$>

<MTEntryIfExtended>

<span id="varP<$MTEntryID$>"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMore(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;"><h3>read more »</h3></a><br /></span><div id="varXYZ<$MTEntryID$>" style="display: none"><p><$MTEntryMore$></p><a href="#<$MTEntryID pad="1"$>" onclick="showMore(<$MTEntryID$>,0);return
true;"><h3>« hide more</h3></a></div>
</MTEntryIfExtended>

<h4 align="right">posted at <$MTEntryDate format="%I:%M %p"$><MTEntryIfAllowPings>
|| <a href="<$MTCGIPath$>mt-tb.cgi?__mode=view&entry_id=<$MTEntryID$>" onclick="OpenTrackback(this.href); return false">trackback
(<$MTEntryTrackbackCount$>)</a>
</MTEntryIfAllowPings>

<script language=javascript>
document.write(' || <a href="<$MTEntryLink$>">permalink</a>');
</script>
<MTEntryIfAllowComments><script language=javascript>
<!–
document.write(' || <a href="<$MTEntryLink$>#comments">')
if (<$MTEntryCommentCount$> == 0)
{
document.write('speak up</a>')
} else if (<$MTEntryCommentCount$> == 1)
{
document.write('<$MTEntryCommentCount$> voice</a>')
} else if (<$MTEntryCommentCount$> > 1)
{
document.write('<$MTEntryCommentCount$> voices</a>')
}
//–>
</script>
</MTEntryIfAllowComments>

<?
if (<$MTEntryCommentCount$> > 0) {
?>

<br><MTEntryIfAllowComments>
<script language="javascript">
if (openit == "true") {
document.write('<span id="varP2<$MTEntryID$>" class="extended" style="display: none">');
} else {
document.write('<span id="varP2<$MTEntryID$>" class="extended" >');
}
</script>
<noscript>
<span id="varP2<$MTEntryID$>" class="extended">
</noscript>
<a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;">show comments right here »</h4></a><br /></span>
<script language="javascript">
if (openit == "true") {
document.write('<div id="varXYZ2<$MTEntryID$>">');
} else {
document.write('<div id="varXYZ2<$MTEntryID$>" style="display: none">');
}
</script>
<noscript>
<div id="varXYZ2<$MTEntryID$>" style="display: none">
</noscript>
<div style="background-color: #D4D4D4; layer-background-color: #D4D4D4; border: 2px none #D4D4D4; padding-left: 10px; padding-right: 10px;">
<h4 align="right"><a href="#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,0);return
true;">« hide comments</a></h4>
<MTComments>
<$MTCommentBody$>
<h4>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></h4><br /><br />
</MTComments>
<h4 align="right"><a href="#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,0);return
true;">« hide comments</a></h4></div>
</div>
</MTEntryIfAllowComments>
<?
} else {
echo "</h4>";
}
?>

52 | randy

October 13th, 2002 at 4:06 pm

Avatar

Jennifer: Thank you for your comments. Here's the continuing dilemma: I've set the code up on my regular site, and my test site. You can see them both here: http://podbaydoor.com and http://podbaydoor.com/test1.

What's driving me nuts is that as far as I can tell, the test site is working fine (almost – why do I have "MORE…" and "read more >>" at the same time?) I *think* I've input the code into the index files on both sites exactly the same way. But when you look at podbaydoor.com, it looks like poo, and doesn't work at all. I can't determine what I've done wrong.

I am not a code guy – I'm copying and pasting as best I can follow instructions. The code you are using seems to be much more detailed and extensive than the code posted at the top of the page.

Anyway, I'm leaving the two sites up with the code so you can check them if you have time. Thank you so much for helping. Randy

53 | Jennifer

October 13th, 2002 at 6:50 pm

Avatar

Randy – I think I figured out what you did… posted on it on your site (you commented out the javascript that makes the function work…)

54 | randy

October 13th, 2002 at 7:29 pm

Avatar

Thanks Jennifer. I removed those tags, and it still doesn't work. Neither does the general "More…" function for that matter. Rather than open up the entry further on the same page, and open up the comment feature, it moves me right to the archives instead. Can't figure it out. I'm sorry this is prolonging, and wish I could do something to make it work! 😐

55 | randy

October 15th, 2002 at 8:50 am

Avatar

Jennifer: I rebuilt the Main Index page from scratch, and now it is working. I don't know why, but I don't want to look the proverbial gift horse in the pie hole! Thanks for helping with this, much appreciated. And thanks for the code too.
-Randy

56 | Donna

October 20th, 2002 at 3:46 pm

Avatar

Just a note – I noticed a "wiggle" in the mouseover "read more"/"hide more" when using Netscape 6 – this made it difficult for readers to open and close the additional text. As pointed oout by GoddessKristine on the MT boards, Netscape may not like the extra p tags in the code – when I removed the p tags around the "read more" and "hide more" links, they displayed without a problem.

57 | Belle

November 7th, 2002 at 11:00 am

Avatar

I've inserted the code into my journal page and archives, but when I try to collapse the comments, I'm redirected to my home page, not my journal page. The home URL is http://www.proofchick.com and the journal is at http://www.proofchick.com/weblog. Could I be having problems because my journal is not my index.html file in the root directory?

59 | Jennifer

November 18th, 2002 at 11:02 am

Avatar

Belle, I'm suspicious that there may be some other javascript that's conflicting with this. It does seem to do the "close it up" – but then it does a "refresh" sort of and sends you to that index page… Is there any other javascript on there that you can try hiding and then testing this script? (I think I saw a counter.js file included there).

60 | Jennifer

November 18th, 2002 at 11:06 am

Avatar

Actually – I take it back.
Here's your problem:
<base href="http://www.proofchick.com/">

That means that any time anyone clicks – the "base" of the link will be assumed to be that URL – so when people click on the "hide more" link – they're going to that URL…

I'm guessing the reason why it works with the "open more" link is because the full path is specified in the href…otherwise it would be doing the same thing… (take that out and see what happens)

61 | Belle

November 18th, 2002 at 12:07 pm

Avatar

Thanks so much, Jennifer! I didn't want to take out the base href because I have a number of images liked to it, so I moved my image folder into the weblog directory and changed the base href to http://www.proofchick.com/weblog/. That seemed to do the trick.

You goddesses here are fabulous! Please keep up the good work.

62 | jane

January 14th, 2003 at 5:10 pm

Avatar

You guys are amazing! This works really well. Thanks!

63 | Eli

January 22nd, 2003 at 5:41 pm

Avatar

I know that you've had this code up for awhile now, but I just found it and was able to implement it into my site within minutes. You guys are awesome!

64 | Oscar

February 10th, 2003 at 4:34 pm

Avatar

I couldn't agree more! This is how things SHOULD be, and I am so very grateful not to have to have figured it out by myself. Thank you, thank you, thank you!!!

65 | Iki

April 11th, 2003 at 1:01 pm

Avatar

Thanks so much for the tip! Love it, and it worked right off the bat (minus the comments thing, not ready for that part yet!)

66 | Iki

April 11th, 2003 at 2:41 pm

Avatar

Something was freaking me out about this. The link for the "read more" or "hide more" stretches the entire width of the line – well beyond where the actual words stop.

If you go to the part in your template body where the "read more" or "hide more" is listed, you'll see that there is a paragraph break before the link ends. Same goes for the comments part – in the original script above, the paragraph breaks before the link ends.

It shows:

…read more »</p></a>

Wherever the text you're showing appears, switch the tags around so your link ends before the paragraph breaks. So you have

…read more »</a></p>

and the link won't stretch the width of the entry.

Aside from my freak factor, excellent script and thanks again!

67 | Intruder

May 2nd, 2003 at 8:55 pm

Avatar

Hey scriptygoddesses! I have a problem. When I put this:
<?
if (<$MTEntryCommentCount$< < 0) {
?<

on my site, it just says:
arse error: parse error, unexpected $ in path/to/file.php on line 811

btw, it displays the right pathname, i just dont wanna post it here.

68 | Intruder

May 2nd, 2003 at 9:20 pm

Avatar

That was supposed to be Parse error 😉 Bad typo! and another thing, I dont have acess to line 811.
Could any scriptygoddess email me to help me?

69 | Katia

May 6th, 2003 at 10:42 am

Avatar

THANKYOU for the MOST helpful script ever! I have a tendency to rant, so this is just brilliant :)

I've had this on a blog (www.neopetsinfo.com/tnc) for a week – with no issues at all, it's worked perfectly for me and the other people looking at it.

I got an email this morning from a Mac user :

I'm having a problem with your site. It's probably because I'm on a Mac. Okay… if I click on one of the "Read more »" links on the main page, the first one will always work for me and I can view the read more part. If I scroll down further to another entry with a "Read more »" link, it disappears (serious, it disappears and I can't see it) and I can't view the "Read more »" part.

Does anyone have a clue about this? is it just a Mac compatability problem?

70 | Donna

May 14th, 2003 at 9:25 am

Avatar

Katia, I use a Mac, and the "extended entries" code, and have no display problems; ask your friend what browser they use. Just leaving a note here for those interested in using this code on a site that validates – you can do it, but the MTEntryMore tag in the code above designed to be inserted in your Main Index template is wrapped in p tags – if you have line breaks turned on in MT, this causes duplicate paragraph tags to be inserted, and will keep your site from validating. Simply remove the P tags around MTEntryMore, and you should be all set. I've tested it out, and it appears to work fine.

71 | Katia

May 18th, 2003 at 6:44 am

Avatar

Cheers Donna, thanks for the confirmation that it should work on a Mac :) It looks like it may be her browser then :)

72 | Tim

May 27th, 2003 at 3:03 am

Avatar

I've been using this on my blogs for quite some tme now, but I am in need of something similar for another project. Is it possible to hide just some text in the link? So work it the same as the extended entry, but just hiding plain text instead.

73 | david

June 18th, 2003 at 10:54 am

Avatar

Thank you thank you thank you!!

74 | halla

July 10th, 2003 at 12:48 am

Avatar

I tried installing this, and it worked for a bit, but now it doesn't… any ideas? when I click on what should be the flyout, it brings me to my archive page instead of dropping down…

here is the stuff inside my script tag

function showMore(varA1, varB1){
var123 = ('varXYZ' + (varA1));
varABC = ('varP' + (varA1));
if( document.getElementById ) {
if( document.getElementById(var123).style.display ) {
if( varB1 != 0 ) {
document.getElementById(var123).style.display = "block";
document.getElementById(varABC).style.display = "none";
} else { document.getElementById(var123).style.display = "none";
document.getElementById(varABC).style.display = "block"; }
} else { location.href = varB1;
return true; }
} else { location.href = varB1;
return true; }
}

function showMoreComments(varA12, varB12){
var1232 = ('varXYZ2' + (varA12));
varABC2 = ('varP2' + (varA12));
if( document.getElementById ) {
if( document.getElementById(var1232).style.display ) {
if( varB12 != 0 ) {
document.getElementById(var1232).style.display = "block";
document.getElementById(varABC2).style.display = "none";
} else { document.getElementById(var1232).style.display = "none";
document.getElementById(varABC2).style.display = "block"; }
} else { location.href = varB12;
return true; }
} else { location.href = varB12;
return true; }
}

here is my if extended…

<MTEntryIfExtended>
<span id="varP<$MTEntryID$>"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMore(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;"><p>…but there's more »</p></a><br /></span><div id="varXYZ<$MTEntryID$>" style="display: none"><p><$MTEntryMore$></p><a href="#<$MTEntryID pad="1"$>" onclick="showMore(<$MTEntryID$>,0);return
true;"><p>« hide more</p></a></div>
</MTEntryIfExtended>

here is my mt entry if allow comments…

<MTEntryIfAllowComments>
<span id="varP2<$MTEntryID$>" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;"><p>what you said »</p></a><br /></span><div id="varXYZ2<$MTEntryID$>" style="display: none">
<MTComments>
<$MTCommentBody$>
<p>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></p><br /><br />
</MTComments>
<a href="#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,0);return
true;"><p>« hide comments</p></a></div>
</MTEntryIfAllowComments>

any idea what I'm doing wrong? this code should be up and available at http://sanctified.net/halla

75 | Arvind Satyanarayan

September 9th, 2003 at 1:56 am

Avatar

Umm where do i put that script, anywhere on the page ?

76 | Joe Siegler

September 9th, 2003 at 1:15 pm

Avatar

I've got this code installed on my blog, but am having some display issues with it. It "works", but it doesn't display correctly. I have two issues, I'll lay 'em out here:

1) When I click on the show comments link, and then close it, it's not restored to the same position it was before. It's in a nice lineup with the pings line, but then when restored, it just ends up underneath it. Is there any way to get it to line up again like it is before it's clicked on?

2) There's an odd character (Â) that's displayed in the links, and I can't figure out why.

While this problem does show up on my main blog page, the URL you should look at is this one:

http://blog.siegler.net/index2.php

Today I tried backing the code out, putting the stock stuff back in, and then putting this code in again, and these two issues are still here, so the one on the index2 (a test page) is more current than the template for the main page. The code is modified slightly, but only in the section where I added a variable that shows how many words are in the extended section of the entry.

Also, per the suggestions (hey, I read that first), here's the code that's generating this page:

http://blog.siegler.net/indexcode.txt

77 | halla

September 9th, 2003 at 4:28 pm

Avatar

joe,

the problem you describe with the funky a…in the place where it appears were you trying to display the double angle quote («»)? it (the collapsing thing) messes with your ascii display output so if you use the substitutions &171; and &187; it should work for you.

78 | Joe Siegler

September 10th, 2003 at 3:04 pm

Avatar

Well, I tried that, and it just printed the codes instead of the symbol (but not the goofy A character). I sort of cheated and just eliminated the symbol call totally, so it doesn't print that at all, but the "show comments" link not showing up where it was originally issue is still there. Got any ideas on that one?

79 | halla

September 10th, 2003 at 3:18 pm

Avatar

no idea what to tell you for that. I got it working on my site, and have no problems with it. If I had to guess I'd say that the css in the script is conflicting with some css in your layout.

80 | queenkv

October 10th, 2003 at 3:10 pm

Avatar

thank you! this script totally worked out for me!

81 | King of Fools

October 16th, 2003 at 12:01 pm

Avatar

Great script. I had seen this around and was trying to figure out how to do it. Should have looked here first, don't cha know!

82 | Renee

October 25th, 2003 at 6:33 pm

Avatar

This was so super easy to implement I got it to work in one shot. Thank you!

83 | annie

November 16th, 2003 at 5:09 pm

Avatar

Thanks for this! Anything that makes it simpler for my readers to comment is a big help

84 | amber

November 24th, 2003 at 4:38 pm

Avatar

Thanks so much for this script! It's a life-saver! I knew it could be done, but I just couldn't wrap my mind around how.

85 | Goldie

January 19th, 2004 at 6:25 pm

Avatar

Hi there,

I've tried installing this but it comes up with this error messgae each time I try to rebuild:

Build error in template 'Main Index': Error in tag: You used an 'MTEntryID' tag outside of the context of an entry; perhaps you mistakenly placed it outside of an 'MTEntries' container?

Any ideas?? Thanks so much!

86 | Goldie

January 19th, 2004 at 6:41 pm

Avatar

scarp that last comment – I didn't have my glasses on when I pasted ;).

Thanks so much, dear scripty goddess!

87 | DJ

February 14th, 2004 at 12:52 pm

Avatar

hey and thank you… just installed this *hack* and it worked straight away… no problems… woohoo… hte only change i made was to put the javascript in a seperate file and call it… just keeps my page slightly shorter :)

Thanks again and you rock

DJ

88 | Candice

March 19th, 2004 at 2:50 am

Avatar

I don't know how to get this script to work. Do I have to creat different pages for the result and the javascript and so on. WHere do I put all those codes? Like the header/ or the body? I copy and past these codes and upload it and still couldn't get it to work. I never use cgi so I don't know what to do. Can you please help me. Much is appreciated. Thanks

89 | xes

April 2nd, 2004 at 7:23 am

Avatar

hey great job!

I was just wondering could you convert the script to suit blogger or greymatter? 😀

90 | DJ

April 18th, 2004 at 4:10 pm

Avatar

LOL it's me again… yep on my old blog i had this working fine no isssues…

Now on my new blog i've got problems… A "?" mark after the "read more" and "show comments… " links. now i've had these before and it seems to be when FireFox finds an error in the code. but i have no clue what the error could be.

And also if i change to php so i can use the "show only if comments" code i get server 500 errors.

I've posted on my hosts forum to see if i can get help there but thought i'd give a heads up here as well

Thanks in advance for any and all help

DJ

91 | Jennifer

April 18th, 2004 at 4:17 pm

Avatar

There's a new version of this script here – using that one might help.

92 | DJ

April 18th, 2004 at 4:44 pm

Avatar

Thanx… again i have what i think is an error FireFox showing "?" 's but i'm gonna play tommorrow and see what i can do

Cheerz

DJ

93 | lindsey

May 25th, 2004 at 3:23 am

Avatar

I was wondering if you could put the post comment form inside the collapse, so after some tinkering, I pieced it together. It's kind of messy, but… I wanted to put it all in a box, but when I added another table it didn't really work. Also, I haven't figured out how to direct the page back to the index when you post a message… I also have the problem joe was talking about where the "show comment" line skips down after you re-collapse it. Here's the code, click my name to see it, and anyone with solutions or ideas to make it better feel free to comment!!

<MTEntryIfAllowComments>
{ <a href=mailto:[email protected]>lindsey</a> at
<a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>"><$MTEntryDate format="%I:%M %p"$></a> }
<$MTEntryCommentCount$> people love me!
<span id="varP2<$MTEntryID$>" class="extended"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');return false;">show love…</a><br /></span><div id="varXYZ2<$MTEntryID$>" style="display: none">
<MTComments>
<$MTCommentBody$>
<p>Posted by <$MTCommentAuthorLink$> at <$MTCommentDate$></p><br /><br />
</MTComments>
<div align=center>post a comment</div>
<form method="post" action="<$MTCGIPath$><$MTCommentScript$>" name="comments_form" onsubmit="if (this.bakecookie[0].checked) rememberMe(this)">
<table border=0 width=100%><tr><td align=center valign=top>
<input type="hidden" name="static" value="1" />
<input type="hidden" name="entry_id" value="<$MTEntryID$>" />
<br>
<input tabindex="1" id="author" name="author" size="25" maxlength="50" value="name" style="font-family: tahoma, verdana; color: #848484; font-size: 9pt; background-color: #ffffff; border: 1px solid #000000" />
<br>
<input tabindex="2" id="email" name="email" size="25" maxlength="50" value="e-mail" style="font-family: tahoma, verdana; color: #848484; font-size: 9pt; background-color: #ffffff; border: 1px solid #000000" />
<br>
<input tabindex="3" type="text" name="url" id="url" size="25" maxlength="50" value="url" style="font-family: tahoma, verdana; color: #848484; font-size: 9pt; background-color: #ffffff; border: 1px solid #000000" />
<br>
<font-size: 9pt>Remember Me?<br>
<input type="radio" id="remember" onClick="rememberMe(this.form)" name="bakecookie" /><label for="remember">Yes</label><input type="radio" id="forget" name="bakecookie" onclick="forgetMe(this.form)" value="Forget Info" style="margin-left: 15px;" /><label for="forget">No</label><br style="clear: both;" /></font>
</td><td align=center valign=top>
<MTIfAllowCommentHTML>
(you may use HTML tags for style)</MTIfAllowCommentHTML>
<textarea tabindex="4" id="text" name="text" rows="10" cols="50" style="font-family: tahoma, verdana; color: #848484; font-size: 9pt; background-color: #ffffff; border: 1px solid #000000"></textarea>
<br>
<div align="center">
<input type="submit" name="preview" tabindex="5"
value=" preview " style="font-family: tahoma, verdana; color: #848484; font-size: 9pt; background-color: #ffffff; border: 1px solid #000000" />
<input style="font-weight: bold;" type="submit" name="post"
tabindex="6" value="post " style="font-family: tahoma, verdana; color: #848484; font-size: 9pt; background-color: #ffffff; border: 1px solid #000000" /></div>
</td></tr></table>
</form>
<a href="#<$MTEntryID pad="1"$>" onclick="showMoreComments(<$MTEntryID$>,0);return
true;"><p>…hide love</a></p></div>
</MTEntryIfAllowComments>

94 | Jennifer

May 25th, 2004 at 8:00 am

Avatar

I'm leaving this post up here for archiving purposes – but there is a new version of this script here. Please use that one.

95 | VeggieChica

May 27th, 2004 at 11:11 pm

Avatar

I was wondering if you could convert this to BLOGGER? THanks

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