1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[GET] Link to this post script

Discussion in 'Blogging' started by almir, Sep 22, 2008.

  1. almir

    almir Power Member

    Joined:
    Jul 11, 2008
    Messages:
    728
    Likes Received:
    229
    Hi !

    I asked for this on programming, but forced a friend to make me one, so here it is, if someone needs it.

    This script will add - Link to this post + html code with post link and anchor text code. Right now the anchor will be Title of post + title of the site. I couldn't managed it myself to be only post title, but I guess this friend would fix that today, so I will update a thread if he is.

    Code have to be added in your template below the <p><data:xpost.body/></p> ( remove x) part if you want it to be below post body.. I think you first have to enable adsense between posts to make this work ( you can delete that adsense code manually from the template, but you have to enable it first )

    Here is the code :

    Code:
    Link to this post:
    <p><b:if cond='data:blog.pageType == "item"'>
    <b:if cond='data:post.includeAd'>
    <textarea id="linkNaPost" cols="35" rows="1" class="bginput" onClick="this.focus();this.select()">
    </textarea>
    <script language="javascript">
      var mjesto=document.getElementById("linkNaPost");
      // dirty hack jer ne znam dovoljno javascripta
      var jedanDiv = document.createElement('div');
      var noviAnchor = document.createElement('a'); 
      noviAnchor.href = document.URL; 
      noviAnchor.name = noviAnchor.innerHTML = document.title;  
      jedanDiv.appendChild(noviAnchor); 
      mjesto.value = jedanDiv.innerHTML;
    </script>
    </b:if>
    </b:if>
    
    You can add your own CSS to make it fit your page

    If you can fix it to show only post title, without blog title, post here please. I tried but I couldn't do it.

    Actually, this <datax:xpost.title/> ( without x ) should be on the place of = document.title; but I don't know how to make it to work.
     
    • Thanks Thanks x 1
    Last edited: Sep 22, 2008
  2. PitBoss

    PitBoss Junior Member

    Joined:
    Feb 29, 2008
    Messages:
    125
    Likes Received:
    921
    Occupation:
    Professional money collector
    Location:
    Great American SouthWest
    Just so that I'm clear on this, you'd use this on a blog site, or on any site where you have "posts"? How is this different than the permanent link created with each post in Wordpress?
     
  3. almir

    almir Power Member

    Joined:
    Jul 11, 2008
    Messages:
    728
    Likes Received:
    229
    No, this is for Blogger, but I guess you can add it to any page because it uses pages url and title

    Its just a way to "force" someone who would potentially link to your post to use anchor of your post, for SEO reasons
     
    Last edited: Sep 22, 2008
  4. PitBoss

    PitBoss Junior Member

    Joined:
    Feb 29, 2008
    Messages:
    125
    Likes Received:
    921
    Occupation:
    Professional money collector
    Location:
    Great American SouthWest
    Ok, I think I get it now. I'm not a code boy, so it takes me a bit to understand how this stuff works and what it affects. ;)
     
  5. almir

    almir Power Member

    Joined:
    Jul 11, 2008
    Messages:
    728
    Likes Received:
    229
    I forgot to note, if you would use it on a non-blogger page, than delete those "if" parts
     
  6. PitBoss

    PitBoss Junior Member

    Joined:
    Feb 29, 2008
    Messages:
    125
    Likes Received:
    921
    Occupation:
    Professional money collector
    Location:
    Great American SouthWest
    Ah, that's good to know as I'm switching my main site to wordpress.