Download & Extend

Multiple Values with Repeating Dates

Project:Date
Version:6.x-2.4
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

Is there any way to have one date field allow for both Multiple Values and Repeating dates?

The problem is I have a content type that sometimes occurs on a regular repeating schedule and sometimes occurs on an irregular schedule.

When I have two different date fields I have problems getting items to sort by date correctly in views. It would be wonderful it there was a way to add both multiple values if the events occurred on an irregular basis and a way to add repeating dates when the event falls into this category.

If there isn't a way to do this does anyone know how to get two date fields to sort together to present a dates in ascending order form both fields.

Comments

#1

I think I am looking for the same thing.

Most CCK fields have a 'Number of Values' option, but Date doesnt seem to have this.

In the case of many of my events, I have several dates for the event, but they are irregular so I cannot use the 'repeat' option.
In this case I would prefer to have the ability to enter several distinct date values.

Is there a way to set the 'Number of Values' in CCK date field configuaration to unlimited?

#2

I currently have a date field set to Text Field with pop-up and it allows me to set the number of values to unlimited. This allows for irregular repeating dates to be entered.

If I use repeating dates then no there is no "number of values" setting.

#3

Thanks. I now noticed this.

For the dated nodes I am creating, some nodes could really use the repeat feature, but other nodes need individual dates to be entered - as they are too random.

I wanted to have a node with both types of CCK date fields (1 repeating and 1 multiple) in them, or multiple repeating sets, so i could enter dates easily whether they are regular, or irregular.

I have tried the second option now, but can't figure out how to get views to sort repeating dates and multiple dates coming from the same node - so I may need to go with just multiple dates after all, since that would handle all of my cases, though it certainly would be a pain for daily events :)

#4

That's basically what I had to do as well. Unfortunately I couldn't get views to sort based on two date fields at the same time so I had to pick one or the other.

#5

My solution for using unlimited and repeating date simultanously:
Build a datefield, that collects the dates of one unlimited and one repeatable datefield with the help of CCK Computed Field.
So you can use (and sort) only one datefield in views.

1. install the computed field module http://drupal.org/project/computed_field
2. add 3 datefields to your contenttype:
- date_unlimited (configure as unlimited)
- date_repeat (configure as repeatable)
- date_all (configure as unlimited)

3. Add a computed field with the following "Computed Code"
Number of values = 1
Uncheck "Store using the database settings below", means: don't store the resulting values in the database

<?php

$node
->date_all = array();

if(
is_array($node->field_date_unlimited))
foreach(
$node->field_date_unlimited as $dtfield)
  if(isset(
$dtfield['value']))  $node->date_all[] = $dtfield;
 
if(
is_array($node->field_date_repeat))
foreach(
$node->field_date_repeat as $dtfield)
  if(isset(
$dtfield['value']))  $node->date_all[] = $dtfield;

//remark: the simple solution $node->date_all = array_merge($node->field_date_unlimited,$node->field_date_repeat);
//doesn't work:  adding an additional null value ...
?>

4. Hide the date_all field in the edit form in your own module, implementing hook_form_alter

<?php

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if(
$form_id == 'mycontenttype_node_form') {
      
$form['field_date_all']['#access'] = false;
  }
}

?>

Now you can use then date_all field in your views.
Exclude the date_unlimited and date_repeat from display in teaser and full node in your contenttype, show only the date_all field.

#6

subscribe

#7

Component:Date CCK Field» Code
Status:active» closed (won't fix)

Hi,
I am just indiscriminately closing all support requests with no activity for more than 1 year.
If you consider this to still be a valid issue / support request, feel free to re-open.
BUT,
if you are re-opening this issue, please provide specific details on how this issue can move forward.

Thanks.

#8

I realize this was a rather old post but was this for D6?

I've got two multi-value date fields and I'm trying to compute them into one but I'm not having any success.

<?php
$node
->date_all = array();

if(
is_array($node->field_date_unlimited))
foreach(
$node->field_date_unlimited as $dtfield)
  if(isset(
$dtfield['value']))  $node->date_all[] = $dtfield;

if(
is_array($node->field_date_repeat))
foreach(
$node->field_date_repeat as $dtfield)
  if(isset(
$dtfield['value']))  $node->date_all[] = $dtfield;
?>

Doesn't seem to work no matter the fields I attempt to use. Any suggestions that might get this going?

This is what I'm working with..... but I never get any output.

$node->date_all = array();

if(is_array($node->field_date_unlimited))
foreach($node->field_date_unlimited as $dtfield)
if(isset($dtfield['value'])) $node->date_all[] = $dtfield;

if(is_array($node->field_date_repeat))
foreach($node->field_date_repeat as $dtfield)
if(isset($dtfield['value'])) $node->date_all[] = $dtfield;