Welcome Guest, Not a member yet? Register   Sign In
Troubles with "Build a CMS in Codeigniter" on tutsplus
#1

[eluser]Servan[/eluser]
Hello,
I'm trying to learn Codeigniter by myself, so i'm pretty sur that something is missing in my code or i made a mistake somewhere.

i just finishing this tutorial "Build a CMS in Codeigniter on tutsplus" and there is a bug that made me crazy.
Everything works except ...
In this tutorial there is a Frontend and an Admin section. In the video the base url load a "homepage section" and a dashboard section is loaded as admin base url.
In my case base url get me a 404 and the admin root url load the "page section" (and not the dashboard).
I've already try to copy/past some parts of the tutorial files in mine without success.
#2

[eluser]InsiteFX[/eluser]
Well 9 times out of 10 the tutorials are out dated and will not work with the new CodeIgniter versions
with out modifications.

Without seeing any code it will be very hard to even try to track down your problems.
#3

[eluser]Servan[/eluser]
Actually this tuto have been done in january 2013, so yes it might be a little exceeded.
I've put all my files on Github, because i don't know which file is the source of my problem.

Here is the link in case someone have a little bit of time to loose on my error Big Grin
https://github.com/Svann/CI_CMS
#4

[eluser]InsiteFX[/eluser]
Your frontend controller and the other one belong in core not libraries.

You could take those to classes and add them to your MY_Controller
#5

[eluser]Servan[/eluser]
Thanks InsiteFX for the advice.

For my error i've done some changes in my "page.php".
The pages data are loaded with the slug in the uri but there's nothing specified for an url whith no slug, like my base url.
So i changed this :
Code:
$this->data['page'] = $this->page_m->get_by(array('slug' => (string) $this->uri->segment(1)), TRUE);
count($this->data['page']) || show_404(current_url());

Into this :
Code:
if($this->uri->segment(1)) {
$page_template = $this->uri->segment(1);
} else {
$page_template = 'homepage';
}

$this->data['page'] = $this->page_m->get_by(array('slug' => (string) $page_template), TRUE);
count($this->data['page']) || show_404(current_url());

It looks like it's working but i'm not sure this is the best way.
#6

[eluser]InsiteFX[/eluser]
Did you create the routes for the controllers?
#7

[eluser]Servan[/eluser]
i use the same "route.php" than in the tutorial
Code:
$route['default_controller'] = 'page';
$route['404_override'] = 'page';
$route['article/(:num)/(:any)'] = 'article/index/$1/$2';
#8

[eluser]InsiteFX[/eluser]
Segments work like below.
Code:
$this->uri->segment(1)  // = Controller
$this->uri->segment(2)  // = Controller Method/Function

In your case if the template to load is dashboard then you would pass in dashboard on the url.





Theme © iAndrew 2016 - Forum software by © MyBB