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
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
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.
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)
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.
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.
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!
/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.