I assume this is probably waiting for the resolution regarding UUIDs #1277908: Introduce UUIDs onto panes & displays for better exportability & features compatibility, but was wondering what solutions exist now regarding imported panels that have content pointed towards nodes.

For example, I'm working on a profile install that uses Features to import certain static pages (home, manual, etc.), as well as Panels that are used. In the case of the home page, Panels points to a node id that does not exist because the nodes are given new ids when imported. I know I can go through the Panels UI and fix it, but would rather find a solution whereby I can use hook_install_tasks() during the profile install.

I see the Panels information from Features is kept in code and not put into the database during install. Is my only solution custom code that goes through the Panels code, updates the node id to the new one, and save everything to the database programmatically?

Just wondering what others might be doing to solve this problem.

Comments

merlinofchaos’s picture

Another solution might be to not use the standard method of embedding a node, and instead use a view. Otherwise, a custom node embed that uses uuid instead of nid is the most elegant solution; but since uuid isn't always there, it can be problematic to have it used by default since it could appear midstream or worse, disappear midstream.

rbruhn’s picture

@merlinofchaos - The reason the design guy used Panels was due to our having a slide show in one section, the node text in another, and a view showing latest news in another. If I can use another view in place of the node, that would be great. Just not sure how to get that one node in a view without using an nid there as well. Is there a tutorial somewhere?

merlinofchaos’s picture

The trick would be to have a field on the node that isn't a nid that you can use to select the node. If you've got a UUID, then your view could select the node via UUID, and voila, the view works.

If you're using a node context (i.e, adding the node via the context tab) you can use Views for this as well. Using the views_content module, you can add a 'view context' display to your view; this will enable you to add the view itself as a context on the context tab. There is then a relationship, I think it's called something like 'node from view' where it will extract the node from the view. Or you can just use 'view row' panes to display various fields from the view as you need. There's a lot of flexibility in how exactly you configure things, once you've acquired your data.

The hardest part will be figuring out how to select your node. The simplest way to do it is to create a view individually, unless you expect to have more than a handful of these. If you have more than a handful, you'll need to do something creative like string contexts and an ID selector.

Another option, btw, is if this is really completely just about a node and displaying it, use panelizer and attach a panel to the node from there. Then it won't really care about node IDs; it will be part of the node itself when deployed.

rbruhn’s picture

Thanks merlin. Since all my nodes have UUID for other reasons, I think that will be the easiest solution.

merlinofchaos’s picture

One other alternative would be to write a custom context plugin that includes some kind of node selector and then does a ctools_context_create('node', $node); -- this is totally acceptable and might be the fastest path to what you need.

rbruhn’s picture

@merlinofchaos - That was total Greek to me. I'm learning Drupal, but not THAT proficient yet... lol