You can access a blog post also at blog/id/{id}, however, the generated URL is built into the module with the blog_post_model::get_url method (around line 608 in the fuel/modules/blog/models/blog_posts_model.php file). So to change it, you would need to change that method.
I changed this line $url = $year.'/'.$month.'/'.$day.'/'.$this->slug;
to this $url = $this->slug;
Now, posts have the desired href: http://www.mywebsite.com/blog/my-post but now, when i click on one of the post, it don't show the clicked post but the same page with all posts.
You will probably need to change the main fuel/modules/blog/controller/blog.php file since it looks for those URI parameters to query the database for the post.
Well, I have figured this out and wanted to help you guys.
You need to do little change on two files:
1) In fuel/modules/blog/models/blog_posts_model.php
Find the get_url method and change
$url = $year.'/'.$month.'/'.$day.'/'.$this->slug;
to
$url = $this->slug;
2) Now, open fuel/modules/blog/controller/blog.php
near line no. 20 just add this below code after $view_by = 'page';
// custom code for getting blog post by slug ( without date )
if ($this->fuel->blog->uri_segment(2) && $this->fuel->blog->uri_segment(3)=="")
{
$view_by = 'slug';
$slug = $this->fuel->blog->uri_segment(2);
if ($view_by == 'slug')
{
return $this->post($slug, $year, $month, $day);
}
}
//end of custom code for getting blog post by slug ( without date )
That's it.
It took time for to figure this out but finally i did it.
Comments
I changed this line $url = $year.'/'.$month.'/'.$day.'/'.$this->slug;
to this $url = $this->slug;
Now, posts have the desired href: http://www.mywebsite.com/blog/my-post but now, when i click on one of the post, it don't show the clicked post but the same page with all posts.
Well, I have figured this out and wanted to help you guys.
You need to do little change on two files:
1) In fuel/modules/blog/models/blog_posts_model.php
Find the get_url method and change
$url = $year.'/'.$month.'/'.$day.'/'.$this->slug;
to
$url = $this->slug;
2) Now, open fuel/modules/blog/controller/blog.php
near line no. 20 just add this below code after $view_by = 'page';
// custom code for getting blog post by slug ( without date )
if ($this->fuel->blog->uri_segment(2) && $this->fuel->blog->uri_segment(3)=="")
{
$view_by = 'slug';
$slug = $this->fuel->blog->uri_segment(2);
if ($view_by == 'slug')
{
return $this->post($slug, $year, $month, $day);
}
}
//end of custom code for getting blog post by slug ( without date )
That's it.
It took time for to figure this out but finally i did it.
I hope this will be helpful.
Thanks!