If you have a blog on blogger platform surely you have wondered how to make the post appear on the home as a brief preview and a button "Read more ...", how to insert a short summary on the home page. After trying unsuccessfully several scripts found on the net, finally I found one that works, and I agree with you. The original source is in English and includes a erratas; I or translated by entering the correct code.
Here's how to install:
Revenue in blogger with your account and go to Design> Edit HTML in your Dashboard and check the "Expand Widget Templates."
For safety make a backup of your template before modifying it.
find the closing tag \u0026lt;/ head> and copy the following lines of code immediately before it (to find a line of code in the browser, type Control + F).
For safety make a backup of your template before modifying it.
find the closing tag \u0026lt;/ head> and copy the following lines of code immediately before it (to find a line of code in the browser, type Control + F).
\u0026lt;script type='text/javascript'> thumbnail_mode var = "no-float";
summary_noimg = 430;
summary_img = 340;
img_thumb_height = 100;
img_thumb_width = 120;
\u0026lt;/ Script>
\u0026lt;script type='text/javascript'>
//\u0026lt;![ CDATA [
function removeHtmlTag (strx, chop) {
if (strx.indexOf (" \u0026lt;")!=- 1)
{
was s = strx.split ("\u0026lt;");
for (var i = 0; i \u0026lt;s.length; i + +) {
if (s [i]. indexOf (">")!=- 1) {
s [i] = s [i]. substring (s [i]. indexOf (">")+ 1, s [i] . length);}
}
strx = s.join ("");
}
= chop (chop \u0026lt;strx.length-1)? chop: strx.length-2;
while (strx.charAt (chop-a): = '' & & strx.indexOf ('', chop)! =- 1) chop + +;
strx = strx. substring (0, chop-1);
return strx +'...';
}
function createSummaryAndThumb (PID) {
was div = document.getElementById (pid);
was imgtag = " ";
was img = div.getElementsByTagName (" img ");
was sum = summary_noimg;
if (img.length> = 1) {
imgtag = '\u0026lt;span style =" float: left; padding: 0px 10px 5px 0px; "> \u0026lt;img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/> \u0026lt;/ span> ';
Summ = summary_img;}
var summary = imgtag +' \u0026lt;div> '+ removeHtmlTag (div.innerHTML, Summ) +' \u0026lt;/ div> ';
div. innerHTML = summary;}
//]]> \u0026lt;/ script>
be noted that the previous code we can change blow up the image to display changing these values:
img_thumb_height = 100;
img_thumb_width = 120;
\u0026lt;data:post.body/> Now find the code in your template and replace with the following code:
\u0026lt;b:if cond='data:blog.pageType == "static_page"'> \u0026lt;br/>
\u0026lt;data:post.body/>
\u0026lt;b:else/>
\u0026lt;b:if cond='data:blog.pageType != "item"'>
\u0026lt;div expr:id='"summary" data:post.id'> \u0026lt;data:post.body/> + \u0026lt;/ div> \u0026lt;script type='text/javascript'>
; createSummaryAndThumb ("summary \u0026lt;data:post.id/>");
\u0026lt;/ script> \u0026lt;span class='rmlink' style='float:right;padding-top:20px;'> \u0026lt; a expr: href = "data: post.url"> Read more .. \u0026lt;/ a> \u0026lt;/ span>
\u0026lt;/ b: if>
\u0026lt;b: if cond = 'data : blog.pageType == "Item" '> \u0026lt;data:post.body/> \u0026lt;/ b: if>
\u0026lt;/ b: if>
Done! Now click on preview and then save.
Obviously if you change the model you have to start all over again.
Credits: www.anshuldudeja.com
0 comments:
Post a Comment