0

How can I print a date like JAN 28 in the provided Event list, using Drupal Views?

The example image taken from the Drupal website is attached below

enter image description here

0
  1. Create a new content type for events (e.g. 'events') and add starting and ending date fields. You can create now create your desired event content.

  2. Add a new calendar view from the existing template in the calendar module(admin/structure/views add-template). From the list, you should select "A calendar view of the 'field_yourfieldname' field in the 'node' base table."(Display type of the view: Month)

  3. In the edit mode of your calendar view, under filter criteria, select the event content type that you created above. Also add a contextual filter - 'Content: Nid'. Save the view.

  4. Create a new view for your event listing. This view should have a page display. Under filter criteria, select the event content type that you created above. Add 'Content: Nid' as a new field and tick the option 'Exclude from display' in the configuration page. Add another field, 'Global: PHP', for grabbing the current date and passing it as argument to the calendar view. you should write 'print date("Y-m")' in the Output Code field and tick the option 'Exclude from display' in the configuration page.

  5. Embed the calendar view in your event listing by adding a new field: 'Global: View'. (See the attached image for the configuration of this field.) Here you should specify the name of your calendar view in the View setting section and also specify the views display type. Then, you should add '[%php]/[%nid]' as a contextual filter for the calendar view. Save the view. Your customized event listing is now ready!

0

Navigate to /admin/config/regional/date-time/formats/add and add a new date format. For the replacement pattern use: M t then click save.

then navigate to: /admin/config/regional/date-time and create a human readable name for your custom date format, then select the date format you created inside the select box. click save.

Create your view add your date field and then in the field settings give it your custom date format for the format section.

Style with CSS. You're done.

You may need to create two different date formats to achieve the styling you want. One for M and one for t. Then add your date field to the view twice and add the date formats on the fields, then you can easily target the two different date elements and use css to position them the way they are in the image you provided.

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.