![]() |
Determining which module to load with Matchbox modules - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Determining which module to load with Matchbox modules (/showthread.php?tid=8259) |
Determining which module to load with Matchbox modules - El Forum - 05-12-2008 [eluser]PeteZahut[/eluser] Suppose you have this url: http://www.somedomain.com/somename/ I'd like to determine which matchbox-module to load based on the "somename" segment. The segment is checked against the database where the type is pulled: "select type from content where uri = 'somename'" if the type is "page", go to the page-module and load "show_page" with seg 1 as value if the type is "form", go to the form-module and load "show_form" with seg 1 as value if the type is "module", go to the module using the name in segment 1 and load "index" I know you can achieve this with custom routes, but how can this be achieved without specifying the custom routes? Determining which module to load with Matchbox modules - El Forum - 05-12-2008 [eluser]wiredesignz[/eluser] Using Matchbox modules without routes this would require a redirect() after choosing the final controller. If you look at Modular Extensions HMVC you will see this can be achieved using a default controller with CI's remap() method and then loading or running the appropriate module controller. Determining which module to load with Matchbox modules - El Forum - 05-12-2008 [eluser]PeteZahut[/eluser] [quote author="wiredesignz" date="1210617493"]Using Matchbox modules without routes this would require a redirect() after choosing the final controller. If you look at Modular Extensions HMVC you will see this can be achieved using a default controller with CI's remap() method and then loading or running the appropriate module controller.[/quote] I see. I don't know if this may work, but here goes. 1. route all requests to deafult conroller using this in routes.php Code: $route['(.*)'] = "default_controller/$1"; 2. do the redirect in default controller Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Correct me if i'm wrong but this won't do a background redirect to a controller. This will redirect through the url which leaves redirect() useless i think. Determining which module to load with Matchbox modules - El Forum - 05-12-2008 [eluser]wiredesignz[/eluser] Yes it will, you would need to be more specific with routes to allow calls to those controllers. Modular Extensions would be a better choice to achieve the functionality you require. See my signature. And this thread: http://ellislab.com/forums/viewthread/73177/ |