| Project: | Panels |
| Version: | 7.x-3.3 |
| Component: | Panel pages |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I've created a new entity type "Messages" and added a bundle "Private Message".
When I create a new entity (ie. new content) Drupal creates the following URL /messages/private_message/1 for it.
Is there currently a way to use panels to override this page so I can use panels to control the layout and content? To be more general, is there a way to override all Private Message entity pages and use the same panel for all of them?
This would be similar to enabling "Node template" in the panels dashboard, which would allow me to create variants based on different selection rules (eg. based on the content type of the node, etc). Can I do this with the new entity type I created? In short I'd like to use panels to set the layout and content for my new entity type.
Thanks for any help.
Comments
#1
You have two options.
1) Check out ctools/page_manager/plugins/tasks/node_view.inc and more or less do what it does to override your entity page.
2) Check out Panelizer and implement an 'entity' panelizer plugin (they're relatively easy) and allow your entity to be panelized.
Panelizer is MUCH more flexible. I currently use it on custom entities with very little difficulty. And if an entity requires panelizer, the integration can be super smooth.
#2
Thanks for the quick response, I've tried duplicating node_view.inc as message_view.inc. Made some progress including being able to activate the Message template but panels isn't overriding the /messages/private_message/1 page. I'm going to keep banging my head against it to see what happens...
I assumed that panels + custom entities would have been supported since it seems like using a panel to override a custom entity page would be common (or maybe it's just me who likes using panels for everything?). Entities integrated so well into everything else (eg. views) that I naturally assumed that I'd be able to enable panel page templates for any custom entity I created through the interface. Out of curiosity is this something that's on the roadmap?
In my initial investigation I actually did find node_view.inc but didn't go much further with it until you suggested it. Do you know of any module or examples I could look at to help me along?
Thanks!
#3
I'm trying to achieve the same and also go stuck on panelizer not overriding my entity page. Do I need to change something in the MyModuleEntityMyEntity.class.php file other than the class name itself?
I'm using 7.x-2.0
Many thanks
#4
I gave up and just went back to using nodes instead of creating my own entity. Doesn't seem like entities is well supported enough yet. But looking forward to the day it is as it's a great concept. Thanks to the person/people who pushed the idea :). Definitely a huge step forward for Drupal.
#5
No, nothing new on this is in the roadmap. In order to override an entity, something like one of the two things will always be required, because there just isn't enough about an entity to really do the job.
I've had great luck using panelizer as the sole delivery method of a custom entity. I'll attach a copy of the plugin I used, which may be simpler than trying to copy the existing ones.
This is just the panelizer plugin (it'd live in plugins/entity) and doesn't contain any of the basic custom entity stuff I've created. You still need your own entity controller and all that, which I assume you have. You also need the hook_ctools_plugin_directory set up so that it knows where to find your entity.
As you can see, the bare minimum necessary is quite bare. Using Panelizer, you can then simply override the view modes for the entity as you see fit, and voila. Panels rendering the entity in whatever capacity you desire.
#6
Also, for the node_view task plugin, that particular one might be more complex than necessary; unfortunately, overriding menu items is actually relatively complex and thus annoying. The term_view one might be a mildly simpler example.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.