Jump to content

Custom render function for field value in template


regesh
 Share

Recommended Posts

How to make a hook that will customize value of field and output function result.
I want for field date (in templates) to display values like: yearstaday or today or in other ways 21 may(in my lang) 2021.
So for that i got function to parse Y-m-d to what i need. But i do not how to create hook. Thanks a lot!

Link to comment
Share on other sites

If you want dates to output in other languages, I'd start here:

And perhaps also look at this:

If you want all dates from a particular field to be formatted the same on output, look at the Details tab for the data field.

To format dates on a template, use PW's $datetime->date() (see https://processwire.com/api/ref/wire-date-time/date/).

Or you could get the timestamp (the unformatted date) with $page->getUnformatted("date_field") and then use PHP's date functions – particularly strftime().

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...