wintercms / wn-pages-plugin

Static Pages plugin for Winter CMS
https://wintercms.com/
MIT License
9 stars 22 forks source link

How to show "Last Modified" date on frontend #39

Closed oim37 closed 9 months ago

oim37 commented 9 months ago

Hello,

image

help please, can't find how to show this data on frontend? Want to show this near title - this is very useful information - shows the relevance of the article.

Thank you very much in advance.

bennothommo commented 9 months ago

@oim37 the timestamp is accessible via this.page.mtime in Twig. You can do something like this in the Twig code to present it nicely:

Last updated on {{ this.page.mtime|date('l jS F, Y') }}
oim37 commented 9 months ago

I'm very grateful, but he's unlike {{ this.page.title}} where it takes data from the page, it shows the modification date of the template file itself.

On all pages, today's date of editing the template file itself is displayed, and the date of editing the pages themselves is completely different.

oim37 commented 9 months ago

I try {{page.mtime|date('l jS F, Y')}} and it workin good for static pages showing - Saturday 5th August, 2023

thanks for the help.

oim37 commented 9 months ago

The only thing is that when switching languages, I have 5 of them, it always writes in English:

Saturday 5th August, 2023 Monday 13th February, 2023

bennothommo commented 9 months ago

Whoops, sorry, my bad! Good job on working out the right one! :)

I'm not sure how translations work with dates unfortunately. @mjauvin might be able to assist with this.

mjauvin commented 9 months ago

use international format:

{{ page.mtime | date('Y-m-d') }}
oim37 commented 9 months ago

Yes, I did just that, just for interest, I searched (September) in winter files and find this path domain.tld/modules/system/lang/ with complete translations.

more domain.tld/modules/system/lang/de/client.php 'months' => ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], or more domain.tld/modules/system/lang/ru/client.php 'months' => ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],

That's me, simply, thank you!