Slug update
-
The automatic amendment to the “slug” (appending “-2” to the existing slug) is not helpful. On our u3a (activities for retired people in the UK) site, we find that several of our group coordinators create their monthly events by simply duplicating their previous “placeholder” event. They are not technical people, and don’t even consider the slug. But by the end of the year, their slug has the form “monthly-event-2-2-2-2-2-2-2-2-2-2-2” – technically ok, but looks dreadful in the browser.
My suggestion would be; first form the usual automatic slug from the title (“monthly-meeting”) in the above example, and use it if it doesn’t cause a duplicate entry. Otherwise, loop through the characters in the slug, starting at the end. For each, if the character is a number, continue to the next character. If not, then if it’s a dash, take the numeric characters after the dash, add 1, and replace those characters (loop around, adding 1 each time, if the new slug is a duplicate entry). Otherwise, append “-2” to the slug.
That should result in, for example, the 5th duplicate having slug “monthly-event-5”
The final logic might be just a little more complicated, but hopefully you get the idea, which is to stop the needlessly untidy slugs that your Plug-In is currently generating. Apart from that, we are extremely pleased with the Plug-In.
Thanks, Dave
The topic ‘Slug update’ is closed to new replies.