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 <: and > to >. Not to mention typing &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
0 comments
0 Comments:
Post a Comment
Links to this post: