• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not new but trying to figure out how to go about this (Controller + Route / Remap ? )

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


Any thoughts?

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.

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 :
$route['default_controller'] = "welcome";
$route[':any'] = "interior";

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?


This should do it Wink

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

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

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

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!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.