# Use date as title in panel

**URL:** <https://forum.getkirby.com/t/use-date-as-title-in-panel/25163>\
**Category:** Questions\
**Tags:** v3\
**Created:** [April 3, 2022, 7:51am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163 "2022-04-03T07:51:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivo](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@Vivo](https://forum.getkirby.com/u/Vivo)\
**Post date:** [April 3, 2022, 7:51am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163/1 "2022-04-03T07:51:44Z")

</div>

I’ve updated a website from Kirby 2 to 3. On a page template I use a date field that automatically alters the title of the page in the date.

In Kirby 2 I used a plugin for that, but in Kirby 3 this is not working. So I wrote it als a hook in the config file. But somehow I don’t get this to work.

What am I doing wrong? Or beter, is there another way in Kirby 3 to accomplish the goal (have a date field als title.

```auto
  'page.update:after' => function ($page) {
        
  			if ($page->intendedTemplate() === 'event') {
  			
    			$title = $page->date()->toDate('Ymd');
    			$uri = str::slug($title);
    			// Stop if there's a sibling with same date
    			if (! $page->parent()->find($uri)) {
      				// otherwise update title and URI
      				$page->update(compact('title'));
      				$page->move($uri);
    				}
  			}
  				
  				

        }

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 3, 2022, 8:15am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163/2 "2022-04-03T08:15:31Z")

</div>

The hook will always result in an error, because you are not redirected to the new page.

I’d recommend the Custom Add Fields plugin:

> **[Custom Add Fields](https://getkirby.com/plugins/steirico/custom-add-fields)**
>
> This plugin allows to define the fields shown on Kirby's page add dialog in the corresponding page's blueprint.

With this plugin, you can even skip the title completely, I think.

---

<div class="post-metadata">

**Author:** ![Vivo](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@Vivo](https://forum.getkirby.com/u/Vivo)\
**Post date:** [April 3, 2022, 9:08am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163/3 "2022-04-03T09:08:37Z")

</div>

Ok. But the idea is that if the date is changed later on, then the title is updated as well.

Can the title field be an date field?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 3, 2022, 9:17am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163/4 "2022-04-03T09:17:02Z")

</div>

Oh, ok, but that means that the URLs to these pages will keep changing as well whenever a user changes the date? Just wondering if that is a good idea… What is your use case? And why does the date have to be in the title/slug at all? What happens if there are multiple events with the same date?

But as I wrote above, when you change the slug in a hook, you will not be redirected to the new location and your users will see an error.

---

<div class="post-metadata">

**Author:** ![Vivo](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@Vivo](https://forum.getkirby.com/u/Vivo)\
**Post date:** [April 3, 2022, 9:39am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163/5 "2022-04-03T09:39:28Z")

</div>

True. That might not be a good idea, as you explained.

The reason that I set it up like this, is that the page order is always by date. It’s an event calendar. So it’s logical to have a chronicle order of te events in the panel and content folder. But maybe this can be achieved in a different way.

Thank you for your feedback!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 3, 2022, 9:49am UTC](https://forum.getkirby.com/t/use-date-as-title-in-panel/25163/6 "2022-04-03T09:49:33Z")

</div>

You can sort your pages by date in a pages section, so no need to have the title.

> **[Pages section](https://getkirby.com/docs/reference/panel/sections/pages#sorting)**
>
> List and edit subpages

In the frontend, it’s not an issue anyway.

A consistent URL will also be better for SEO reasons, otherwise, you would have to keep track of them all the time and use redirects.
