Welcome Guest, Not a member yet? Register   Sign In
Not new but trying to figure out how to go about this (Controller + Route / Remap ? )
#1

[eluser]internut[/eluser]
I've not been too active with CI lately but have done some great things with it. I'm trying a different approach.

I'm looking to basically have a way to have from the default install of CI have the Welcome / Index controller + Another controller handle a lot of the front of the site.

Reason for my madness is to have pages all created via DB records.

In short:

.com/ <--- Index Page (welcome.php CLASS)

.com/any-folder/ <--- Routed to: (interior.php CLASS)

.com/any-folder/sub-folder-name/ <--- Routed to : (interior.php CLASS)

The input that comes from segment 1 & 2 (or 3 / 4 / 5 etc) call the DB and populate what interior.php will output via the data grabbed via model and used as output in the view.

Basically allowing a very dynamic site based off DB records. Not creating a controller for every area of the site.

.com/about-us/ (about-us.php controller)
.com/contact-us/ (contact-us.php controller)
.com/help/ (help.php controller).

If I'm not clear let me know Smile

J

Any thoughts?
#2

[eluser]internut[/eluser]
Basically just want the string if not index to be returned and I can parse it from there if its not a URI Segment string.
#3

[eluser]tomcode[/eluser]
Guess You mean this :

1. Your site's home is handled by controller welcome.php
2. the rest is handled by controller interior.php

To achieve this change Your config/routes.php :
Code:
$route['default_controller'] = "welcome";
$route[':any'] = "interior";
#4

[eluser]internut[/eluser]
Thanks Tomcode..

While that did work I wonder if I should go the _remap method.

The route method does not seem to then let me have an /admin/ controller folder and be able to call that for an admin area. That basically behaves normally.

Kind of want if a controller is named / available then use that. If not fall back to interior or welcome controller than handles the front end or is the default.

Though if a controller is present use that.

Am I asking to much of CI?

Jason
#5

[eluser]tomcode[/eluser]
This should do it Wink

Code:
$route['default_controller'] = "welcome";

$route['admin'] = "admin";
$route['admin/(:any)'] = "admin/$1";

$route[':any'] = "interior";
#6

[eluser]internut[/eluser]
You're a routing fool!

and awesome!

Thanks so much! I was thinking along those lines, cut couldn't put it together Smile

Again, thx!




Theme © iAndrew 2016 - Forum software by © MyBB