This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi dears, I am trying to get a news session for my website. I am using slug to point at the particular news details page. However, it is possible that there can be a duplicate slug in the future as the slug depends on the title of the news. I wanna add another identifier value depending on the post date of the news such that it minimize such possibility. So the URL will be something like www.mywebsite.com/news/3-5-2017/this-is-the-news-title instead of just www.mywebsite.com/news/this-is-the-news-title .
Thats one way i can think of, please help to contribute a solution to this, and at the same time if there are people that can suggest a better convention to deal with this matter please let me know too. Thanks a lot!
What exactly is the problem? You can avoid duplication of slug by adding "unique" validation rule to this field. Add a date in the URL is also an acceptable solution, just make url of page like this "/news/:date/:slug".
You have to use the Sluggable trait, with that you wont have duplicated slugs:
In the above example, if the name column was set to Cheyenne, as a result the slug column would be set to cheyenne, cheyenne-1, or cheyenne-2, etc before the model is created.
Last updated
How did you fix this? I don't want urls like title-of-slug-1
title-of-slug-2
title-of-slug-3
. I want the date in the url like: url.com/12-sep-2017/title-of-slug/
How do I define what :date should do?
I'm just using the builderPlugin.
Edit: For now, i just manually hardcoded the url with
/portfolio/gallery/{{ gallery.date|date("d-m-Y")|lower }}/{{ gallery.slug }}
Last updated
1-7 of 7