whyisjake

Jake Spurlock

Jan 26th, 2010
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.70 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.  
  5. // create a wp object with posts
  6. $rotatingPosts = new WP_Query();
  7. $rotatingPosts->query('showposts=5');
  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.    //$image_path = wp_smart_image('type=url'); incorrect use of the vale
  16.    //$image_path = wp_smart_image('url'); this will probably work
  17.    $image_path = wp_smart_image($type='url');// this is what their example shows
  18.    $js .= "promos[".$count."] = new Array(4);\n";
  19.    $js .= "promos[".$count."][0] = \"" . addslashes($title) . "\";\n";
  20.    $js .= "promos[".$count."][1] = \"". addslashes($teaser) ."\";\n";
  21.    $js .= "promos[".$count."][2] = \"". $link ."\";\n";
  22.    $js .= "promos[".$count."][3] = \"". $image_path ."\";\n";
  23.    $count++;
  24. endwhile;
  25. ?>
  26.  
  27. <!-- This is where the JavaScript array gets loaded -->
  28. <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/promoWidget.js"></script>
  29. <script type="text/javascript">
  30. var promos = new Array(5);
  31. <?php echo $js; ?>
  32. </script>
  33. <!-- 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
  34. 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
  35. into the theme CSS file and not use skin.css at all.  -->
  36. <div id="promoWidget">
  37.     <div id="photo"><img id="promoimg" src=""/></div>
  38.     <div id="adContainer" style="height:220px;">
  39.         <div id="title">Promos Go Here</div>
  40.         <div id="teaser">&nbsp;Teaser goes in here</div>
  41.     </div>
  42.     <div id="promonav">
  43.         <span id="pager">Page <span id="page">1</span> of 5 &nbsp;</span>
  44.         <div id="buttons">
  45.             <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>
  46.             <a href="javascript:void(0);" onClick="promoStop();"><img src="<?php bloginfo('template_directory'); ?>/images/promo_pause.jpg" border="0"/></a>
  47.             <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>
  48.         </div>
  49.         <div id="readmore"><a id="link" href="">Read More</a></div>
  50.     </div>
  51. </div>
  52. <script type="text/javascript">
  53. promoCount = 0;
  54. loadPromo(promoCount, true);
  55. </script>
Advertisement
Add Comment
Please, Sign In to add comment