Welcome Guest, Not a member yet? Register   Sign In
news story titles in urls
#4

[eluser]Flayra[/eluser]
CI has a built-in converter, url_title() that takes your title as a parameter and returns "friendly" url:
Code:
$title = 'The Greatest Blog Post ever(tm)';
$urltitle = url_title($title); // returns 'the-greatest-blog-post-ever-tm'
You then save this url in your database together with your blog (or news, or whatever) post, and when it's called you search for that string and return that post.
Code:
// Assuming the called URL is something like news/show/the-greatest-blog-post-ever-tm/
$title = $this->uri->segment(3);
$q = $this->db->getwhere('blog', array('urltitle' => $title));
// Show it
I hope this helps clarify it


Messages In This Thread
news story titles in urls - by El Forum - 06-22-2007, 07:54 AM
news story titles in urls - by El Forum - 06-22-2007, 08:33 AM
news story titles in urls - by El Forum - 06-22-2007, 08:43 AM
news story titles in urls - by El Forum - 06-22-2007, 09:20 AM
news story titles in urls - by El Forum - 06-22-2007, 10:18 AM
news story titles in urls - by El Forum - 06-22-2007, 06:06 PM
news story titles in urls - by El Forum - 06-23-2007, 02:26 AM
news story titles in urls - by El Forum - 06-23-2007, 04:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB