[Plugin: WP Super Cache] Help with Javascript for dynamic content
-
Hi
I’ve read the comments on using javascript to call random dynamic content. I searched Google for solutions like a random image rotator. I found one on codelifter.com that appeared pretty straightforward… I thought I could simply switch out a text quotation for a php include statement. But alas, the routine barfs on the <?php part. I’ve tried escaping, stringing, \’ing, to no avail.
I am trying to dynamically show 1 of 4 sidebar blocks at random. Using a “We have nothing to fear but fear itself.” type quote this routine works fine. It does not like the beginning php statement code.
Could I ask for tips, suggestions, another approach to accomplish a random block in javascript so WP Super Cache won’t cache it?
Thanks in advance for looking at this.
-Boots
<div class="random sidebar_block"> <!-- Randomly selecting which block to show --> <script language="JavaScript"> // ============================================== // Copyright 2004 by CodeLifter.com // Free for all; but please leave in this header. // ============================================== var Quotation=new Array() // do not change this! // Set up the quotations to be shown, below. // To add more quotations, continue with the // pattern, adding to the array. Remember // to increment the Quotation[x] index! Quotation[0] = "<?php include("sidebar_block1.php") ?> "; Quotation[1] = "<?php include("sidebar_block2.php") ?> "; Quotation[2] = "<?php include("sidebar_block3.php") ?> "; Quotation[3] = "<?php include("sidebar_block4.php") ?> "; // ====================================== // Do not change anything below this line // ====================================== var Q = Quotation.length; var whichQuotation=Math.round(Math.random()*(Q-1)); function showQuotation(){document.write(Quotation[whichQuotation]);} showQuotation(); </script> </div>
This is what is in each of my sidebar_block php files. The H2 text, flv and jpg are different in each of the 4 php files. The name of the flv and jpg files will be the same in a given php file. The H2 text will be a simple statement but unique to each php file.
<h2>Sidebar Block 1</h2> <div id="container"> </div> <script type="text/javascript" src="/jwp/swfobject.js"></script> <script type="text/javascript"> var s1 = new SWFObject("/jwp/player.swf","content1-flv","300","245","9","#FFFFFF"); s1.addParam("allowfullscreen","true"); s1.addParam("wmode","transparent"); s1.addParam("allowscriptaccess","always"); s1.addParam("flashvars","file=/jwp/content1.flv&image=/jwp/content1.jpg"); s1.write("container"); </script>
- The topic ‘[Plugin: WP Super Cache] Help with Javascript for dynamic content’ is closed to new replies.