impresspages / ImpressPages

ImpressPages is php framework with admin panel. Build functional website in one hour.
http://www.impresspages.org
Other
501 stars 178 forks source link

Override inside Plugin #775

Closed flakerimi closed 8 years ago

flakerimi commented 8 years ago

Is possible to have same feature as Theme, an override folder when you can override certain files if plugin is enabled?

maskas commented 8 years ago

It hasn't been implemented, because this feature potentially can slow down the system significantly. But I have an idea. Let me have a look.

flakerimi commented 8 years ago

Awesome, let me know when you got something, even extending a class could be great.

Let say class MyDb extends Db will would be great to add custom methods, just like that I did days ago

maskas commented 8 years ago

With this change you should be able to set view overrides from within a plugin. One of the best places to do that is by catching an event. E.g.


<?php

namespace Plugin\Application;

class Event
{
    public static function ipBeforeController()
    {
        \Ip\View::registerOverride(ipFile('Ip/Internal/Admin/view/login.php'), ipFile('Plugin/Application/view/newLogin.php'));
    }
}

Sounds good? Works for you?

flakerimi commented 8 years ago

Well this is good for views but I would love to have something to extend IP. I dont want to touch core, but sometimes you need to. Currently I am using Theme/override but having that for each plugin would be great or somewhere to autoload custom classes

maskas commented 8 years ago

It is not recommended, but extra easy. Just add

require_once('Path to your own file');

in index.php file. And that's it. Your file will be used instead of the default one.