html - 'data:post-snippet' truncation in blogger -
let's wrote post on blogger: abc def ghi <div class="pls-exclude-from-snippet">jkl mno pqr stu vwxyz</div>
instead of listing z, want blogger set data:post.snippet 'abc def ghi' (letting blogger know stop if reads token: div class 'pls-exclude-from-snippet'). how do that?
i found here https://productforums.google.com/forum/#!topic/blogger/x9lxrjxnb2s
still have tweak little, works. think gonna post people similar problem had.
here's code. before </head>
, add:
<script type='text/javascript'> //<![cdata[ function stopiffound(strx,token){ var thelocation = strx.indexof(token); if(thelocation!=-1){ strx = strx.substr(0,thelocation); } return strx; } function removehtmltag(strx, chop){ strx = stopiffound(strx,'<div class="pls-exclude-from-snippet">'); if(strx.indexof("<")!=-1){ var snippet = strx.split("<"); for(var i=0;i<snippet.length;i++){ if(snippet[i].indexof(">")!=-1){ snippet[i] = snippet[i].substring(snippet[i].indexof(">")+1,snippet[i].length); } } strx = snippet.join(""); } chop = (chop < strx.length-1) ? chop : strx.length-2; while(strx.charat(chop-1)!=' ' && strx.indexof(' ',chop)!=-1) chop++; strx = strx.substring(0,chop-1); return strx+'...'; } function createsnippet(pid){ var div = document.getelementbyid(pid); var summ = snippet_count; var summary = '<div class="snippets">' + removehtmltag(div.innerhtml,summ) + '</div>'; div.innerhtml = summary; } //]]> </script>
find <data:post.snippet/>
, in
<div class='post-body'> <b:if cond='data:post.snippet'> <data:post.snippet/> </b:if> </div>
replace with
<div expr:id='"summary" + data:post.id'><data:post.body/></div> <script type='text/javascript'>createsnippet("summary<data:post.id/>"); </script>
Comments
Post a Comment