'Content Slider', 'description' => t('Setting Content Slider.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('content_slider_admin_settings'), 'access arguments' => array('administer site configuration'), ); $items[] = array( 'path' => 'content_slider/list/'. arg(2), 'title' => t('Content Slider'), 'page callback' => 'content_slider_page_list', 'page arguments' => array(arg(2)), 'access arguments' => array('access content_slider'), 'type' => MENU_CALLBACK, ); return $items; } function content_slider_admin_settings() { // only administrators can access this function // Generate the form - settings applying to all patterns first $form['content_slider_settings'] = array( '#type' => 'fieldset', '#weight' => -20, '#title' => t('Basic settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['content_slider_settings']['content_slider_auto'] = array( '#type' => 'checkbox', '#title' => t('Auto rotate contents'), '#default_value' => variable_get('content_slider_auto', 1), '#description' => t("Display content without mouse click."), '#maxlength' => '1', '#size' => '1', ); $form['content_slider_settings']['content_slider_speed'] = array( '#type' => 'textfield', '#title' => t('Glide animation duration (in milliseconds)'), '#default_value' => variable_get('content_slider_speed', 1000), ); $form['content_slider_settings']['content_slider_direction'] = array( '#type' => 'textfield', '#title' => t('Set direction of glide'), '#default_value' => variable_get('content_slider_direction', 'leftright'), '#description' => 'Available value: "updown", "downup", "leftright", or "rightleft"', ); // set direction of glide: "updown", "downup", "leftright", or "rightleft"' //$output_body .= 'direction: "downup", $form['content_slider_source'] = array( '#type' => 'fieldset', '#weight' => -20, '#title' => t('Slider content source (based on Drupal content-type)'), '#description' => t('Note: For Content Slider 3, please insert ID of nodequeue.'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['content_slider_source']['content_slider_source_1'] = array( '#type' => 'textfield', '#title' => t('Content type for Slider 1'), '#default_value' => variable_get('content_slider_source_1', 'page'), ); $form['content_slider_source']['content_slider_source_2'] = array( '#type' => 'textfield', '#title' => t('Content type for Slider 2'), '#default_value' => variable_get('content_slider_source_2', 'story'), ); $form['content_slider_source']['content_slider_source_3'] = array( '#type' => 'textfield', '#title' => t('Nodequeue ID for Slider 3'), '#default_value' => variable_get('content_slider_source_3', '1'), ); return system_settings_form($form); } /** * Implementation of hook_block(). * */ function content_slider_block($op = 'list', $delta = 0) { $content_slider_auto = variable_get("content_slider_auto", 1); $content_slider_speed = variable_get("content_slider_speed", 1000); $content_slider_direction = variable_get("content_slider_direction", 'leftright'); $content_slider_source_1 = variable_get("content_slider_source_1","page"); $content_slider_source_2 = variable_get("content_slider_source_2","story"); $content_slider_source_3 = variable_get("content_slider_source_3","featured"); global $base_url; $ajax_base_path = $base_url; if ($op == 'list') { $blocks[0]['info'] = 'Content Slider 1'; $blocks[1]['info'] = 'Content Slider 2'; $blocks[2]['info'] = 'Content Slider 3'; return $blocks; } if ($op == 'view') { global $base_url; drupal_add_css(drupal_get_path('module', 'content_slider') . '/contentslider.css'); drupal_add_js(drupal_get_path('module', 'content_slider'). '/contentslider.js'); $output_body = ""; //Text $output_head = ''."\n"; $output_head .= '/***********************************************'."\n"; $output_head .= '* Featured Content Slider script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)'."\n"; $output_head .= '* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts'."\n"; $output_head .= '* This notice must stay intact for legal use'."\n"; $output_head .= '***********************************************/'."\n"; //drupal_add_js($output_head,'inline'); $slider_id = $delta + 1; switch ($delta) { case 0: $content_type = $content_slider_source_1; $block['subject'] = 'Content Slider 1'; $block['content'] = outbody_of_block($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); break; case 2: $content_type = $content_slider_source_3; $block['subject'] = 'Content Slider 3'; $block['content'] = outbody_of_block($content_type,$delta); break; } return $block; } } function outbody_of_block($content_type,$delta) { $output_body = ''; if ($delta == 2) { $results = db_query(" SELECT nid FROM {nodequeue_nodes} WHERE qid = %d ORDER BY nid DESC LIMIT 5", $content_type); } else { $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 .= '
'."\n"; while ($data = db_fetch_object($results)) { $slider_nid = $data->nid; $output_body .= '
'."\n"; $output_body .= "". node_view(node_load($data->nid), 1) .""; if ($slider_nid == 1) { $output_body .= '

'; } $output_body .= '
'; } $output_body .= '
'; $output_body .= ''; $output_body .= ''; return $output_body; //$output_body .= ''; } function content_slider_page_list($i) { $content_slider_item = variable_get("content_slider_item", 10); $dse_news_total = db_query(" SELECT count(*) AS total FROM {node} n WHERE n.type='slider".$i."' AND n.status=1"); $row_news = db_fetch_object($dse_news_total); $news_total = $row_news->total; $sql_counts = "SELECT $news_total"; $sql = " SELECT n.nid, n.title, r.teaser FROM {node} n INNER JOIN {node_revisions} r ON r.nid = n.nid WHERE n.type = 'slider$i' AND n.status=1 ORDER BY n.created DESC"; $sql = db_rewrite_sql($sql); $results = pager_query($sql, $content_slider_item, 0, $sql_counts); $output = "
"; while ($node = db_fetch_object($results)) { $output .= node_view(node_load($node->nid), 1); } $output .= theme('pager', NULL, $content_slider_item, 0); $output .= '
'; return $output; }