My ultimate goal is to provide a custom version the panel content page used in panels node module. I've stumbled upon the ctools display renderers which looks to be just the ticket I need for what needs to be accomplished. It seems pretty straight forward on how to override the panel node view display renderer, however what has me stumped is figuring out how to override the default panels content page.

Any guidance is greatly appriciated.

CommentFileSizeAuthor
#11 panels_every_node.tar_.gz14.84 KBcangeceiro

Comments

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Please describe your use case; it is unlikely that display renderers are truly what you need, though there are some cases where this might be true. Generally, this is true only if you want to provide features similar to IPE, however.

Overriding the default behavior is possible, but it is not easy, because while the structure is in place, the UI to edit it is not, so any changes would have to be made by manually creating code that would ordinarily be created by the UI, if it were to exist. I'll give some pointers on how to do this if your use case matches, but I have a feeling I'm likely to advise you to a different solution, depending on what it is you're trying to accomplish.

cangeceiro’s picture

Thanks for a quick reply merlin.

So I'll do my best to describe what I have so far. I've forked my own version of panels_nodes module that is pretty much the same, but panels has been abstracted from a specific node type as the ability to create a panel node needs to span across different node types. On the content side the panel content page needs to be exposed to several roles, but each role needs to have different features of the interface available to them. For example, role A needs to be able to move panel panes around, role b also needs to be able to add and remove panel panes, and role A and B should only see a particular category of panel panes to choose from. Finally admins should have the original panel content access.

I'm open to any suggestions you may have to accomplish this in a better manor. The approach at this point was to roll a custom version of panels_renderer_editor.class.php where permissions to controls could be handled

merlinofchaos’s picture

I've forked my own version of panels_nodes module that is pretty much the same, but panels has been abstracted from a specific node type as the ability to create a panel node needs to span across different node types.

There's an open feature request for this. If the code isn't too embarrassing it may be worth sharing. In the worst case maybe it's something someone else and clean up, and in the best case maybe it's something we can use as is.

And reading this...you're right. That's exactly the use case that the renderer plugins are being designed for.

So, as I said before, the UI for actually setting this stuff up hasn't been done. That said, take a look at panels_ipe/includes/panels_ipe.pipelines.inc

That's a standard defaults for the renderer pipeline exportable, which is partially implemented. You can use that like you would variants. It contains a list of renderers (currently that contains exactly 1). It will go through them one by one, checking to see if the user has permission to use it. If yes, it will render with that display renderer. If not, it will continue down the line. If all options are exhausted, it will proceed to the the 'standard' renderer.

You can then create custom renderers that do what you want. I would think you would want to start with panels_ipe renderer as a starting point, as that will give you a better idea of how to do limited/custom functionality, but you can start with the editor as well. You don't need to clone the editor, instead you want to derive from it like the IPE does and then override the functionality you want to change.

Right now, this only works for the actual display of the renderer. The 'back-end' is still hardcoded to standard. However, since you've got your cloned version of panel_node, you have the ability to control which renderer is used for the back-end as well, and you can pretty much just choose in code rather than using a pipeline.

I'd really love it if you'd share what you produce out of this. Even if we can't use the code directly, some of it may provide a basis for future code, since all of this is precisely where we intend this stuff to go when it's fully matured.

flevour’s picture

Interesting even if seemingly too custom approach, I'll keep an eye on this.
If I understand correctly it will be orobably worth sharing as sample code rather than official module/component.
Keep up the good work,
Francesco

cangeceiro’s picture

Ok, the info above was a great help. I don't think it would take much to clean up the forked panel nodes module at all. So i would have no problem sharing that back, as I had also planned on doing a little write up on what was done as well for my blog since there isn't alot of documentation on the web about working with display renderers. But, I'll have to wait till im done on this project before i can get to cleaning it up and posting it :)

