Unarbobmoow
New Member
I am trying to create a Content Management System using Codeigniter. I have a page where I display a list of article titles. When any user click on any of the article titles it will take the user to the details of that article in a separate page.I am displaying the article title list using the following code:\[code\] <a href="http://stackoverflow.com/questions/10545392/<?php echo base_url(); ?>article/<?php echo $row['article_id']; ?>"> <?php echo $row['article_title']; ?></a>\[/code\]When any user click on the above link it takes the article_id and go to the following controller Controller:\[code\]function index($id){ $this->load->model('mod_articles'); $data['records']=$this->mod_articles->list_articles($id); $this->load->view('view_article',$data);}\[/code\]Model :\[code\] function list_articles($id) { $this->db->select('*'); $this->db->from('article'); $this->db->where('article_id', $id); $query = $this->db->get(); return $query->row_array(); } \[/code\]Now when I display the result, in the browser's address bar the link looks like this-\[code\] localhost/cms/article/1 //<< here localhost/cms/ is my base_url\[/code\]According to this website , an example of good SEO friendly URL is \[code\]http://www.mysite.com/joomla-seo-tips\[/code\] .Now my question is how to make my URL look like \[code\]localhost/cms/article/my-article-title\[/code\] instead of showing the id of the article at the end of link?To acheive this should I query for my article titles instead of article ids or there are some better ways to do that? Please share your ideas on this. Thanks in Advance EditSo, before saving my content should I run following code get the \[code\]$article_slug\[/code\] and then save it? \[code\]function create_slug($string){$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);return $slug;}$article_slug= create_slug('My Name '); // as you suggested I will create a new column for this\[/code\]