Welcome-! If you want to exchange link, please simply add my link on your blog/website then leave message in chat box at the bottom of the page... Thank you-Happy reading~~

Tuesday, October 26

Widgets

"Read More" and COLLAPSE full post in same page

Have you tried to put "Read More" and open full post page ? Want to try another one?
This "collapse" trick will open your full post in the same page (with a nice effect), without go to the single post page. This tricks will put "Read more" in every post you made automatically (including older posts). You can't choose how long is your post introduction. Nice but also has disadvantages. It's up to you....

First, like what we did before, Back-up your template just for in case..
DASHBOARD ► LAYOUT ► EDIT HTML ► click on the EXPAND WIDGET TEMPLATES in the upper right corner.

Using CTRL (Option) + F, find the following line of code:

</head>

Place this following code before that part, become like this:
<script language='javascript' src='http://halotemplates.s3.amazonaws.com/jquery-truncator/jquery-1.2.3.pack.js' type='text/javascript'/><script language='javascript' src='http://halotemplates.s3.amazonaws.com/jquery-truncator/jquery.expander.js' type='text/javascript'/><script type='text/javascript'>$(document).ready(function() {$('.excerpt').expander({slicePoint: 280, // default is 100expandText: '[...]', // default is 'read more...'});

});</script>
</head>

Then, find this part of code (it may look a bit different in your template):
<div class='post-body entry-content'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>

Ok, next... delete those code and REPLACE it with these code :
<b:if cond='data:blog.pageType != "item"'>
<div class='excerpt post-body entry-content'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
<b:else/>
<div class='post-body entry-content'>
<data:post.body/>
<div style='clear: both;'/> <!-- clear for photos floats -->
</div>
</b:if>

Save your template....

Note :
  • the code slicePoint: 280 shows the length of your post introduction. You can decrease or increase the number to make it shorter or longer)
  • the code expandText: '[...]' is code for the text "Read more" in your posts. You can change [...] to read more, see full post, continue reading, etc
  • if you can't find 'post-body entry-content', maybe it written as 'post-body'

4 comments:

darkhunter said...

ah, it's a very nice info..

um.. but i wonder if i can decide when to expand text not from slice point.

Because every posts have different length. And it can be messed up when i give expand text.

Thank you.

Amelia said...

@darkhunter : Ah yes :) that's what I thought also before implement this code.. But finally I put this "collapse" code because I'm kindo lazy to put it manualy :p

Property said...

thanks for useful article

Amelia said...

@property : You're welcome :)

Post a Comment

Chat with me

Creative Commons License Copyright licensed by :Creative Commons Attribution 3.0 Unported License. We allow people to copy and distribute our work provided they give us credit - URL backlink to the article or to the our homepage,http://share-everythings.blogspot.com.
Twitter Delicious Facebook Digg Stumbleupon Favorites More