? content_slider_use_theme_layer.patch
Index: content_slider.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_slider/content_slider.module,v
retrieving revision 1.2
diff -u -p -r1.2 content_slider.module
--- content_slider.module	10 Jan 2009 19:22:22 -0000	1.2
+++ content_slider.module	28 May 2009 10:30:17 -0000
@@ -8,6 +8,24 @@
  */
 
 /**
+ * Implementation of hook_theme().
+ */
+function content_slider_theme($existing, $type, $theme, $path) {
+  return array(
+    'content_slider' => array(
+      'arguments' => array('content_type' => '', 'delta' => 0),
+      'template' => 'content_slider',
+    ),
+    'content_slider_row' => array(
+      'arguments' => array('slider_nid' => 0),
+      'template' => 'content_slider_row',
+    ),
+  );  
+}
+
+
+
+/**
  * Implementation of hook_help().
  */
 function content_slider_help($section) {
@@ -159,68 +177,52 @@ function content_slider_block($op = 'lis
       case 0:
         $content_type = $content_slider_source_1;
         $block['subject'] = 'Content Slider 1';
-        $block['content'] = outbody_of_block($content_type,$delta);
+        $block['content'] = theme('content_slider',$content_type,$delta);
         break;
 
       case 1:
         $content_type = $content_slider_source_2;
         $block['subject'] = 'Content Slider 2';
-        $block['content'] = outbody_of_block($content_type,$delta);
+        $block['content'] = theme('content_slider',$content_type,$delta);
 
         break;
 
       case 2:
         $content_type = $content_slider_source_3;
         $block['subject'] = 'Content Slider 3';
-        $block['content'] = outbody_of_block($content_type,$delta);
+        $block['content'] = theme('content_slider',$content_type,$delta);
 
         break;
     }
     return $block;
   }
 }
-function outbody_of_block($content_type,$delta)
-{
- $output_body = '';
-    $sql  = " SELECT n.nid, teaser FROM {node} n INNER JOIN {node_revisions} r ON n.nid=r.nid "." WHERE n.status=1 AND n.type='".$content_type."' ORDER BY n.changed DESC LIMIT 5";
-    $results     = db_query($sql);
-
-    $output_body .= '<div id="slider'.$delta.'" class="sliderwrapper">'."\n";
-    while ($data = db_fetch_object($results)) {
-      $slider_nid = $data->nid;
-      $output_body .= '<div class="contentdiv">'."\n";
-      $output_body .= "<a href='".$base_url."/node/".$slider_nid."'>". node_view(node_load($data->nid), 1) ."</a>";
-      if ($slider_nid == 1) {
-        $output_body .= '<p></p><a href="javascript:featuredcontentslider.jumpTo(\'slider1\', 3)">';
-      }
-      $output_body .= '</div>';
-    }
-    $output_body .= '</div>';
-    $output_body .= '<div id="paginate-slider'.$delta.'" class="pagination">'."\n";
-    $output_body .= '</div>';
-
-    $output_body .= '<script type="text/javascript">';
-
-    $output_body .= 'featuredcontentslider.init({'."\n";
-    $output_body .= 'id: "slider'.$delta.'",//id of main slider DIV'."\n";
-    $output_body .= 'contentsource: ["inline", ""],  //Valid values: ["inline", ""] or ["ajax", "path_to_file"]'."\n";
-    $output_body .= 'toc: "#increment",  //Valid values: "#increment", "markup", ["label1", "label2", etc]'."\n";
-    $output_body .= 'nextprev: ["Previous", "Next"],  //labels for "prev" and "next" links. Set to "" to hide.'."\n";
-    $output_body .= 'revealtype: "click", //Behavior of pagination links to reveal the slides: "click" or "mouseover"'."\n";
-    $output_body .= 'enablefade: [true, 0.2],  //[true/false, fadedegree]'."\n";
-    $output_body .= 'autorotate: [true, 3000],  //[true/false, pausetime]'."\n";
-    $output_body .= 'onChange: function(previndex, curindex){  //event handler fired whenever script changes slide'."\n";
-    $output_body .= '//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)'."\n";
-    $output_body .= '//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)'."\n";
-    $output_body .= '}';
-    $output_body .= '})';
 
-    $output_body .= '</script>';
-     return  $output_body;
+/**
+ * Theme preprocessor for content_slider
+ * Builds a list of rows which match the given content type.
+ */
+function template_preprocess_content_slider(&$variables) {
+  // build a list of 'featured nodes' matching the given content type.
+  $rows = array();
+  $sql  = " SELECT n.nid FROM {node} n INNER JOIN {node_revisions} r ON n.nid=r.nid "." WHERE n.status=1 AND n.type='".$variables['content_type']."' ORDER BY n.changed DESC LIMIT 5";
+  $results     = db_query($sql);
+  while ($nid = db_result($results)) {
+    $rows[] = theme('content_slider_row', $nid);
+  }  
+  $variables['rows'] = $rows;
+}
 
-    //$output_body .= '</div>';
+/**
+ * Theme preprocessor for content_slider_row
+ * Adds the content of the featured node.
+ */
+function template_preprocess_content_slider_row(&$variables) {
+  $variables['content'] = node_view(node_load($variables['slider_nid']), 1);
 }
 
+
+
 function content_slider_page_list($i) {
   $content_slider_item = variable_get("content_slider_item", 10);
 
Index: content_slider.tpl.php
===================================================================
RCS file: content_slider.tpl.php
diff -N content_slider.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ content_slider.tpl.php	28 May 2009 10:30:17 -0000
@@ -0,0 +1,24 @@
+<div id="slider<?php echo $delta; ?>" class="sliderwrapper">
+  <?php foreach($rows as $row): ?>
+    <?php echo $row; ?>
+  <?php endforeach; ?>
+</div>
+
+<div id="paginate-slider<?php echo $delta; ?>" class="pagination"></div>
+
+<script type="text/javascript">
+  featuredcontentslider.init({
+    id: "slider<?php echo $delta; ?>",           //id of main slider DIV'
+    contentsource: ["inline", ""],               //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
+    toc: "#increment",                           //Valid values: "#increment", "markup", ["label1", "label2", etc]
+    nextprev: ["Previous", "Next"],              //labels for "prev" and "next" links. Set to "" to hide
+    revealtype: "click",                         //Behavior of pagination links to reveal the slides: "click" or "mouseover"
+    enablefade: [true, 0.2],                     //[true/false, fadedegree]
+    autorotate: [true, 3000],                    //[true/false, pausetime]
+    onChange: function(previndex, curindex){     //event handler fired whenever script changes slide
+      //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
+      //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
+    }
+  })
+</script>
+
Index: content_slider_row.tpl.php
===================================================================
RCS file: content_slider_row.tpl.php
diff -N content_slider_row.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ content_slider_row.tpl.php	28 May 2009 10:30:17 -0000
@@ -0,0 +1,6 @@
+<div class="contentdiv">
+<a href="<?php echo $base_url; ?>/node/<?php echo $slider_nid; ?>"><?php echo $content; ?></a>
+<?php if ($slider_nid == 1): ?>
+  <p></p><a href="javascript:featuredcontentslider.jumpTo(slider1, 3)">
+<?php endif; ?>
+</div>
\ No newline at end of file
