Welcome Guest, Not a member yet? Register   Sign In
Site setup - subcontrollers?
#1

[eluser]Unknown[/eluser]
I am setting up a site which splits neatly in two: a public site and a members-only site. Is it possible to set up CI so that, on the members side, controllers are called as
http://www.mydomain.com/members/directory
http://www.mydomain.com/members/jobadverts
http://www.mydomain.com/members/jobadverts/edit/23

where 'directory' and 'jobadverts' are my members-only controllers? The "/members/" segment merely indicates which part of the site you are on.

On the public side, all the pages are static and I use a single "public" controller and .htaccess routing to load each page as
http://www.mydomain.com/public/page1
http://www.mydomain.com/public/page2 ...

However this won't work on the members only side as I want different controllers for the various utilities. Would it be possible to call another controller from a base "members" controller?

I don't know whether to use .htaccess, the CI url helper or some other form of routing. Please help.
#2

[eluser]sparkling tux[/eluser]
As far as I know - there's no way to do something like $this->load->controller().
I use routing (system/application/config/routes.php) for such purpose.
#3

[eluser]mmm_broccoli[/eluser]
i never tried this but maybe you can put some logic into the routes file? If the uri class is loaded by then you could do this:

if ($signed_in) {
$route['whatever'] = 'members';
} else {
// load public
$route['this'] = 'public';
}

i have no idea if it would work or if it's possible. just the first thing that came to mind Smile
#4

[eluser]Crafter[/eluser]
Do you really need the member/public portion of the URL?

Unless they are seperate (sub)directories, you could lose them.

Just have
http://www.mydomain.com/directory

and let your directory decide what happens to logged in and not logged in users.
#5

[eluser]sparkling tux[/eluser]
To route depending on the status of the user (logged/not logged) I'd use pre-controller hook.
#6

[eluser]esra[/eluser]
Use FreakAuth in combination with a single set of controllers. FreakAuth allows you to create user groups. You can restrict access to controller methods, views, etc. based on the user group membership. You could create a public group for anonymous users and a separate member group for privileged users.

For example, you could display a menu to all users who are not logged on. Selected menu options would not be displayed unless the user was logged in and a member of the member group. You can handle this by wrapping individual menu options in conditional code (if/else statements) that check to determine if the user is a member of a specified group.

Find the FreakAuth thread and get the link to the dedicated site. There are tutorials there and the library comes with sample code.




Theme © iAndrew 2016 - Forum software by © MyBB