Closed (outdated)
Project:
Panels
Version:
7.x-3.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Sep 2009 at 09:58 UTC
Updated:
13 Jul 2026 at 20:34 UTC
Jump to comment: Most recent
Comments
Comment #1
crea commentedI am calling page_manager_node_view($node) from my theme_node_preview(). It works ok for simple panels, but for panel where I have mini-panels embedded as panes I get WSOD.
Comment #2
markus_petrux commentedBefore invoking page_manager_node_view(), you probably need to load the file where it is:
You should see errors in your log though.
Comment #3
crea commentedYes I thought too that it's something about missing function. However including 'plugins/tasks/node_view' didn't help. I think it's included in page_manager_get_task() anyway, that's why I get working panel if I disable mini-panels.
This probably has something to do with mini-panel specific code which relies on missing code.
Comment #4
crea commentedHuh, actually it was custom formatter code that went crazy.
Comment #5
crea commentedOk, my code. Maybe someone finds this useful. Something like this would be nice to have in Panels out of the box.
Comment #6
merlinofchaos commentedIf you would like this in Panels out of the box, can you provide it as an actual patch to the panels node module?
Comment #7
crea commentedI needed it for Panel Pages. I thought it works for panel nodes already, however I don't use them. I gave it some thought and came to conclusion it would be better to add this to documentation, since it would require override theming function within a module and any user defined function withing a theme would break it anyway. So it's better to just have this theming example and let user make theming function they want exactly.
Comment #8
merlinofchaos commentedOh I see. So it would actually be a patch for CTools, not Panels.
In any case, an actual patch would be more useful to me.
Comment #9
thomjjames commentedHi,
Think the code for #5 needs to be slightly different or you get the whole page return in the preview:
Think this should be default behaviour for the page_manager module.
Cheers
Tom
Comment #10
thalemn commentedDid this get added to CTools?
I'm using Panels to display results from a CCK form - but previewing the node isn't possible. I'm relatively new to Drupal, so I don't have the skills yet to work directly with the php...can you point me in the right direction?
Thank you for any assistance!
Tom
Comment #11
merlinofchaos commentedNo, this has not been added. It would require a patch to be added.
That said, I do believe that fixing it so that when you click 'preview' on a node, you get the actual panel that would be displayed, so something like this would be desirable, and IMO should be automatic.
Comment #12
thalemn commentedI did find a patch to direct the preview to view the panel. Works great!
Comment #13
thomasmuirhead commentedHi thomlynn,
Could you share where you found the patch - that would be great!
thanks
THomas
Comment #14
egifford commentedThis information is great. Thanks.
Comment #15
liquidcms commentedthis would be cool.. but code above (either version) doesn't work for me.
returns false.
panels 3.9
ctools 1.8
Comment #16
pmathur01 commenteddid someone find a patch or a solution for this? I am not able to preview the panel node with preview.
thanks
Prerna
Comment #17
thalemn commentedI can't recall where I found this solution, but it does work.
I inserted this code into the template.php file:
function marinelli_node_preview($node) {
$output = '
$preview_trimmed_version = FALSE;
// Do we need to preview trimmed version of post as well as full version?
if (isset($node->teaser) && isset($node->body)) {
$teaser = trim($node->teaser);
$body = trim(str_replace('
', '', $node->body));
// Preview trimmed version if teaser and body will appear different;
// also (edge case) if both teaser and body have been specified by the user
// and are actually the same.
if ($teaser != $body || ($body && strpos($node->body, '
') === 0)) {
$preview_trimmed_version = TRUE;
}
}
if ($preview_trimmed_version) {
drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "<!--break-->" (without the quotes) to fine-tune where your post gets split.'));
$output .= '
'. t('Preview trimmed version') .'
';
$output .= node_view(drupal_clone($node), 1, FALSE, 0);
$output .= '
'. t('Preview full version') .'
';
$output .= custom_node_preview($node);
}
else {
$output .= custom_node_preview($node);
}
$output .= "
\n";
return $output;
}
/**
* Render Panel Page as part of node preview page.
*
* Based on page_manager_node_view().
*/
function custom_node_preview(&$node) {
// Load my task plugin
$task = page_manager_get_task('node_view');
// Load the node into a context.
ctools_include('context');
ctools_include('context-task-handler');
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node));
$output = ctools_context_handler_render($task, '', $contexts, array($node->nid), false);
if ($output !== FALSE) {
return $output['content'];
}
// Otherwise, fall back.
return node_view($node);
}
Comment #18
pmathur01 commentedThanks a lot! It worked beautifully..
Prerna
Comment #19
Letharion commentedFeature request has essentially been accepted by merlin, but this issue has been in "Needs work" since 2009. I'm closing this one won't fix until someone can actually submit a patch.
Comment #20
glenn_echo commentedI struggled with a similar problem where ctools_context_handler_get_task_contexts returned false. I finally realized it returned false because I was passing it an array instead of an object. Simply:
prior to calling the function made this work.
Comment #21
vali hutchison commented#17 worked well for me too. I'm using D7 and found I had to change
return $output['content'];to
return $output;in the custom_node_preview function to make it work.
Comment #22
vali hutchison commentedActually, the above doesn't fully work for the site i'm testing in D7. It will only preview the existing saved node. So on node creation, you just see 'Array' and for existing nodes you see the display well via panels, but not the new changes made in the edit form prior to clicking preview.
The panel testing does use 'OG group from node' as a context so maybe this is the issue?
Comment #23
liquidcms commentedAny update on this?
i'll reopen as i don't think:
makes any sense.
Comment #24
ezman commentedThe reason none of these fixes work fully is because they're all calling ctools_context_handler_render() and passing in $node->nid
When a new unsaved node is previewed, it has no nid, so the page renderer is silently failing.
I've recently encountered this issue, and at the moment can see no easy way around it: the ctools page at node/%node needs a node id to work properly. Not to mention if you have any Views in there which want the node id to query the database with...
It seems to be a big can of worms. The only workaround I can think of right now is to just save the node when its previewed, possibly deleting it afterwards if needed.
Comment #25
japerryDrupal 7 is no longer supported, closing.