Hey,

This more a question how to use date arguments.

I have created a Content type "Games" with CCK and a view to display this data.

date: select list (dd/mm/yyyy hh:ss)
hometeam: text field
visitors: text field

I can list the games of this week using this syntax ?q=games/@P1W . This works like a charm but what would the syntax be to list the games of next week ? And what would be the syntax to list the games of the previous week ?

Thanks

CommentFileSizeAuthor
#2 photoshop_week_paging.jpg128.54 KBtmp
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

I just committed something to the cvs version you might try. It adds a date browser plugin that works in combination with the date range argument. You create a view that uses the date range argument and give the argument an option of the period you want to page by (year, month, week, day, or hour), then select Date: Date Browser for your page type (instead of table or list). Then when you go to your view it will default to the current period that you selected and provide back/next links to the next and previous period. You may need to clear your cache to get it working.

That's not exactly what you asked, but maybe what you want???

tmp’s picture

FileSize
128.54 KB

Hey Karen,

Thanks again for these new features.

Would it be possible to make something like the screenshot in attachment ? The pager would always be on top of the view and would alow easy scrolling by year, month or week, ... depending on the argument settings.

It's just a thought :-)

tmp’s picture

Hey karen,

This is what I need for a date browser BUT in my case I need to display the games-nodes in a table view.

Cheers

KarenS’s picture

The display is themeable. Look at the bottom of date_views.inc and you'll see a theme called theme_date_views_browser_full_view(). Copy that function to your template.php file in your theme and rename it to mytheme_browser_full_view(). Then where it says $display='views_view_teasers' change it to say 'views_view_table';

KarenS’s picture

I mean rename it to mytheme_views_browser_full_view(). (Replace 'date' with your theme name).

KarenS’s picture

Status: Active » Fixed

I still got it wrong. I mean rename 'theme' with your theme name. :-)

I'm marking this as fixed, reopen if necessary.

tmp’s picture

Hey Karen,

I pasted this piece of code in the template.php. This will display the date brower in table format.
Thanks

<?php
function bluemarine_date_views_browser_full_view($view, $nodes, $type) {
  
  $teasers = true;
  $links   = true;
  theme_add_style(drupal_get_path('module', 'date') .'/date.css');
  
  $date_views_browser_views = date_views_browser_get_views();
  $period = $date_views_browser_views[$view->name]->options;
  switch ($type) {
    case ('block'):
      $arg = date_views_browser_period_arg(NULL, $view->argument[0]['options']);
      if ($view->url) $url = $view->url . '/'. $arg;
      $output  .= '<h5 class="date-browser-block-label">'. l(date_views_browser_period_label(NULL, $period), $url) .'</h5>';
      $display = 'views_view_table';
      break;
    default:
      $output  .= date_views_browser_navigation($view, $period);
      $display = 'views_view_table';
      break;
  }
  $output .= theme($display, $view, $nodes, $type, $teasers, $links);

  return $output;
}
?>
tmp’s picture

Hey Karen,

When the date browser is opened, I would like to display to current week by default.
?games/@P1W doesn't seem to work with the datebrowser to display the current week.

KarenS’s picture

The date browser displays the current week (or year or month or day or hour) when you have nothing in the argument. Any reason why you don't want to leave the argument blank?

tmp’s picture

Hey Karen,

Leaving the argument blank doesn't seem to work. This displays all nodes.

KarenS’s picture

Do you have the Date:Date Browser type selected for the page view? If so, please export your view and paste it here. That ought to be working...

tmp’s picture

Karen,

The view is set to datebrowser.
This is the export:

  $view = new stdClass();
  $view->name = 'wpw';
  $view->description = 'Wedstrijden per week';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'wedstrijden per week';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = 'Geen wedstrijden deze week !';
  $view->page_empty_format = '1';
  $view->page_type = 'date_views_browser';
  $view->url = 'wpw';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '100';
  $view->sort = array (
    array (
      'tablename' => 'node_data_field_datum',
      'field' => 'field_datum_value',
      'sortorder' => 'ASC',
      'options' => '',
    ),
  );
  $view->argument = array (
    array (
      'type' => 'content: field_datum',
      'argdefault' => '2',
      'title' => '',
      'options' => 'week',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node_data_field_datum',
      'field' => 'field_datum_value',
      'label' => 'Datum',
      'sortable' => '1',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Thuisploeg',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'node_data_field_bezoekers',
      'field' => 'field_bezoekers_value',
      'label' => 'Bezoekers',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node_data_field_type',
      'field' => 'field_type_value',
      'label' => 'Type',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node_data_field_sets',
      'field' => 'field_sets_value',
      'label' => 'Sets',
      'options' => 'default',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'content_wedstrijd',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node_data_field_datum, node, node_data_field_bezoekers, node_data_field_type, node_data_field_sets);
  $views[$view->name] = $view;
KarenS’s picture

I was just about to tell you I couldn't replicate this when I finally got something set up that behaves this way. I'm working on it...

KarenS’s picture

I just made changes to both cvs and 4.7 version. I think that will fix the problems.

tmp’s picture

I had a quick look at it. It looks fine.

Anonymous’s picture

Status: Fixed » Closed (fixed)