...

View Full Version : Blogger Help



TheChuckKnoblog
03-30-2009, 04:43 AM
I have added a Read more feature to my blog (http://thechuckknoblog.com). (click read more and full post comes up). I do not want it on every single post I only want it on the ones that I enter.

Here is the code that I added to get it working can anyone tell me how I can alter it so that it only appears on the posts that I want?


<b:if cond='data:blog.pageType != &quot;item&quot;'>
<script type='text/javascript'>

var fade = false;
function showFull(id) {
var post = document.getElementById(id);
var spans = post.getElementsByTagName('span');
for (var i = 0; i &lt; spans.length; i++) {
if (spans[i].id == &quot;fullpost&quot;) {
if (fade) {
spans[i].style.background = peekaboo_bgcolor;
Effect.Appear(spans[i]);
} else spans[i].style.display = 'inline';
}
if (spans[i].id == &quot;showlink&quot;)
spans[i].style.display = 'none';
if (spans[i].id == &quot;hidelink&quot;)
spans[i].style.display = 'inline';
}
}


function hideFull(id) {
var post = document.getElementById(id);
var spans = post.getElementsByTagName('span');
for (var i = 0; i &lt; spans.length; i++) {
if (spans[i].id == &quot;fullpost&quot;) {
if (fade) {
spans[i].style.background = peekaboo_bgcolor;
Effect.Fade(spans[i]);
} else spans[i].style.display = 'none';
}
if (spans[i].id == &quot;showlink&quot;)
spans[i].style.display = 'inline';
if (spans[i].id == &quot;hidelink&quot;)
spans[i].style.display = 'none';
}
post.scrollIntoView(true);
}

function checkFull(id) {
var post = document.getElementById(id);
var spans = post.getElementsByTagName('span');
var found = 0;
for (var i = 0; i &lt; spans.length; i++) {
if (spans[i].id == &quot;fullpost&quot;) {
spans[i].style.display = 'none';
found = 1;
}
if ((spans[i].id == &quot;showlink&quot;) &amp;&amp; (found == 0))
spans[i].style.display = 'none';
}
}

</script>
</b:if>




<b:if cond='data:blog.pageType == &quot;item&quot;'>
<style>.fullpost{display:inline;}</style>
<p><data:post.body/></p>
<b:else/>
<style>.fullpost{display:none;}</style>



<b:if cond='data:blog.pageType != &quot;item&quot;'><br/>
<a expr:href='data:post.url'>Full Post</a>
</b:if>
</b:if>

Any help? It is really bugging me :mad::mad::mad::mad::mad::mad::mad:

TinyScript
03-30-2009, 07:46 AM
Do you have a way to differentiate between the posts you deem important and those you do not? I would suggest creating a class that is for the important posts(like class="important") then get all the span tags with an important class

I found this code using google
http://snipplr.com/view/1696/get-elements-by-class-name/

I would think this might be what you want to do in the showfull() function

var spans = getElementsByClassName(important, span);

the code below needs to be in the script but not contained in the other functions
I don't know if this will work. I didn't test it, but it seems clear. spans, the array, holds all the spans that get the full post added. so then let's tell it to only grab what's important



function getElementsByClassName(classname, node) {

if(!node) node = document.getElementsByTagName("body")[0];

var a = [];

var re = new RegExp('\\b' + classname + '\\b');

var els = node.getElementsByTagName("*");

for(var i=0,j=els.length; i<j; i++)

if(re.test(els[i].className))a.push(els[i]);

return a;

}

TheChuckKnoblog
04-01-2009, 03:20 AM
Do you have a way to differentiate between the posts you deem important and those you do not? I would suggest creating a class that is for the important posts(like class="important") then get all the span tags with an important class

I found this code using google
http://snipplr.com/view/1696/get-elements-by-class-name/

I would think this might be what you want to do in the showfull() function

var spans = getElementsByClassName(important, span);

the code below needs to be in the script but not contained in the other functions
I don't know if this will work. I didn't test it, but it seems clear. spans, the array, holds all the spans that get the full post added. so then let's tell it to only grab what's important



function getElementsByClassName(classname, node) {

if(!node) node = document.getElementsByTagName("body")[0];

var a = [];

var re = new RegExp('\\b' + classname + '\\b');

var els = node.getElementsByTagName("*");

for(var i=0,j=els.length; i<j; i++)

if(re.test(els[i].className))a.push(els[i]);

return a;

}


Hmmm I am still very new to this.

I understand what you are saying (differentiating posts) but I need a little bit of help on how to do this. Where do I add the code?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum