Can you show me how I would setup my blog article page to have the date in the URL automatically. I need this because there will most likely be blog articles with the same title.
ie: Article name. This week’s special offers.
becomes: /blog/this-weeks-special-offer-08-10-22
texnixe
October 20, 2022, 10:57am
2
You could add this via a page model: Page models | Kirby CMS
You would have to overwrite the static create
method in your model. See the original method for details:
Seems a bit too much for my level. I will have to encourage the client to manually change the URL when creating a post
Create a model for your article page (make sure this is named like the blueprint for your article pages, I’m assuming article
here
class ArticlePage extends Page
{
/**
* Creates and stores a new page
*
* @param array $props
* @return Page
*/
public static function create(array $props): Page
{
$props['slug'] = $props['slug'] . '-' . date('Y-m-d');
return parent::create($props);
}
}
1 Like