.:∴ Archives ∴:.
Tierra Verde

Friday, November 28

Spoilerage works with PHP!  


Here's how to do it.

You must instert this:
.commenthidden {display:none;}
.commentshown {display:inline;}

into your CSS (I have a CSS file I put it in).

The in the beginning of your template or included in the beginning of the template (which is what I do) put this Javascript code:

lt;script type="text/Javascript">
function togglecomments (postid) {
var whichpost = document.getElementById(postid);
if (whichpost.className=="commentshown") { whichpost.className="commenthidden"; } else { whichpost.className="commentshown"; }
} </script>


And then include either directly in the template or included after the Javascript:

<?php
function spoiler($id, $anchor, $hiddentext) {
echo '<a aiotitle="click to expand" href="javascript:togglecomments('.chr(39).$id.chr(39).')">'.$anchor.'</a>';
echo '<div class="commenthidden" id="'.$id.'">';
echo $hiddentext;
echo '</div>';
}
?>


Then you can call it with <php spoiler("uniqIDthatIwillcalculatenextver","what you want to say that needs to be clicked to show the spoiler","what the spoiler you want to tell is"); >

That's basically the post below this one.

Don't ask how long it took to get this post to give more than a blank page. I did a quicky install of Google Code prettify.js and .css. Only to find out that I still needed to change < to &lt: and > to &gt;. Not to mention typing &amp;lt; to show you that. And I'm not even happy about how it looks prettified. Oh well. It works. I'll leave it alone.

Permanent link posted by bytehead @ 11/28/2008 12:31:00 AM   Edit this entry 0 comments Links to this post

0 Comments:

Post a Comment

Links to this post:

Create a Link

 

Article Index

Spoilerage works with PHP!
Copyright © 2003-2009, Bryan Price. Licensed by Creative Commons License: Creative Commons License
Home| This page| Colophon| Disclaimer| Privacy Statement