Friends, I'm developing a blog on CI. And thinking about the SEO of the blog, I would like the URL rather than be presented this way:
I would like it to appear with the title of the post.
My Route looks like this:
$route['blog/(:num)'] = "blog/postagem/$1";
My controller is like this (do not worry about gambiarra, so I solve this issue of SEO I create the Models correctly):
class Blog extends CI_Controller {
public function postagem($id){
$this->db->where('id', $id);
$data['blog'] = $this->db->get('blog')->result();
$this->load->view('site/blog/postagem', $data);
}
public function home(){
$data['blog'] = $this->db->get('blog')-> result();
$this->load->view('site/blog/home' , $data);
}
View post:
<?php foreach ($blog as $post ) { ?>
<h1><?php echo $post->titulo; ?>- <small><?php echo $post->categoria;?></small></h1>
<p><?php echo $post->texto;?></p>
<hr>
<?php } ?>
View Home:
<?php foreach ($blog as $post ) { ?>
<a href="<?php echo site_url('blog/postagem');?>/<?php echo $post->titulo; ?>"><?php echo $post->titulo?></a>
<hr>
<?php } ?>
I would like to know how the CI will actually identify that the title in the url corresponds to an ID on the Route .. I can not understand, can anyone help me?