scriptygoddess

14 Mar, 2003

show/hide comments or extended entries (only for x number of entries)

Posted by: Jennifer In: Scripts

This was insipired by Quadsk8's comment here. I've actually been using this script for awhile on my personal blog, but realized I never posted the script here when GeekGrrl mentioned a longer download time on her pages when she added the show/hide script. Quadsk8 had originally suggested doing this using only MT tags – but I prefer to do it with php. I explain why at the very bottom of this post…

(note: this script requires your being able to use PHP on your page)

First go here and follow the instructions for adding the show/hide comments or extended entries.

Now somewhere on the top of your page, add this (changing the red/bold number as appropriate):

<?
$showcommentmax = 6;
$currentshowcomment = 0;
$showextendedmax = 3;
$currentshowextended = 0;
?>

For the comments block:
Before the block that shows/hides your comments put this:

<?
if ($showcommentmax > $currentshowcomment) {
/*
this next line will make it so that it only displays the show/hide comment option IF there are actually comments
*/
if (<$MTEntryCommentCount$> > 0) {
?>

After that block add this:

<?
$currentshowcomment++;
// only counting show comment if it there are comments to show
}
}
?>

For the extended entries block:
Do kind of the same thing for the extended entries except a slight modification.

Find the block that shows/hides your extended entries, directly after the <MTEntryIfExtended> put this:

<?
if ($showextendedmax > $currentshowextended) {

After that block, but before the </MTEntryIfExtended> add this:

<?
$currentshowextended++;
}
?>

Now, the reason why I prefer the PHP method over the strictly MT tag method:
1) I like to have a full 7 days worth of posts on my blog. It's what I like to see on other blogs (sometimes I'll only have time to visit once a week – and it's nice to have it all on one page, where I won't have to hunt for the earliest entries). If you do it with mt tags, you only get x number of entries on the page – it's not day sensitive. So if you have a busy week – some of those entries from earlier in the week may fall off the main page.

2) I have a lot of code – with all my restricted entries, drop down comments, drop down extended entries, etc. – using the mt tag method requires me to have basically two copies of my main content – one for the first x number entries, and another for the remaining x number of entries. This became a real pain to maintain.

However, if you don't have PHP – I guess the MT tag method is better than nothing. :)

1 Response to "show/hide comments or extended entries (only for x number of entries)"

1 | GeekGrrl

March 14th, 2003 at 4:16 pm

Avatar

Thank you! Thank you! 😉

I cut down on the amount of entries on my main page, because I tend to blog about 5-7 times a day, but I really don't want to do less than that. So, if this can help keep it fairly speedy, with about 21 entries on the main page, it would be really cool! 😀

I can't wait to try it this weekend. :)

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