Welcome Guest, Not a member yet? Register   Sign In
Custom CMS and (:any) Route Predicament
#1

[eluser]Vheissu[/eluser]
My CMS is nearing completion (functionality wise) and although it currently works I have a few issues.

My setup:

* Codeigniter 2.0 (latest version)
* Modular Extensions (latest version)
* PHP 5.3.0

I have a module called pages with a pages controller that contains a _remap remap function and in my routes.php I have the following code:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// All default requests go to pages
$route['default_controller']   = "pages";    // Pages controller is the default controller

// Login link
$route['login']                = "auth";
$route['logout']               = "auth/logout";

// Admin control panel
$route['admin']                = "admin";

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

// Every request to the pages controller
$route['(:any)']               = "pages";


/* End of file routes.php */
/* Location: ./application/config/routes.php */
My issue is that although accessing pages like; /about-us or /home works quite fine, I've noticed that the (:any) routing rule is stopping direct access to actual controllers and modules.

So if I have an auth module and go /auth/login - I find that the (:any) is routing this to my pages controller _remap function and not actually calling the module controller, this also seems to be the case for controllers in the root application controllers directory, is there a better way?

I tried using 404_override in my routes file instead of (:any) but it didn't seem to work. Is there a way to check if a controller / module exists first before loading up a page? And also, how would I handle pages with the same name as modules and controllers in my application?

Appending /page/page-name to the URL would probably be a fix, but I want them to just be /page-name instead.
#2

[eluser]wiredesignz[/eluser]
Modular Extensions uses $route['404'] at the current time. I will be updating it soon to use the CI2.0 $route['404_override'] instead.
#3

[eluser]Vheissu[/eluser]
[quote author="wiredesignz" date="1288090734"]Modular Extensions uses $route['404'] at the current time. I will be updating it soon to use the CI2.0 $route['404_override'] instead.[/quote]

Ah, thank you so much. I just took a look at PyroCMS code and noticed that it was using just 404 too. It now works and does all of the checking for real modules / controllers first as a 404 redirect would.

My question stands however of how do I have page names that share the same name as a controller / module. Will it always access the page first or the module / controller?
#4

[eluser]Phil Sturgeon[/eluser]
[quote author="Vheissu" date="1288090831"]My question stands however of how do I have page names that share the same name as a controller / module. Will it always access the page first or the module / controller?[/quote]

What do you mean by that? The 404 route will work just like any other Controller and/or Method call. Set the title however you normally would. Smile




Theme © iAndrew 2016 - Forum software by © MyBB