Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Blogger Help

  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Blogger Help

    I have added a Read more feature to my blog. (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?

    Code:
    <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>
    Code:
    <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>

    Code:
    <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

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    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-ele...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
    Code:
      
          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;
       
          }

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by TinyScript View Post
    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-ele...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
    Code:
      
          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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •