Correct way to add a Panel via Package

Permalink 1 user found helpful
I am trying to add a Panel to provide page related options. In case it's not clear what I mean with Panel, please see the attached image. I have found 0 documentation on this subject, but if you know some good resources please let me know.

I broke the task down as follows:

1. Override or add to /elements/panels/page
2. Add view and controller file
3. Implement custom functionality

#1. I found some info how to override Core files in a package:

public function on_start() {
    $env = Environment::get();
    $env->overrideCoreByPackage('elements/panels/page.php', $this);
}


That's probably not a good way, what happens if another package overrides the same file? What's a better way?

#2. Where do I add those? Can I just put /views/panels/details/page/custompanel.php in my package and it will be available? Since this doesn't work with /elements I am not so sure. (Same for controller). And if it works how do I reference it in the data-pane-detail-url attribute?

data-panel-detail-url="<?php echo URL::to('/ccm/system/panels/details/page/preview') ?>"


Probably some more questions will pop up along the way but it would be great if someone could shed some light on the general approach to take. I would imagine there even might be a undocumented createPanel function somewhere.

1 Attachment

jakobfuchs
 
Juha replied on at Permalink Reply 1 Attachment
Juha
I hacked together something really quick (see attachment). I can't say if it's the recommended way to do things, and it absolutely does not play well with other packages if they want to add custom panels, too. But maybe it helps you to get started.

I'm not sure if there is a way to add your custom stuff to panel without overriding it. At least I couldn't find any "panel::registerPanel( 'my_panel' )" kind of thing anywhere.
Juha replied on at Permalink Reply
Juha
It just occurred to me that instead of overriding core files it might be (at this point) tidier to add the link to your custom panel with JavaScript.
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi jakobfuchs,

This is interesting.

Will you show what you made when you are finished? I would like to see it.
jakobfuchs replied on at Permalink Reply
jakobfuchs
Thanks for your input! I took a quick look and will get back to you when I find the time to take a more in depth look. There's some stuff in the code that's new so I will have to do some experimentation.

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.