Welcome Guest, Not a member yet? Register   Sign In
Modulemanagement
#1

[eluser]Y0shi[/eluser]
Hey there!

Well I started about 1,5 years back with CI. I started coding a small cms and as time has gone by, it grew. Now I'm working at the dynamicness of my CMS and by doing that I try to implement a modulemanamgent which is harder than thought.

I wanna read everything from my /controllers directory, create a instance by using the new command and I want to use the command get_class_vars to retrieve 2 vars ($frontend and $linkable). But it doesn't work. I dont get any response from CI as soon as for example new Userclass happens. Even echo doesnt work.

I hope that anybody can tell me a way to retrieve variables from the controllers... I gettin mad with this problem since I'm working already 2 days with this.

I'd be very grateful for any help.

Regards Wink
#2

[eluser]wh1tel1te[/eluser]
Sounds like PHP errors are being suppressed. Try either turning PHP error reporting at max, or check your error logs. There should be some error occurring to stop execution of your scripts.
#3

[eluser]Y0shi[/eluser]
It's currently at E_ALL so I'll have to check the logs. But are there any code snippets your could suggest me to achieve my goals?

Thanks in advance Wink
#4

[eluser]wh1tel1te[/eluser]
Code:
function get_controllers()
{
    $path = realpath(APPPATH . 'controllers') . '/';
    $this->load->helper('directory');
    $controllers = directory_map($path);
    
    $nav = array();
    foreach($controllers as $id=>$c)
    {
        if (preg_match('/\.php$/i', $c) == TRUE)
        {
            $class = str_replace('.php', '', ucfirst($c));
            
            $nav[$id] = array(
                'controller'    => $c,
                'class='        => $class,
            );
            
            if (class_exists($class) == FALSE)
            {
                require_once($path . $c);
            }
            $nav[$id]['methods'] = get_class_methods($class);
        }
    }
    
    echo '<pre>'; print_r($nav);
}
#5

[eluser]Y0shi[/eluser]
You've helped me alot! It works now. Huge thanks for that.

Edit: Well, another problem is now clear to me. To explain that I should explain my goal. Currently I'm coding everything very fixed. So there's no dynamic in it. If I want my customers to create a link to the news module or to their blog, the requests and everything else has to be hard-coded - which means I have to declare every flow for every module manually. Now I want to do everything dynamic.

I want that I just have to declare some vars in the controller file itself which then will be read and interpreted.

With your help I got the methods and the vars out of it. But is there a way to do this be reading out controller php files? Or is there a better way?

Thanks again in advance.

Best regards




Theme © iAndrew 2016 - Forum software by © MyBB