CodeIgniter Forums
How do I build URL's like this ({title}-{id})? - 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: How do I build URL's like this ({title}-{id})? (/showthread.php?tid=53007)



How do I build URL's like this ({title}-{id})? - El Forum - 07-06-2012

[eluser]Carmichael[/eluser]
Is there a CI function built that receives the id from the URL or do I have to create one by my self?

http://site.com/blog/welcome-to-my-blog-194/


How do I build URL's like this ({title}-{id})? - El Forum - 07-06-2012

[eluser]Aken[/eluser]
A specific function just for that? No. But you can use routes to separate it, or just pick apart the URI segment.


How do I build URL's like this ({title}-{id})? - El Forum - 07-06-2012

[eluser]Carmichael[/eluser]
Can you give me a exemaple?


How do I build URL's like this ({title}-{id})? - El Forum - 07-06-2012

[eluser]InsiteFX[/eluser]
application/config/routes.php
Code:
$route['blog/welcome-to-my-blog/(:any:)] = 'blog/welcome-to-my-blog/$1';

http://site.com/blog/welcome-to-my-blog/194



How do I build URL's like this ({title}-{id})? - El Forum - 07-17-2012

[eluser]Carmichael[/eluser]
[quote author="InsiteFX" date="1341619093"]application/config/routes.php
Code:
$route['blog/welcome-to-my-blog/(:any:)] = 'blog/welcome-to-my-blog/$1';

http://site.com/blog/welcome-to-my-blog/194
[/quote]
I want a - between the title and the id.
Like http://blog.se/welcome-to-my-blog-1

That's not possible?