![]() |
Slugs - Help me to understand - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Slugs - Help me to understand (/showthread.php?tid=49073) |
Slugs - Help me to understand - El Forum - 02-07-2012 [eluser]Mauricio de Abreu Antunes[/eluser] Hello, i’m trying to understand slugs. http://ericlbarnes.com/post/13129707173/codeigniter-slug-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! Slugs - Help me to understand - El Forum - 02-08-2012 [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. Slugs - Help me to understand - El Forum - 02-08-2012 [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. Slugs - Help me to understand - El Forum - 02-08-2012 [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 Slugs - Help me to understand - El Forum - 02-08-2012 [eluser]Mauricio de Abreu Antunes[/eluser] Thanks! I'll use id and slug. Slug is just for visualization and id for my where. |