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:
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?
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.
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.
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.
Hi jakobfuchs,
This is interesting.
Will you show what you made when you are finished? I would like to see it.
This is interesting.
Will you show what you made when you are finished? I would like to see it.
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.
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.