So i am at a point now where i can override the content page's pipeline and specify whatever renderer that I want. This is working well. And if i look at the pipelines on the node edit page, my pipeline shows up as an option. But the renderer is not getting recognized on the edit page. My suspicion is that something that needs to be included is not there. This conclusion came from getting a call to undefined function panels_get_renderer_pipelines() when I was doing some testing.

Here is what I got so far in my page function for the panel content page where 'custom_editor' is the new display renderer that has been created.

function panels_every_node_edit_content($node) {

    if (!empty($node->panels_every_node['did'])) {
        panels_load_include('common');
        $display = panels_load_display($node->panels_every_node['did']);
        $display->css_id = $node->panels_every_node['css_id'];
        // TODO: Find a way to make sure this can't node_view.
        $display->context = panels_every_node_get_context($node);
        $output = panels_render_display($display, 'custom_editor');
    } else {
        $content_types = panels_common_get_allowed_types('panels_every_node', $display->context);
        $output = panels_edit($display, "node/$node->nid/panel_content", $content_types);

    }
    // Print this with theme('page') so that blocks are disabled while editing a display.
    // This is important because negative margins in common block layouts (i.e, Garland)
    // messes up the drag & drop.
    print theme('page', $output, FALSE);

}

Once again, thank you for your assistance

merlinofchaos’s picture

panels_get_renderer_pipelines() is in plugins.inc I think, so you probably just need:

  ctools_include('plugins', 'panels');

(Note also that panels_laod_include() is deprecated and you should use ctools_include() as above in its place).

cangeceiro’s picture

Well it looks like the problem ended up being in hook_ctools_plugin_directory(). i had if ($module == 'ctools') { when i actually needed if ($module == 'ctools' || $module == 'panels') { so my display renderer is up and going now. Your help has been greatly appreciated, after this project is done i'll post what i have back to this thread.

cangeceiro’s picture

ok, i might have spoke to soon. It appears that there is an inconcistancy causing a problem with hook_ctools_plugin_directory()

when i use

/*
 * Implementation of hook_ctools_plugin_directory().
 */
function panels_every_node_ctools_plugin_directory($module, $plugin) {
    if ($module == 'ctools') {      
        return 'plugins/' . $plugin;
    }
}

regular panel pages work, but my custom panel content page is broke.

the following:

/*
 * Implementation of hook_ctools_plugin_directory().
 */
function panels_every_node_ctools_plugin_directory($module, $plugin) {
    if ($module == 'ctools' || $module == 'panels') {      
        return 'plugins/' . $plugin;
    }
}

Allows the custom panel content page to render correctly, but panel pages also use the custom editor on their display.

Any suggestions?

merlinofchaos’s picture

The only way panel pages should be using the custom editor is if you have somehow overridden the association of the standard pipeline. It has nothing ot do with the plugin directory hook.

cangeceiro’s picture

ok i figured this out, its my own damn fault. so i apologize for wasting your time on that last one.

cangeceiro’s picture

StatusFileSize
new14.84 KB

here is my fork of the panels_node module that abstracts it from the panels node type. I don't think it could be considered production, but it is functional. The display renderer is hardcoded to the custom one i developed as well. One glaring flaw I noticed however. When using the content pane type "Node content" it creates a double render for anything added by any modules that append data to $node->content in hook_nodeapi.

zilverdistel’s picture

Subscribing, I'm trying something similar. I want to provide our end-users with a more simple interface for editing the content in the panel node panes. For now, this issue seems to be the greatest help available on doing this.

Letharion’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

In an effort to clean up the many hundreds of open issues in the Panels queue, I'm going over all issues with the "Postponed, needs info" status.
As per the Panels Issue guidelines, http://drupal.org/node/573062 section 2.2, I'm closing all issues that haven't been updated during the last month.
I realise that some issues will be closed, that should remain open. In these cases, most of the time, they have simply been left in the "Postponed, needs info" state by mistake.
If this is the case, and you still have an interest in this issue, please just re-open it, setting the appropriate status.

Also, since this issue seems to revolve around Panel Nodes, please see the new Panelizer project, which may be useful if you find this issue interesting.