Currently you can export panel nodes but they don't include the corresponding display. Is panel node exportability a planned feature?

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

because of the nature of nodes, panel nodes cannot be exported. If you need export behavior, you must use pages from the page manager module.

dalejung’s picture

Hey 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.

merlinofchaos’s picture

I 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.

dalejung’s picture

Sad 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.

merlinofchaos’s picture

Wow, 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.

kvoltz’s picture

This 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!

damienmckenna’s picture

A 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.

dalejung’s picture

Index: 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.

merlinofchaos’s picture

Status: Closed (won't fix) » Active

Whoops, this should've been reopened.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

Here'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.

merlinofchaos’s picture

your drupal_set_message needs a t() call. Also use "" for quoting if there are ' in the string to make it easier on translators.

damienmckenna’s picture

StatusFileSize
new1.6 KB

Another update, to incorporate the requested changes.

merlinofchaos’s picture

Status: Needs review » Fixed

Ok, 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.

damienmckenna’s picture

Excellent, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tedbow’s picture

Category: feature » bug
Status: Closed (fixed) » Needs review
StatusFileSize
new915 bytes

I 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.

-function panels_node_export_node_alter(&$node, $original_node, $method) {
+function panels_node_node_export_node_alter(&$node, $original_node, $method) {

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)

James Andres’s picture

The patch in #16 doesn't work with the latest node_export 7.x-3.x. This patch removes the $method parameter as that resolves the issue.

James Andres’s picture

Actually this patch does one better and fixes another issue where $node->export_display was being attached to all exported nodes, including non-panels nodes. Besides that change, it's the same as #17.

Letharion’s picture

Please 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.

Letharion’s picture

Status: Needs review » Closed (won't fix)

There 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.