Closed (won't fix)
Project:
Panels
Version:
6.x-3.0
Component:
Panel nodes
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Aug 2009 at 19:22 UTC
Updated:
2 Dec 2011 at 14:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
merlinofchaos commentedbecause of the nature of nodes, panel nodes cannot be exported. If you need export behavior, you must use pages from the page manager module.
Comment #2
dalejung commentedHey Merlin. I decided to poke around on this and came up with this:
--- panels_node.module (revision 2699)
+++ panels_node.module (working copy)
@@ -223,6 +223,13 @@
// Create a new display and record that.
$display = panels_new_display();
$display->layout = $node->panels_node['layout'];
+
+ if($node->export_display) {
+ // This works by overriding the $display set above
+ eval($node->export_display);
+ unset($node->export_display);
+ }
+
panels_save_display($display);
$css_id = $node->panels_node['css_id'];
@@ -352,3 +359,14 @@
$contexts['panel-node'] = $context;
return $contexts;
}
+
+/*
+ hook_export_node_alter
+*/
+function panels_node_export_node_alter(&$node, $original_node, $method) {
+ if($method == 'export') {
+ $display = panels_load_display($node->panels_node['did']);
+ $export = panels_export_display($display);
+ $node->export_display = $export;
+ }
+}
I've tested it and it seems to be exporting/importing correctly. Only issue is that it does not work with the prepopulate import option. The node has to be saved. I also have a form.inc line 1200 error dealing with default values. But the panel content/layout looks to have carried over correctly.
Your thoughts on this? Is this a worthwhile avenue to go down? I'll offer up a proper patch after I do some better testing and such.
Comment #3
merlinofchaos commentedI dunno. I'm not really enthused by panel nodes; they exist because there is a need, but I don't like them very much. There are a lot of hassles in fully doing it properly I think.
Comment #4
dalejung commentedSad to hear since I really dig panel nodes. But I probably use them atypically.
I have a patched panels_node module that allows me to use panel nodes as templates. Basically content types like articles and galleries have a nodereference field for Template, Right Column, and Left Column. If a panel node is selected for Template, then that panel-node's layout/content will be rendered with the "node being viewed" supplied as a context (I actually provide other context like site channel terms, etc). Same thing goes for Right and Left column.
The main templating is accomplished via a modified panels task handler that overrides the page handler's display if the Template nodereference is set. So the node will default to the page handler if no template is selected. The defaults for left and right column are handled via a custom Context(the module) reaction.
This allows us to provide multiple article templates that are editor controlled. Also, it allows the editors to make their own template without destroying the whole site using the Pages admin. This is incredibly useful for sponsored articles as well.
I also use the same idiom for Taxonomy pages. With a combination of the panel node templating system and nat editors can select more complex layouts for term pages such as "Obama" vs something like "rubber ducky".
I don't think it's possible to get the equivalent flexibility with any of the other panels variants.
Comment #5
merlinofchaos commentedWow, that is atypical, and really interesting. Right now I'm in Paris on vacation ahead of Drupalcon, but I'd like to talk more about what you're doing because it sounds really exciting and maybe there are things I can do to improve it and make it easier for all. I want to make sure sdboyer reads this too as it sounds like this is a similar functionality (but totally different implementation) as his blueprints stuff.
Comment #6
kvoltz commentedThis is very interesting... and will help with a current project I am working on immensely.
Is there anyway I can get a bit more information on what you are doing here datacaliber?
Thanks so much for your help!
Comment #7
damienmckennaA main benefit of using panel nodes is integration with other modules - you can add a panel node to a Nodequeue, list them in Views, attach images to them to display a thumbnail, manage the metadata, etc.
Comment #8
dalejung commentedIndex: panels_node.module
===================================================================
--- panels_node.module (revision 2699)
+++ panels_node.module (working copy)
@@ -223,6 +223,13 @@
// Create a new display and record that.
$display = panels_new_display();
$display->layout = $node->panels_node['layout'];
+
+ if($node->export_display) {
+ // This works by overriding the $display set above
+ eval($node->export_display);
+ unset($node->export_display);
+ }
+
panels_save_display($display);
$css_id = $node->panels_node['css_id'];
@@ -352,3 +359,14 @@
$contexts['panel-node'] = $context;
return $contexts;
}
+
+/*
+ hook_export_node_alter
+*/
+function panels_node_export_node_alter(&$node, $original_node, $method) {
+ if($method == 'export') {
+ $display = panels_load_display($node->panels_node['did']);
+ $export = panels_export_display($display);
+ $node->export_display = $export;
+ }
+}
This is what I added to panel_node. You gotta make sure that node_export uses the Save node then edit.
I will clean this up into something proper. Just saw this and wanted to put it out there.
Comment #9
merlinofchaos commentedWhoops, this should've been reopened.
Comment #10
damienmckennaHere's a patch version of datacaliber's code. I added a drupal_set_message() to remind the user that the export.module's settings need to be a specific way in order for it to work.
Comment #11
merlinofchaos commentedyour drupal_set_message needs a t() call. Also use "" for quoting if there are ' in the string to make it easier on translators.
Comment #12
damienmckennaAnother update, to incorporate the requested changes.
Comment #13
merlinofchaos commentedOk, sure. I added a !empty() to the ->export_display check to avoid triggering notices when the variable is not set. Otherwise it looks ok ot me. Committed.
Comment #14
damienmckennaExcellent, thanks!
Comment #16
tedbowI have patch correcting the function name on this. Not sure if this problem b/c node_export might has changed. The current code works but the hook it says it is implementing is incorrect.
The hook should be hook_node_export_node_alter not hook_export_node_alter
The current code only works now b/c drupal_alter thinks "panels" is implementing and not "panels_node"(first word in hook == last word in module).
This has the same issue in Drupal 7 version. I only found b/c it currently doesn't work in D7(for another reason which I will submit a patch for)
Comment #17
James Andres commentedThe patch in #16 doesn't work with the latest node_export 7.x-3.x. This patch removes the
$methodparameter as that resolves the issue.Comment #18
James Andres commentedActually this patch does one better and fixes another issue where
$node->export_displaywas being attached to all exported nodes, including non-panels nodes. Besides that change, it's the same as #17.Comment #19
Letharion commentedPlease don't reopen such old issues, when two years have passed, your issues is most likely different.
If you need this functionlity, consider opening a separate issue. Normally maybe I would have opened a new issue and linked them togther, but because Panel Nodes are deprecated now in favor of Panelizer, I'm just going to close this issue, with the suggestion that you look into that module instead.
It's unlikely that Panel nodes will recieve much more work.
Comment #20
Letharion commentedThere has finally been posted an upgrade path from Panel Nodes to Panelizer over here: #1353542: Upgrade path from Panel Nodes to Panelizer.
And with that, I request that anyone that posts issues regarding Panel Nodes try to upgrade, and then either posts Panelizer issues, or upgrade path issues.