Slugs - Help me to understand |
[eluser]Mauricio de Abreu Antunes[/eluser]
Hello, i’m trying to understand slugs. http://ericlbarnes.com/post/13129707173/...ug-library This post tells me to insert my new with a slug like ‘help-me-with-slugs’. Ok, i understood this part. I can not understand how i can select data from a slug? Code: select * from news where slug = 'help-me-with-slugs'; Ok, i can get data from this, but when i insert a slug, it can be duplicated in the database. Is necessary to validate my title? Btw, Code: ...where slug = 'help-me-with-slugs' Performing a query with no primary key like http://www.site.com/news/24/help-me-with-slugs where 24 is ‘help-me-with-slugs’ ID. And what about routes if i get ‘help-me-with-slugs’ pagination? Thanks!
[eluser]Mauricio de Abreu Antunes[/eluser]
Ok, i'm having problems with duplicated slugs. Do i need to check title before insert or update my table? It means unique titles in my table.
[eluser]Mauricio de Abreu Antunes[/eluser]
I can not delete post from CI forum. So, i'm editing it for this reason. Page was not found and i sent my post a lot of times and its duplicated. Sorry.
[eluser]meigwilym[/eluser]
You can either check for duplicates before you insert, or use (as in your example: http://www.site.com/news/24/help-me-with-slugs) a get_where('id', 24), and (programmatically) ignore the slug. A more complicated method is to check for duplicates when writing the content. Wordpress have a system where after you type the title and the text box loses focus, it fires and AJAx call to the server and is given a slug in return. This is then added to the page, probably in a hidden input. Mei
[eluser]Mauricio de Abreu Antunes[/eluser]
Thanks! I'll use id and slug. Slug is just for visualization and id for my where. |
Welcome Guest, Not a member yet? Register Sign In |