whyisjake

Untitled

Mar 17th, 2010
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.62 KB | None | 0 0
  1. <?php
  2. // this is a variable that will hold the JavaScript code created by the script below
  3. $js = "";
  4.  g
  5. // create a wp object with posts
  6. $rotatingPosts = new WP_Query();
  7. $rotatingPosts->query('showposts=5&tag=Featured');
  8. $count = 0;
  9.  
  10. // loop through each post and grab the data
  11. while ($rotatingPosts->have_posts()) : $rotatingPosts->the_post();
  12.    $title = $post->post_title;
  13.    $teaser = $post->post_excerpt;
  14.    $link = get_permalink();
  15.    ob_start();
  16.    echo wp_smart_image('type=url');
  17.    $imagelink = ob_get_contents();
  18.    ob_end_clean();
  19.    $js .= "promos[".$count."] = new Array(4);\n";
  20.    $js .= "promos[".$count."][0] = \"" . addslashes($title) . "\";\n";
  21.    $js .= "promos[".$count."][1] = \"". addslashes($teaser) ."\";\n";
  22.    $js .= "promos[".$count."][2] = \"". $link ."\";\n";
  23.    $js .= "promos[".$count."][3] = \"". $imagelink ."\";\n";
  24.    $count++;
  25. endwhile;
  26. ?>
  27.  
  28. <!-- This is where the JavaScript array gets loaded -->
  29. <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/promoWidget.js"></script>
  30. <script type="text/javascript">
  31. var promos = new Array(5);
  32. <?php echo $js; ?>
  33. </script>
  34. <!-- The HTML for the widget.  There are a lot of style references in here that come from skin.css, which also contains a lot of other style definitions
  35. so probably the best bet would be to take out everything from skin.css that does not apply to this widget, or copy everything that does apply to this widget
  36. into the theme CSS file and not use skin.css at all.  -->
  37. <div id="promoWidget">
  38.     <div id="photo"><img id="promoimg" src=""/></div>
  39.     <div id="adContainer" style="height:220px;">
  40.         <div id="title">Promos Go Here</div>
  41.         <div id="teaser">&nbsp;Teaser goes in here</div>
  42.    
  43.     </div>
  44.    
  45. </div>
  46.  
  47. <div id="promonav">
  48.         <span id="pager">Page <span id="page">1</span> of 5 &nbsp;</span>
  49.         <div id="buttons">
  50.             <a href="javascript:void(0);" onClick="loadPromo(getPromoIndex('down'), false);promoStop();"><img src="<?php bloginfo('template_directory'); ?>/images/promo_left_arrow.jpg" border="0"/></a>
  51.             <a href="javascript:void(0);" onClick="promoStop();"><img src="<?php bloginfo('template_directory'); ?>/images/promo_pause.jpg" border="0"/></a>
  52.             <a href="javascript:void(0);" onClick="loadPromo(getPromoIndex('up'), false);promoStop();"><img src="<?php bloginfo('template_directory'); ?>/images/promo_right_arrow.jpg" border="0"/></a>
  53.         </div>
  54.         <div id="readmore"><a id="link" href="">Read More</a></div>
  55.     </div>
  56.    
  57. <script type="text/javascript">
  58. promoCount = 0;
  59. loadPromo(promoCount, true);
  60. </script>
Add Comment
Please, Sign In to add comment