Welcome Guest, Not a member yet? Register   Sign In
Admin interface to control enabling and disabling of modules and controlling routes
#1

[eluser]getSurreal[/eluser]
I use modular extensions hmvc and I would like to be able to activate/deactivate modules similar to how most CMS's work. I'm not able to find any tutorials or examples on how to implement this and would be grateful if anyone could point me in the right direction. I would want this configuration stored in the database instead of updating config files.
#2

[eluser]Otemu[/eluser]
Hi,

You could have a database table that holds all your modules (id, name, desc, pos, onoff, etc). Let say on your site you have a two column layout with your dynamic modules on the right column side, when entering the admin page your have your usual fields for meta, content, images etc but now additionally you will have a extra tab called modules, this could either be drag and drop, or simply a list with all your created modules.

The module section of your admin panel will have options to disable or enable moduules, set position and depending how deep you want to take your system could have additional parameters options.

On your main site, the right column would loop though the modules found in your modules table that are active and any additional parameters set something like:

foreach $module as $row{
modules::run( $row[modulename]', $row[moduleparam]);
}


#3

[eluser]getSurreal[/eluser]
Thanks Otemu,

I understand how I could display or not display a module by tracking my modules in the database, but they wouldn't really be "disabled". Let's say I have a Blog module. I could "disable" it and the menu would be removed from the page, but if someone actually browsed to http://mysite/blog they would still get the blog module.

Maybe I'm trying to make this more complicated than it needs to be. I guess in each module I could do a check to see if it were enabled, if not redirect to home.

But, I was looking for more of a master system that managed that instead of managing it in each individual module.

#4

[eluser]Otemu[/eluser]
Another option is to use the remap function as mentioned here http://ellislab.com/forums/viewthread/221788/ this might be the better method as you won't need to make an additional database call to see if it active or not.



#5

[eluser]PhilTem[/eluser]
I haven't seen any system that takes care of this. But! I have been thinking about the same thing about a 1.5 years ago - haven't coded a single line of code though. So I'm gonna subscribe to this thread and have a look at what others are posting.

The only thing I could think of doing it would be a check in MY_Controller::__construct() if the module accessed is activated in the database. Which is basically also my methodology to solving this problem Wink
#6

[eluser]getSurreal[/eluser]
I wasn't aware of the remap function. That definitely points me in the direction of a solution. Much appreciated.
#7

[eluser]Harold Villacorte[/eluser]
If you don't want someone to access the blog directly put this in the blog controller:

Code:
if ($this->uri->segment(1) == 'blog') {
  redirect('some_other_url/')
;}




Theme © iAndrew 2016 - Forum software by © MyBB