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!
Does anyone know how to display the month as text in a pagelist block?
See attached file.
Thanks you!
Hi KD ilkington,
Thanks for your reply and clear description!
Will try it out and will update you :)
Thanks again! Happy easter!
Thanks for your reply and clear description!
Will try it out and will update you :)
Thanks again! Happy easter!
An alternative is using the core date helper to format the dates.
In the previous code example:
- find this code
- replace with this code
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());
Really helpful post, saved me hours
Thank you
Thank you
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...
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...