I have an upcoming event list that has a number of repeating date events that happen every Monday, twice a month, etc.. Using the views module I have been able to format/output this list so the repeating dates show up in the right order, and only list the date for that particular instance. When I select the event to view a specific instance of the node with repeating dates there is a long list of every date related to that node.

I have edited the date field using "manage display" options to only show 1 value, but then each page for the repeating event only shows the first date instead of the particular instance I linked to from the previous views page. How can I make it so my node detail pages show a single date related to the specific instance in my repeating date set.

Any help is greatly appreciated. I've scoured the issue queue and forums without finding a solution.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Quadomated’s picture

Still having problems with this issue, anyone have a solution?

KarenS’s picture

Category: feature » support
Priority: Major » Normal
Status: Active » Fixed

This is not a major feature request, it is a support request. Make sure you are using the 'add delta' option, which is a setting on the date arguments and filters. That adds information to the view that Date needs to tell which date you are looking at.

Quadomated’s picture

Karen, thanks for the response and all the hard work you do on this module and others. I'm not familiar with the 'add delta' nor do I know where to find/use it to impact how my nodes are displaying. As it is now my node for each reoccurring event is displaying date like:

Tuesday, November 15, 2011 - 6:00pm Thursday, November 17, 2011 - 6:00pm Tuesday, November 22, 2011 - 6:00pm Thursday, November 24, 2011 - 6:00pm Tuesday, November 29, 2011 - 6:00pm Thursday, December 1, 2011 - 6:00pm Tuesday, December 6, 2011 - 6:00pm Thursday, December 8, 2011 - 6:00pm Tuesday, December 13, 2011 - 6:00pm Thursday, December 15, 2011 - 6:00pm Tuesday, December 20, 2011 - 6:00pm Thursday, December 22, 2011 - 6:00pm Tuesday, December 27, 2011 - 6:00pm Thursday, December 29, 2011 - 6:00pm Tuesday, January 3, 2012 - 6:00pm Thursday, January 5, 2012 - 6:00pm Tuesday, January 10, 2012 - 6:00pm Thursday, January 12, 2012 - 6:00pm Tuesday, January 17, 2012 - 6:00pm Thursday, January 19, 2012 - 6:00pm Tuesday, January 24, 2012 - 6:00pm Thursday, January 26, 2012 - 6:00pm Tuesday, January 31, 2012 - 6:00pm Thursday, February 2, 2012 - 6:00pm Tuesday, February 7, 2012 - 6:00pm Thursday, February 9, 2012 - 6:00pm Tuesday, February 14, 2012 - 6:00pm Thursday, February 16, 2012 - 6:00pm Tuesday, February 21, 2012 - 6:00pm Thursday, February 23, 2012 - 6:00pm Tuesday, February 28, 2012 - 6:00pm Thursday, March 1, 2012 - 6:00pm Tuesday, March 6, 2012 - 6:00pm Thursday, March 8, 2012 - 6:00pm Tuesday, March 13, 2012 - 6:00pm Thursday, March 15, 2012 - 6:00pm

Thank you for your patience and helping figure this out

KarenS’s picture

Look for the following on the Date contextual filter:

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pjcdawkins’s picture

Status: Closed (fixed) » Active

I haven't got this to work yet.

I have "Add multiple value identifier" enabled for each of the view's date filters (these are normal filters, not contextual filters). But that doesn't appear to make any difference to the view's query. The behaviour is as described in the OP.

Quadomated’s picture

No problems with the how my dates show up within views, only when I look at the node detail.

Within your views have you tried unchecking "Display all values in the same row" underneath the MULTIPLE FIELD SETTINGS. When I made that change my views displayed only the active instance date just as I'd like.

pjcdawkins’s picture

My view lists node teasers, not fields, so there are no multiple field settings (the node display has no settings in Views).

In this issue I suppose our problem is really in the Date field's display formatter, not in Views. What I want it to do is:

  • in a single node page, show the next 1 or n date(s) from now
  • in a View, show 1 or n date(s), relative to the specific date which matches the filter

So a repeating event could show its next date when displayed on its own (with the Repeats tab still available), but when in a sorted View it would show the relevant date for each instance in the list.

