In Movable Type, extended entries are used to provide flexibility in the display of a post. The best example is hiding a portion of a very long post. This remainder of this post (the extended part!) explains how to configure MT templates to employ extended entries that expand and collapse the text on the index page itself instead of moving to the individual post page.
When I was developing my MT templates, I was not concerned at all about the extended entry part of the template. This was because I had already decided that I was never going to use it anyways. My logic was assuming that most people would not bother to click to read the rest of the post. I was also not satisfied with the way the extended link worked. In the standard template, it takes the user away from the index page and to the individual post. This is disruptive when the user is trying to catch up on all latest posts.
I changed my mind for two reasons. First, I often write long posts and understand that every post will not interest every reader. I would rather have a reader skim the first two paragraphs of several posts and end up spending more time here then have him get bogged down in a very long post and quit the site. Second, I have noticed that many sites have extended entries which expand and collapse instantly, without leaving the page. There are many sites that do this, but first place I noticed it was at Winds of Change.
Before I explain how to modify your template to do this, I have to give credit where credit is due. The javascript is from the amazingly useful Scriptygoddess, more specifically in this post. I'm just trying to provide a very clear installation explaination for it (plus one additional step which was not mentioned there).
Implementing expandable extended posts into your index template involves three simple steps:
Step 1: Adding the Javascript
In your index template, the following script needs to be inserted above the </head> tag:
<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;
}
}
</script>
Step 2: Modifying the Extended Display Section
Find the <$MTEntries$> tag in the template. At some point below that there should be something similar to:<MTEntryIfExtended> <span class="extended"> <a href="<$MTEntryPermalink$>#more"> Continue reading "<$MTEntryTitle$>" </a></span><br /> </MTEntryIfExtended>
<!-- ENTRY EXTENDED BODY -->
<MTEntryIfExtended>
<span id="varP<$MTEntryID$>">
<p><a href="#<$MTEntryID pad="1"$>"
onclick="showMore(<$MTEntryID$>,'<$MTEntryLink$>#<$MTEntryID pad="1"$>');
return false;">Show me the rest</p></a><br />
</span>
<div id="varXYZ<$MTEntryID$>" style="display: none">
<p><$MTEntryMore$></p>
<p><a href="#<$MTEntryID pad="1"$>"
onclick="showMore(<$MTEntryID$>,0);return true;">
Ok, I've seen enough</p></a>
</div>
</MTEntryIfExtended>
Step 3: Add an Anchor to the Start of Each Post
Find the <$MTEntryTitle$> tag. Immediately prior to this tag, add the following line:<a name="<$MTEntryID pad="1"$>"></a>
UPDATE: If you are using the BASE tag to set the default target to "_blank" (forcing all links to open in a new window), the collapse link anchor must also have the following:
target="_self"
Thanks. The expanded entry function seems to be working.
Hey big thanks for this useful mod!
Most excellent King. This code rules.
abm
Glad you found it helpful!
I agree, great stuff, thanks!
Hey brilliant idea but one question… I am at a lost to find out how to tell it turn on or better put how many words or lines to cut off the text and have the link. help please
It is not automatic. You divide your post into the body and extended sections and then the body part appears with the extended part hidden.
Alternatively, you could modify the template so that it used the excerpt instead of the body and then when you pressed the more arrow, it would hide the excerpt and display the body section (which contained the entire post). In MT you can configure the number of words in your excerpt section.




http://king-of-fools.com/blog/trackback/173/Uk04mmHZ/
I've been looking all over for the code that makes extended MT entries sort of open and close within the page (like on Nicole Lee's blog, where I first noticed it). I finally found the way to do it here....
This is a test to see if my recent addition of the javascript I found here will work to expand and collapse a long entry without the reader leaving the page....