? node_tmpl_4_CCK_1.patch
Index: node_template.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/leech/node_template/node_template.module,v
retrieving revision 1.2.2.3
diff -u -p -r1.2.2.3 node_template.module
--- node_template.module	16 Feb 2007 12:09:34 -0000	1.2.2.3
+++ node_template.module	6 Aug 2007 15:46:20 -0000
@@ -54,8 +54,9 @@ function node_template_load($nid) {
   $node_templates[$nid]->node_template = $template;
 
   // Run php code for template. Make node "local" for that code.
-  drupal_eval('<?php global $node_templates; $node = &$node_templates['.$nid.'];?>'.$node_templates[$nid]->node_template->php_load);
-
+  $GLOBALS['node_template_current'] = &$node_templates[$nid]; 
+  drupal_eval('<?php global $node_template_current;' . '$node = $GLOBALS[' . '\'node_template_current\'];' . (string)$node_templates[$nid]->node_template->php_load);
+  
   // Let other modules prepare template (they should remove unique data so it's safe to clone as many times as possible ;)
   node_invoke_nodeapi($node_templates[$nid], 'template');
 
@@ -88,7 +89,8 @@ function node_template_save(&$node) {
 
   if (isset($node->node_template) && $node->node_template->php_save) {
     // Run php code for template. Make node "local" for that code.
-    drupal_eval('<?php global $node_templates; $node = &$node_templates['.$node->node_template->nid.'];?>'.$node->node_template->php_save);
+    $GLOBALS['node_template_current'] = &$node; 
+    drupal_eval('<?php global $node_template_current;' . '$node = $GLOBALS[' . '\'node_template_current\'];' . (string)$node->node_template->php_save);
   }
 
   node_object_prepare($node);
@@ -254,7 +256,7 @@ function node_template_create_form() {
     '#title' => t('Loading PHP code'),
     '#default_value' => $template->php_load,
     '#rows' => 20,
-    '#description' => t('This PHP code will be run after original node is loaded, before template is created. It will be run only once, not every time template node is prepared. Variable $node is full copy of original node, which You can change before it will be cloned to create new nodes. Changes You make with PHP code here will not affect original node.')
+    '#description' => t('This PHP code will be run after original node is loaded, before template is created. <strong>Do not use &lt;?php ?&gt; tags.</strong> It will be run only once, not every time template node is prepared. Variable $node is full copy of original node, which You can change before it will be cloned to create new nodes. Changes You make with PHP code here will not affect original node.')
   );
 
   $form['php_save'] = array (
@@ -262,7 +264,7 @@ function node_template_create_form() {
     '#title' => t('Saving PHP code'),
     '#default_value' => $template->php_save,
     '#rows' => 20,
-    '#description' => t('This PHP code will be run at saving time. It will be run each time new node is created from template, when that new node is saved. Variable $node is full copy of original node, which You can change before it will be cloned to create new nodes.')
+    '#description' => t('This PHP code will be run at saving time. <strong>Do not use &lt;?php ?&gt; tags.</strong> It will be run each time new node is created from template, when that new node is saved. Variable $node is full copy of original node, which You can change before it will be cloned to create new nodes.')
   );
 
 
