Search code examples
phpcodeigniterpyrocms

Calling a function on details.php - PyroCMS


Is there a way to call a function that is withing the details.php file from an admin controller from my custom module ?

Im developing a module that has sub modules within it.

Inside the details.php file there is the standard

install() function however I also have

install_module_a()

and

install_module_b()

So from my controller I would like to do something like

class Module_manager extends Admin_controller
{

    public function index() {}
    public function install_mod_a()
    {
       $this->details->install_module_a();

    }

}

PyroCMS version 2.2.x

also posted this question here


Solution

  • I've tried to answer this question on https://forum.pyrocms.com/discussion/25115/calling-a-function-within-details-php

    The answer is basically:

    1. include the details.php
    2. instantiate the class
    3. call the function

    The only more problematic thing is, to determine wether your modules are in the shared_addons/modules or addons/modules folder. But a simple is_file or file_exists check should help with that.

    Check out installer/libraries/Module_import.php around line 76 and 222 to see how the PyroCMS team tackled this matter.