Jump to content

Recommended Posts

Posted

Hi!

I inserted {name} {modified} in the field "List of fields that is displayed in the page list at backend" (in german "Liste der Felder, die in der Seitenliste im Admin-Bereich angezeigt werden") at advanced tab in the template settings.

The page are now displayed as:
mypage 123 1598443140

What do i have to insert to get a formatted date like 9.2.2021?

Thanks!

Posted

One approach would be to use a hook in ready.php, adapting the method described in this post:

You'd probably end up with something like this (not tested):

wire()->addHookAfter('ProcessPageListRender::getPageLabel', function($event) {
    
    $page = $event->arguments('page');

	$modifiedFormatted = date("j.n.Y", $page->modified);

	$event->return = $event->return . ' ' . $modifiedFormatted;

});

 

  • Like 3
Posted

I don't know of a way to do this with the template settings.

However, if you want to the date to appear for only a particular template, you could add a check like this:

wire()->addHookAfter('ProcessPageListRender::getPageLabel', function($event) {
    
    $page = $event->arguments('page');

	// Check template
	if($page->template->name == 'relevant-template') {

		$modifiedFormatted = date("j.n.Y", $page->modified);

		$event->return = $event->return . ' ' . $modifiedFormatted;

	}

});

 

Posted
On 2/11/2021 at 9:28 AM, tires said:

So it is not intended to do this in the template settings?

The AdminOnSteroids module has a feature that allows formatted dates in Page List via the template settings. See the "Date filter" section in the documentation here.

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
  • Recently Browsing   0 members

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