« Home | Anger: NOW PEOPLE » | Greed: Vote! » | Envy: More Cindy Fun » | Anger: Iran » | Pride: Inline Trackbacks » | Envy: Sheehan's Takeover » | Pride: DO IT! » | Sloth: How Effin American? » | Pride: Thinkin » | Envy: Hillbilly Update » 

Tuesday, January 31, 2006 

Pride: Blogger Hack Primer

The extended entry contains the promised primer on the 2 Blogger hacks I have made. Inline Trackbacks and Extended Entry sections.
Toggle Haxorz

<!-- Place this javascript code block in your template header (<head></head>) section -->
<script language="javascript" type="text/javascript">
// This includes an external javascript source
// I find it easier than building the string every time
function include(script_filename) {
     document.write('<' + 'script');
     document.write(' language="javascript"');
     document.write(' type="text/javascript"');
     document.write(' src="' + script_filename + '">');
     document.write('</' + 'script' + '>');
}

// This function toggles the visiablity of the passed element
function hider(elementName) {
     var control;

     control = document.getElementById(elementName);
     if(control.style.display == 'none' || control.style.display == "")
     {
          control.style.display = 'inline';
     }
     else
     {
          control.style.display = 'none';
     }
}

// This counts the number of trackbacks in post "id"
// Shamelessly ripped from Basil's tutorial
function TBCount(id){
    var hs_search = new RegExp('\\W','gi');
    var hs_id = id.replace(hs_search,"_");
    id = hs_id;
    var rtrnVal=0;
    if (hstb[id]) {
        var rtrnVal=hstb[id];
    }
    return rtrnVal;
}
</script>

<!-- Place this in your template's style section. (inside the head section) -->
<!-- If you don't have a style section, use the style tags as shown -->
<style>
<MainOrArchivePage>
span.fullpost {display:none;}
</MainOrArchivePage>
<ItemPage>
span.fullpost {display:inline;}
</ItemPage>
</style>
</head>

<body>

<!-- Your Blogger template. Inside the post code -->

<!-- This puts a direct pointer to the trackback ping location in your post -->
<!-- This is totally optional and can easily be modifed. -->
<!-- Put it in the post code where you want it to appear -->
<a href="http://haloscan.com/tb/sinsblog/<$BlogItemNumber$>">Trackback URI</a>

<!-- Place this javascript in your template where you want trackbacks to appear -->
<script type="text/javascript">
<!--
// This shows the trackbacks if there are any to show
// it uses a service to translate XML (RSS) to javascript
// The service main page can be found here: http://itde.vccs.edu/rss2js
id="<$BlogItemNumber$>";
var TBNum=TBCount(id);
if (TBNum) {
    document.write("Trackbacks:<br>");
    document.write("<ul>");
    include("http://itde.vccs.edu/rss2js/feed2js.php?src=http://haloscan.com/tb/sinsblog/<$BlogItemNumber$>?__mode=rss&chan=n&num=0&desc=0&date=n&targ=y");
    document.write("</ul>");
}
// -->
</script>

<!-- This is an example of how to make an extended entry -->
<!-- The "hider" javascript function must be defined -->
<!-- the stuff you want initially hidden is in the "span" tag -->
<!-- IMPORTANT: Use a different "id" for every entry or they will be toggled together -->
<!-- Put this in your POST, not your TEMPLATE -->
<a href="javascript:hider('extEntry');">Toggle Extended Entry</a>
<span id="extEntry" class="fullpost">
Here is the extended entry text.
This will be hidden on the main page or archive pages and shown
on individual item pages by default due to the style "fullpost"
The link will toggle visibility.
</span>

<!-- FIN -->


If you rather download an HTML file instead of cut-n-paste, Click Here.

If you use this, please trackback to this post. If you have problems, please use the comments on this post so everyone can benefit.

Update: It turns out there is a small bug in the process. Here is the explaination from the guy who found it.
Turns out if someone trackbacks with accents over the
letters, say for a foreign language, it screws up the
feed.

I manually edited the haloscan entry and it works now.
You might want to pass that along on your blog in case
some get foreign language readers.
Thanks Mark! I hope to figure out a fix, but until then maybe this will help someone not pull their remaining hair from their skull.

| | Trackback URI

Blog Info

Praise for The 7 Deadly Sins


"I have to admit that you do sloth like nobody's business."
- tee bee
"omg...you're even nerdier than my bf. That's hawt."
- trouble
"Not everybody remembers the glow of green text on black monitor with fondness"
- cathyf
"That's just crazy talk"
- tee bee
"Holy crap! Where's the ACLU pukes this time?"
- justanothermngirl
"Quick, edit these before anyone sees them!"
- Chris
"See? Getting old isn't all bad."
- David
"THIS IS GOOD, SPREAD THE WORD."
- RICHARD
"Best wishes to my Blog Brother."
- Retired Geezer
"Congratulations to one sinner from another."
- basil
"I just sic them on punks like that like a couple of pitbulls."
- digitalbrownshirt
"I hate to say anything negative about someone I've never met (OK, that's a lie), but that guy is a $#@*& idiot."
- John from WuzzaDem

Video Game Voters Network

My Blogfather

Feed The Sins



Weblog Commenting and Trackback by HaloScan.com

Open Trackback Alliance

Open Trackback Alliance


101st Fighting
Keyboarders



Powered by Blogger and Blogger Templates
Listed on BlogShares



Top100 Bloggers
Top 100