Welcome Guest, Not a member yet? Register   Sign In
Automatically generate navigation for some controllers
#1

[eluser]mscahill[/eluser]
I want to be able to create navigation automagically by searching a controller folder. Here's the catch: not all of the controllers in the folder are going to be included in the navigation. How can I differentiate between those that are included and those that are not?

Furthermore, there are three types of navigation in my application: general navigation, report navigation, and admin backend navigation. Some of these controllers fall into only one of these categories. Some of them won't show up in any of them.

Ideas? (Note: I'm looking at functionality similar to Wordpress's treatment of plugins, except without the majorly over-complicated loop system)
#2

[eluser]Pascal Kriete[/eluser]
I can think of two options, depending on the details.

One is to specify the controllers to exclude, since those will probably be static:
Code:
$this->load->helper('directory');

$ignore = array('admin', 'uninstall', 'end_world');

$controllers = directory_map(APPPATH.'controllers', TRUE);
$controllers = array_diff($controllers, $ignore);

// Build nav using $controllers array.

The other would be to override the router and give your controllers a prefix depending on the 'type' of controller. Then loop through all the controllers and grab those with the proper prefix.
#3

[eluser]mscahill[/eluser]
I'm trying to wrap my mind around all the different types of controllers that would be in my application, and then putting them in separate folders within the controller folder. That's probably the simplest solution...




Theme © iAndrew 2016 - Forum software by © MyBB