Slug ID's with the same name?
- by James Jeffery
I want to create slug URL's from a users title in my system.
If a user types "The best way's to get slim; period!", then I want the slug to be "the-best-ways-to-get-slim-period".
Also, if someone has already created a page with that title I want the slug to be "the-best-ways-to-get-slim-period-1".
My question is how can I check the database before a record is created? Ok, obviously I am going to have to perform a check in the database, and then a write. That's 2 queries. Is this the normal way to do it?
Also, are there any conventional regular expressions for filtering non alpha/number characters and replacing spaces with hyphens?
Any help is much appreciated.
Thanks.