Display date as text in pagelist

Permalink 1 user found helpful
Hello,

Does anyone know how to display the month as text in a pagelist block?
See attached file.

Thanks you!

1 Attachment

View Replies: View Best Answer
MrKDilkington replied on at Permalink Reply 1 Attachment
MrKDilkington
Hi restyles,

I recreated the example from the screenshot you attached.

You can use the code to make a custom block template for the page list.

- copy view.php
concrete\blocks\page_list\view.php
- copy it to (create the folders if they aren't there)
application\blocks\page_list\templates
- rename the file to day_month.php

Add some space at line 85 and then paste this code into day_month.php at line 86.
- it should look like this:
https://gist.github.com/anonymous/3e8c9498efbf51d05083#file-day_mont...
<?php
//http://php.net/manual/en/datetime.format.php...
//http://php.net/manual/en/function.date.php... - date formats
$date_day_number = date_create($date);
$date_day_number = date_format($date_day_number, 'd');
$date_month_text = date_create($date);
$date_month_text = strtoupper(date_format($date_month_text, 'M'));
?>
<style>
    .day_date_month {
        width: 42px;
        text-align: center;
    }
    .day_date_month .day {
        font-weight: bold;

I attached a screenshot of what the code prints to the page.

You can experiment with the formatting and replace the existing date with it.
https://gist.github.com/anonymous/3e8c9498efbf51d05083#file-day_mont...
restyles replied on at Permalink Reply
Hi KD ilkington,

Thanks for your reply and clear description!
Will try it out and will update you :)

Thanks again! Happy easter!
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
An alternative is using the core date helper to format the dates.

In the previous code example:
- find this code
$date_day_number = date_create($date);
$date_day_number = date_format($date_day_number, 'd');
$date_month_text = date_create($date);
$date_month_text = strtoupper(date_format($date_month_text, 'M'));

- replace with this code
$date_month_text = strtoupper($dh->formatCustom('M', $page->getCollectionDatePublic()));
$date_day_number = $dh->formatCustom('d', $page->getCollectionDatePublic());
JonRimmer replied on at Permalink Reply
JonRimmer
Really helpful post, saved me hours

Thank you