All pastes #71415 Raw Edit

Untitled

public text v1 · immutable
#71415 ·published 2006-06-25 18:54 UTC
rendered paste body
  $view = new stdClass();
  $view->name = 'taxonomy_by_date';
  $view->description = 'Browse taxonomy-filtered content by date';
  $view->access = array (
  0 => '1',
  1 => '2',
);
  $view->view_args_php = '// Default to term 1 if none was set
if (!$args[0]) {
  $args[0] = 1;
}

// Default to most recent date if none was set
if (!$args[1]) {
  $timezone = _views_get_timezone();
  $latest = db_result(db_query("SELECT DATE_FORMAT(FROM_UNIXTIME(n.created+$timezone), '%Y%m%%d') FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d ORDER BY n.created DESC LIMIT 1", $args[0]));
  $args[1] = $latest;
}

return $args;';
  $view->page = TRUE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '<?php\r\n\r\n// Get current view object and its arguments\r\n$view = $GLOBALS[\'current_view\'];\r\n$args = $view->args;\r\n$term = $args[0];\r\n\r\n// Retrieve array of unique dates\r\n$timezone = _views_get_timezone();\r\n$result = db_query(\"SELECT DISTINCT DATE_FORMAT(FROM_UNIXTIME(n.created+$timezone), \'%Y%m%%d\') AS date FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d ORDER BY n.created DESC\", $term);\r\nwhile ($date = db_fetch_object($result)) {\r\n  $date_list[] = $date->date;\r\n}\r\n\r\n// Find current and last positions\r\n$current = array_search($args[1], $date_list);\r\n$last = count($date_list) - 1;\r\n\r\n// Find previous date\r\nif ($current == 0) {\r\n  $prev = NULL;\r\n}\r\nelse {\r\n  $prev = $date_list[$current-1];\r\n}\r\n\r\n// Find next date\r\nif ($current == $last) {\r\n  $next = NULL;\r\n}\r\nelse {\r\n  $next = $date_list[$current+1];\r\n}\r\n\r\nprint theme(\'date_pager\', $prev, $next, $term);\r\n\r\n?>';
  $view->page_footer_format = '2';
  $view->page_empty = 'No content was found.';
  $view->page_empty_format = '1';
  $view->page_type = 'node';
  $view->url = 'taxonomy_by_date';
  $view->use_pager = FALSE;
  $view->nodes_per_page = '10';
  $view->sort = array (
  );
  $view->argument = array (
    array (
      'type' => 'taxid',
      'argdefault' => '2',
      'title' => '',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
    array (
      'type' => 'fulldate',
      'argdefault' => '5',
      'title' => '',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'created',
      'label' => '',
      'handler' => 'views_handler_field_date_small',
      'defaultsort' => 'DESC',
    ),
  );
  $view->filter = array (
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node);
  $views[$view->name] = $view;