Here's a patch that adds non-executing comments to the export output, giving the title of the node that any item with the keyname "nid" points to.

If, like me, you're using Node Export as a backup, it's reassuring to be able to work out what references what from the export text alone.

CommentFileSizeAuthor
node_export_nid_comment.diff632 bytesdannyobrien

Comments

danielb’s picture

Status: Active » Needs work

Not sure I'm comfortable with that being there by default - makes a few assumptions that could lead to problems (like values for a nid field being a valid node id), and the output is a bit anti-drupal (are you a perl programmer??). Perhaps I will provide a hook so this can be done another way that is configurable. I also think in a majority of use cases the 'nid' values are completely misleading, and any references will be inaccurate on the destination site, so this might lead people to try and read the export code and subsequently get the wrong idea.

<?php

    foreach ($var as $key => $value) {
      $code .= $tab ."  '". $key ."' => ".node_export_node_encode($value, $iteration).",\n";
    }

?>

could become

<?php

    foreach ($var as $key => $value) {
      $out = $tab ."  '". $key ."' => ".node_export_node_encode($value, $iteration).",\n";
      $code .= drupal_alter('node_export_node_encode', $out, $tab, $key, $value, $iteration);
    }

?>

and then you do


<?php

function YOURMODULE_node_export_node_encode_alter(&$out, $tab, $key, $value, $iteration) {
  if (($key == 'nid') && $node = node_load($value)) {
     $out = $tab ."  '". $key ."' => ".node_export_node_encode($value, $iteration).',';
     $out .= "// '".$node->title."'";
     $out .= "\n";
  }
}

?>

Will think about it some more.

dannyobrien’s picture

Interesting! Thanks for the suggestions!

danielb’s picture

Status: Needs work » Fixed

I've added the hook into the module. Hopefully this is satisfactory so you can change each array element to add your own output.

Status: Fixed » Closed (fixed)

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