0

I'm using the auto generate entry titles from custom fields option, eg

{eventVenue}-{seriesName}-{eventDate}

But sometimes the eventVenue isn't known at the time of creating the entry, so you can end up with a slug of tba-winter-2017-04-15. But when they later update the eventVenue the slug is not right. It's not very easy to explain to users that they can/should change the slug and for them to remember to do so.

I fully understand the thinking that in many cases the slug shouldn't change due to existing links that may exist and will now break, but is there a way to override the default?

In ExpressionEngine I used an addon, "Title Master" that had the option to update url on edit or not.

2
  • Changing the slug (and URL) after the entry has already been published is a bad idea – you'll hurt your SEO as well as annoy any users who might've shared, linked to or bookmarked the old URL. You should consider using a different URL format altogether, that isn't dependent on the event venue, or maybe just live with the fact that some of the entries will have "incomplete" URLs. Commented Apr 28, 2017 at 20:01
  • The reason to include the date and the event venue and series name is because the venue and series are used repeatedly (and sometimes on the same day) and the combination of all three ensures the url is always unique and readable. I prefer url's to be readable rather than random or obscure.
    – Paul Frost
    Commented Apr 29, 2017 at 13:01

2 Answers 2

1

You could write a simple plugin that listened to the onSaveEntry and perform whatever custom business logic you require for slugs.

Don't re-save that entry going through craft()->entries->saveEntry(), though, or else you'll create an infinite loop by firing the onSaveEntry event again.

You could either call craft()->elements->saveElement() directly or use use QueryBuilder to directly update the database with the slug.

1
  • Thanks Brad, but writing plugins is beyond my skill set at the moment. But I suspect I'm going to have to learn to at some point.
    – Paul Frost
    Commented Feb 27, 2017 at 19:50
1

It could be as easy as training your users to delete the slug. If you delete the slug and save the entry will update it.

1
  • My experience is that users forget, and the more automation you include makes it easier for everyone.
    – Paul Frost
    Commented Apr 29, 2017 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.