Jump to content

Show Modified date of a page in page list in backend


tires
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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;

	}

});

 

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...