I\'m trying to implement page templating in my codeigniter application, templating is working fine for instance, i have a blog page, which i\'m trying to assign as my homepa
Your code
// Fetch the page template
$this->data['page'] = $this->page_m->get_by(array('slug' => (string) $this->uri->segment(1)), TRUE);
count($this->data['page']) || show_404(current_url());
the uri segment code
$this->uri->segment(1)
is looking first url segment, when you browse your site like www.yousite.come/blog it will work find but when you do www.yoursite.com 1st uri segment is missing so it will return false , so i will show 404 page.
Solution : You can just add the second parameter to the function like
$this->uri->segment(1,'blog');
now if the first url segment is missing it will not return false,it will return the default vlaue 'blog'
For more information about this you can see codeingitor documentation
application/config/routes.php
$route['default_controller'] = 'namecontroller';
The problem is that there's no URI segment when you visit www.mywebsite.com
. You can try setting the default value as:
$this->uri->segment(1 , 'blog')