How to programmatically duplicate a node reference field during rendering? I am working on a node type which contains node references to other types. I want to programmatically duplicate a few node reference fields based on a set of conditions during rendering of the node. I have not been able to figure that out.
You have total control over the layout of nodes within your theme via the node.tpl.php file and its variants and overrides. Check out a lot of information about node.tpl.php here and template files in general here.

By creating a specific template, you can customize it to your purposes along these lines:

function YOURTHEME_preprocess_node(&amp;$vars) {

  if ( /* whatever condition you have that returns true for printing */ ) {
    $vars['template_files'][]='node-printing';
  }

  // any other node preprocessing goes here

}


Then, you put a node-printing.tpl.php file in your theme directory next to the default node.tpl.php for your theme, and in there, customize it as you like.

The key variables to be looking at are $content and $node. If you goto admin/content/node-type/NODE_TYPE/display on your system you can see how $content is built and customized,  while the latter is it as an object containing all of its fields that you can rework and so forth. 

Putting a drupal_set_message('&lt;pre&gt;' . print_r($node, TRUE) . '&lt;/pre&gt;'); at the top of your new template file will show you what you have to work with.

And, as always, just remember to clear caches after creating this new template so that the theme registry picks it up, but now you should be able put anything anywhere you want in your node display.