EllisLab text mark
Advanced Search
noob question
Posted: 28 June 2007 01:06 AM
Joined: 2007-06-28
34 posts

Hey there.. noob here.

I am trying to build a 3 level deep url loading a view at each stage.

My controllor for a user dashboard: dash.php

function index() {
= array(
'morecontent' => '',

$content $this->load->view('dash/index',$data,true);

This gives me http://somesite.com/dash

So there is sub section of the dashboard called the account settings

function settings() {
= array(
'morecontent' => $this->load->view('dash/settings',array(),true),

$content $this->load->view('dash/index',$data,true);
$this->wrapOutput($content,"Dashboard > Settings","dash");

So above I am loading the settings view into the dash view… and it gives me http://somesite.com/dash/settings

So I want to now load a payment view into settings.. and have the final url be http://somesite.com/dash/settings/payment

My instinct is to create a function called payment() inside of the settings() function.. sort of like nesting folders in a file strcture… but that is not how CI works.

I need to have 3 or 4 subpages inside of settings, that is inside of dash… How best to accomplish this?

Sorry if it does not make sense.. I am thinking like a file system.. if I want to group pages into categories I just nest the file structure… how does one nest functions in a controllor to created nested url’s?

It is important for us to use this 3 level structure as /dash will have many 2nd level pages which in turn have more 3rd level pages. like /dash/profile/bio and /dash/profile/privacy   etc.

Posted: 28 June 2007 02:35 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-06-28
34 posts

Sorry.. after a few more searches I found it.. http://www.ellislab.com/codeigniter/user-guide/general/controllers.html#subfolders smile

Posted: 28 June 2007 07:32 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-07-10
485 posts

Another approach is to use the Modular Separation extensions on the Wiki. Also do a search for modular separation on the forums. This allows you to create a application/modules/ directory structured like so:


You can add any number of modules. Dash could be a base controller (do a search for base controller) and all other controllers could be extended from the base controller, allowing base controller code to be shared by your module controllers. You dashboard could use a master view or template and the modules could be loaded into the master view/template.

You might also want to read more about creating routes in the user guide and do a search on the forum for additional examples, especially examples using regular expressions (regex).