Am I right that this doesn't seem to be possible at the moment with the Date module? If that's the case, I will see if I can implement the feature with a custom module (although I only work part time) as I guess it's an edge case.

KarenS’s picture

Status: Active » Closed (duplicate)
chiebert’s picture

Not wanting to re-open this, but while trying to get the node view to display the 'current' instance of a repeating date, I discovered that the field display settings (admin/structure/types/manage/[event-type]/display), I can enter a relative date in the 'starting from' field of the 'Multiple values' section. So, I can tell it to show 1 item starting from 'now', and voila!

That said, the help text on that widget could use a tweak, since for the longest time I assumed I could only enter a hard-coded specific date in the from/to fields...

pjcdawkins’s picture

@chiebert (#10)

Thanks, that's very helpful to know.

I will want something quite a bit more flexible: my site has events that sometimes "repeat" just once, e.g. a show that's on for two nights, Wednesday and Thursday. For those I want to display both dates on the full node display, and hide the repeat rule (and ideally make both dates available to a customised Commerce field for selling tickets). Other events repeat every week for a whole year so obviously for those I don't want to show more than one date, but I do want to display the repeat rule.

I'd want to do something similar for events in the past, although setting 'starting from' to 'now' would not work for those.

AND where those event nodes are listed, the reference date shouldn't be 'now', it should be the date corresponding to the position in the list (i.e. the date of the previous result). But that would probably require something Views-ish.

sashken2’s picture

Thanks chiebert
'now' - works good, but I need 'now -1 day' and it don't work

steven.wichers’s picture

Use "yesterday" or "-1 day"

sashken2’s picture

steven.wichers, if I use "yesterday" or "-1 day" AND date = Today, I don't see date in Node view

P.S. if I use "yesterday" or "-1 day" I don't see date in Node view

steven.wichers’s picture

Does the event occur within that time frame?

It sounds like you want this: "If the event has a time that occurs yesterday or today then show that time, but if it doesn't then show the next closest one."

If that is correct I do not think you are going to get what you're looking for without custom code.

kjauslin’s picture

After losing quite some time researching on how to display the next available date (from today) in a views row, I finally found this issue and comment #1401688-10: How do I make the node view of a repeating date event only show the specific date of the instance I'm viewing.. Very cool feature. To save future time for others, I made a smallest patch to include the availability of relative dates in the GUI help text.

kjauslin’s picture

Status: Closed (duplicate) » Needs review

Status: Needs review » Needs work

The last submitted patch, date-repeat-helptext-in-views-1401688-16.patch, failed testing.

Tran’s picture

Is there an answer to this?
I have a calendar that has repeating events... on day 1, there is one listing of the event. On day 30, there is 30 listings of the event.

What is the easy way to fix this so that a repeated event shows up ONLY ONCE per day it is scheduled

SchwebDesign’s picture

Hey all,

Try this patch here: Support relative date formats in the filter of the date field output formatter

That patch solved the issue for us, as "now" worked, but "yesterday", "1 day ago", "-1 day", etc didn't work at all.

I hope that helps someone else as well.

peteruithoven’s picture

The suggestion in #7 works for me.

unchecking "Display all values in the same row" underneath the MULTIPLE FIELD SETTINGS.

tzt20’s picture

The suggestion in #7 works for me too. Thanks for posting.

tmckay’s picture

Title: How do I make the node view of a repeating date event only show the specific date of the instance I'm viewing. » Nothing's Working for Me
FileSize
51.91 KB
37.09 KB
50.78 KB
44.05 KB

I'm having the same issue. I've tried pretty much everything in this post and anything else I've found. Nothing has worked for me yet. Take a look at the images I've attached to see how I have the block setup.

Delta makes sense, just set it equal to 0. Problem is delta doesn't update when it's gone past the date. I can't seem to find the fix. I need help.

pixelsweatshop’s picture

Title: Nothing's Working for Me » How do I make the node view of a repeating date event only show the specific date of the instance I'm viewing.

@tmckay please don't change the issue title.

tmckay’s picture

Oh sorry. I didn't know that did that. First time commenting. Thought those were required for my comment for some reason. Well if anyone could help I'd appreciate it. Still having issues.

chiebert’s picture

Just chiming back in here - Just to make sure I hadn't introduced any wonky settings along the way, I started from scratch with a fresh D7.21 site, Date 7.x-2.6 and Calendar 7.x-3.4:

  • created a new 'event' content type with a repeating-enabled 'field_event_date' field of type 'date' - left the default display settings under 'manage display', which basically means 'show all events' and 'display repeat rule'
  • created some Event content with repeating dates
  • created a new calendar view using the appropriate template
  • confirmed settings #4 (add multiple value identifier) and #7 (do NOT display all results in one row) were both correctly applied in the various displays of the calendar view
  • flushed all caches, just to be sure

Result: When I view, for example, the month display for the calendar, and then click on some instance of a repeating event, the node view show all the repeat dates. So, I'm not seeing where the 'add multiple value identifier' is taking effect. Is there yet more that I'm missing here?

(Meanwhile, I've found that the Date Repeat Formatter sandbox project - http://drupal.org/sandbox/othermachines/1456552 - is doing the trick for now)

lias’s picture

I'm using the Date Repeat Formatter module now on a production site and it's working really well so far using the current dev release of Date.

See the issue here to download the zipped version of the module.
http://drupal.org/node/1509984#comment-7374284

cybernomad’s picture

@Chiebert #10: Cool, that is exactly what I was looking for, works also with fields in views

shortspoken’s picture

Issue summary: View changes

Wanted to drop a solution here as I came across the same issue. I ended up using the sandbox module "Date Repeat Entity" https://drupal.org/sandbox/eft/2141729
which creates a unique node of every repeating instance. Then you get exactly the date of the instance you are viewing, because there is only one date value per instance/node.

You should probably combine this with limiting the repeating instances, as this issue https://drupal.org/node/1901936 has no solution so far.

Cheers!

kevinquillen’s picture

Version: 7.x-2.0-rc1 » 7.x-2.7

Is there just a way to add the date delta to the URL with a router or some other fashion? Something like..


function foo_menu() {
  // loop entity types and check if it has a multi value date field that repeats
  $bar['entity/%/date/%'] = array(
    // basic callback code here, passing entity id and delta arguments
  );
}

Which basically should be a clone of the view rendering function, but signals which date value to show from the passed delta?

Example:

node/1 - basic node render display
node/1/date/5 - the node is rendered, but the date field shows the fifth value in its array

I know this can get tricky - entities could have multiple date fields. You'd want to know which field to affect... but there must be some simple way of achieving this besides nothing.

I am already invested in a site with thousands of event dates for repeating nodes, so this seems like a simple enough approach without instituting a lot of change (say, creating nodes per repeating event, for example - instead of date values).

bkosborne’s picture

I want to clear up some confusion I noticed as I was reading this thread.

Some people are trying to get views that are showing fields to only display one date per "row". This is useful when displaying a listing of events like in a calendar, where you want a distinct "row" for each repeated date on a node. To do this, you need to uncheck the "Display all values in the same row" under the "Multiple Field Settings" when editing the field in the view.

The other group of people are trying to have node pages (when you view a node) only display either 1 date of a repeating set, or only show future dates of the repeating set.

You won't be able to have a node page that just displays 1 relevant date, because when viewing a node it has no idea which of the repeating dates you're trying to display (comment #30 above discusses a potential workaround). Date module does not create multiple distinct nodes for each repeating date. It's just 1 node that has multiple date field entries. Using some nice views integration you're able to split out the repeated dates as described above, but when viewing the actual node, you cannot do that, since there's only 1 node to view.

If you want to display only future dates of a repeating date field, people have been modifying the display formatter for the field to use a relative date to limit the dates shown to only future dates. This would work, but only if your flushing your page caches every day or more often. There's also a sandbox module that tries to make this process a bit nicer. Also see #1715542: Support relative date formats in the filter of the date field output formatter and Date Repeat Entity module (which creates a distinct node for each repeat date).

ramu_bharu’s picture

I have achieved this by creating two template files.
One is for Calender view page template file to alter event title and another one is for node template.

Here is the code of two files:

1. Calender view page template file to alter event title

views-view-field--calendar--page-1--title.tpl.php

<?php
/**
 * @file
 * This template is used to print a single field in a view.
 *
 * It is not actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the template is
 * perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $field: The field handler object that can process the input
 * - $row: The raw SQL result that can be used
 * - $output: The processed output that will normally be used.
 *
 * When fetching output from the $row, this construct should be used:
 * $data = $row->{$field->field_alias}
 *
 * The above will guarantee that you'll always get the correct data,
 * regardless of any changes in the aliasing that might happen if
 * the view is modified.
 */
?>
<?php
// Getting event date
$event_date = $row->field_data_field_event_date_field_event_date_value;
// Convert to strtotime
$sdate = strtotime($event_date);
$nid = $row->nid;
// Getting event title
$title = $row->node_title;
print(l(t($title),'node/'.$nid, array('query' => array("date" => $sdate))));
?>

2. node template file to alter event date

node--events.tpl.php

<?php

/**
 * @file
 * Bartik's theme implementation to display a node.
 *
 * Available variables:
 * - $title: the (sanitized) title of the node.
 * - $content: An array of node items. Use render($content) to print them all,
 *   or print a subset such as render($content['field_example']). Use
 *   hide($content['field_example']) to temporarily suppress the printing of a
 *   given element.
 * - $user_picture: The node author's picture from user-picture.tpl.php.
 * - $date: Formatted creation date. Preprocess functions can reformat it by
 *   calling format_date() with the desired parameters on the $created variable.
 * - $name: Themed username of node author output from theme_username().
 * - $node_url: Direct URL of the current node.
 * - $display_submitted: Whether submission information should be displayed.
 * - $submitted: Submission information created from $name and $date during
 *   template_preprocess_node().
 * - $classes: String of classes that can be used to style contextually through
 *   CSS. It can be manipulated through the variable $classes_array from
 *   preprocess functions. The default values can be one or more of the
 *   following:
 *   - node: The current template type; for example, "theming hook".
 *   - node-[type]: The current node type. For example, if the node is a
 *     "Blog entry" it would result in "node-blog". Note that the machine
 *     name will often be in a short form of the human readable label.
 *   - node-teaser: Nodes in teaser form.
 *   - node-preview: Nodes in preview mode.
 *   The following are controlled through the node publishing options.
 *   - node-promoted: Nodes promoted to the front page.
 *   - node-sticky: Nodes ordered above other non-sticky nodes in teaser
 *     listings.
 *   - node-unpublished: Unpublished nodes visible only to administrators.
 * - $title_prefix (array): An array containing additional output populated by
 *   modules, intended to be displayed in front of the main title tag that
 *   appears in the template.
 * - $title_suffix (array): An array containing additional output populated by
 *   modules, intended to be displayed after the main title tag that appears in
 *   the template.
 *
 * Other variables:
 * - $node: Full node object. Contains data that may not be safe.
 * - $type: Node type; for example, story, page, blog, etc.
 * - $comment_count: Number of comments attached to the node.
 * - $uid: User ID of the node author.
 * - $created: Time the node was published formatted in Unix timestamp.
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in
 *   teaser listings.
 * - $id: Position of the node. Increments each time it's output.
 *
 * Node status variables:
 * - $view_mode: View mode; for example, "full", "teaser".
 * - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser').
 * - $page: Flag for the full page state.
 * - $promote: Flag for front page promotion state.
 * - $sticky: Flags for sticky post setting.
 * - $status: Flag for published status.
 * - $comment: State of comment settings for the node.
 * - $readmore: Flags true if the teaser content of the node cannot hold the
 *   main body content.
 * - $is_front: Flags true when presented in the front page.
 * - $logged_in: Flags true when the current user is a logged-in member.
 * - $is_admin: Flags true when the current user is an administrator.
 *
 * Field variables: for each field instance attached to the node a corresponding
 * variable is defined; for example, $node->body becomes $body. When needing to
 * access a field's raw values, developers/themers are strongly encouraged to
 * use these variables. Otherwise they will have to explicitly specify the
 * desired field language; for example, $node->body['en'], thus overriding any
 * language negotiation rule that was previously applied.
 *
 * @see template_preprocess()
 * @see template_preprocess_node()
 * @see template_process()
 */
?>
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>>
      <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <div class="meta submitted">
      <?php print $user_picture; ?>
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

  <div class="content clearfix"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_event_date']);      
      print render($content);
      if (isset($_GET['date'])):   
      $event_date = date('F d, Y - h:i a', $_GET['date']);     
      print '<strong>Date of Event:</strong><br/>' . $event_date;
      endif;      
    ?>
  </div>

  <?php
    // Remove the "Add new comment" link on the teaser page or if the comment
    // form is being displayed on the same page.
    if ($teaser || !empty($content['comments']['comment_form'])) {
      unset($content['links']['comment']['#links']['comment-add']);
    }
    // Only display the wrapper div if there are links.
    $links = render($content['links']);
    if ($links):
  ?>
    <div class="link-wrapper">
      <?php print $links; ?>
    </div>
  <?php endif; ?>

  <?php print render($content['comments']); ?>

</div>
hwasem’s picture

The reference by SchwebDesign in #20 was exactly what fixed my problem - partial implementation of PHP's relative date formats.

joshuautley’s picture

#31 points tot he patch which solves both view and node display.

Thank you.

Steve Polito Design’s picture

It's important to look at #31 and understand there are two different issues at play here.

Shameless plug, but I wrote a tutorial explaining how to display relative dates on a node, and limit a view to only showing future events.

swhitters’s picture

What solved my problem was to check off aggregate in the advanced tab, but NOT distinct.

I was attempting to create a calendar view with a popup colorbox for each event on a date. I had the same problem with the repeating dates (either display all repeated dates or the first date in the series rather than the instance date). If I checked off distinct, only the first event in a repeating series would show up on the calendar.

Checking aggregate worked, but if you have a date with start and end times, you'll need to make sure to group the additional value in the aggregation settings for that particular field.

Hope that helps someone.

Brian E. Conklin’s picture

@Steve, Thank you! That's exactly what I needed! We should get this patch added into the module.

Chris2u’s picture

Many previous comments advertised using "now" and "display 1 value" in the display formatter would solve the right intended display of the node detail view which it doesn't. If you have three repeating dates in the future and clicked on the first in the calendar view, you would be shown the right one. However, if you clicked on the second, you would still be shown the first one. If the first transitioned to the past, its date would never be shown in the node view anymore. Using "now" is thus only a "solution" if you showed only the next repeating event in calendar AND you didn't show past events in calendar. The only solution I found to this problem is to use a view with "full node rendering" as detail view, which is not optimal, too, as you lose functionality of the node-edit page like edit/manage display etc. If anyone found a better solution to this long standing problem - without extra modules (date_repeat_fm does a decent job but is no longer maintained) - I would be keen to know.

kevinquillen’s picture

I still think a solid way to solve it is to create your own route with hook_menu... pardon the fact I do not have any code to post.

Menu route: node/%node/view/date/%delta

The callback could pass the node id and field delta argument, and you could either build it there or defer it to a preprocess and pass it in the array.

Essentially, you're looking at the same node, but the URL is signaling what date value to show (by the field delta of that date field).

Then, just have Views use that link instead of the regular node link.

Personally, I would then go back and remove (in code) the event dates from showing in a huge list on the default/full view mode, and add a link that would jump to the calendar filtered on that node id to see all potential dates.

I can understand where some don't want to go that route and feel the UI should do it, but this is how I would solve it.

Vali Hutchison’s picture

#7 worked for me.

trackleft2’s picture

This allows you to use the node row plugin in your view and still use repeating date field.

/**
 * Implements hook_field_display_alter().
 *
 * If events are in in a view using the node display row plugin, we need to help nodes
 * using the field__MY_FIELD_NAME field to find the next date to display.
 *
 * What we are doing here is passing the value of the field from the
 * view which is force using fields, to the start from date 'multiple_from' on
 * the entity. This is mostly useful with repeating events.                                          /
 * @todo should add  a condition that the view forces using fields
 */
function MY_MODULE_NAME_field_display_alter(&$display, $context) {
  if ($context['field']['field_name'] == 'field_MY_FIELD_NAME' && isset($context['entity']->view) && $context['entity']->view->style_plugin->row_plugin->plugin_name == 'node') {
    $row_index = $context['entity']->view->row_index;
    $display['settings']['multiple_from'] = $context['entity']->view->result[$row_index]->field_data_field__MY_FIELD_NAME_field__MY_FIELD_NAME_value;
  }
}