4

I have set up events with calendaring on my site along with an agenda view. Each event has a date, possible start time, possible end time, and possible end date/time.

Therefor I have two date fields associated with this content type - field_date(value, value2) where value is the start date/time and value2 is the end date/time.

How can I show dates and times separately so that I can use CSS to make a pretty agenda view using something like the following markup?

<div class="item even">
<span class="event-month-day">September 21</span><br>
<span class="event-title">Fall Solstice (all-day-event)</span>
</div>

<div class="item even">
<span class="event-month-day">October 18</span><br>
<span class="event-title">Fall Festival</span><br>
<span class="event-time">10:00 am to 11:00 pm</span>
</div>

<div class="item even">
<span class="event-month-day">October 21-25</span><br>
<span class="event-title">Sign up for pie eating contest</span><br>
<span class="event-time">9:00 am to 4:00 pm</span>
</div>

I've looked at using the formatter module (explained here: how do I add extra classes to a date field at views?) but could not figure out how to use the formatter with two date variables for my Event content type.

Any help?

  • I wanted to clarify, when you said you could not figure out how to use the formatter with two date variables, does that mean that there was no value2 token available? – Beebee Oct 14 '13 at 15:00
  • I believe there is always a value2. I am trying to separate the date and the time of each and display them outside of the regular Drupal formats(short, medium, long). So instead of "Monday, October 14, 2013 - 3:13pm" or "10/14/1013 - 3:13pm" I want to display each granulation of time separately (Month, Day, Year, and time) and apart from one another, display the date "October 14" on one line within one span tag, and then the time "3:13pm" on another line within another span tag (or not shown at all if it is an all day event). I hope this makes sense. – MikeOlee Oct 14 '13 at 15:20
1

I had to do something similar recently. I created a views page and outputted the same Date field twice. I also had two different date formats set up. One showing only Month and Day, and the other format only showing time. Then I assigned the first "Date" field the date format, and the other the "time" format. Afterwards I was able to style them as I pleased.

In the field date settings, I had it to where it also showed multiple, but only first and last with a " - " seperator in order to output "September 11 - September 14" for example. The same can be done for the time formatted field.

1

Create two Formats under the below link one for the date and second for the time.

admin/config/regional/date-time/formats/add

After Create 2 formats as suggested, Add Date types of those two format under the below link

admin/config/regional/date-time/types/add

Now go to your view page and add that date field twice with one format of date and one format of time.

Make one of that field exclude from the display and in the other field you can use rewrite result and pass the structure what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.