Determining which module to load with Matchbox modules |
[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?
[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.
[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.
[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/ |
Welcome Guest, Not a member yet? Register Sign In |