--- nodereference.module.original 2008-06-04 05:56:58.000000000 -0700 +++ nodereference.module 2008-06-08 21:59:27.000000000 -0700 @@ -123,6 +123,19 @@ function nodereference_field_settings($o '#required' => FALSE, '#description' => t('Provide a comma separated list of arguments to pass to the view.'), ); + // Add token list for view argument in advance setting. + if (module_exists('token')) { + $form['advanced']['token_help'] = array( + '#title' => t('View argument token replacement patterns'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'), + ); + $form['advanced']['token_help']['help'] = array( + '#value' => theme('token_help', 'node'), + ); + } } } return $form; @@ -645,7 +658,22 @@ function nodereference_get_view($field, // Get arguments for the view. if (isset($field['advanced_view_args'])) { - // TODO: Support Tokens using token.module ? + + // Support for Tokens using token.module. + if(module_exists('token')) { + + // Get node ID from node being edited. + $matches = array(); + preg_match('`node/(.*)/edit`', $_SERVER['HTTP_REFERER'], $matches); + $nid = $matches[1]; + + // Load node and replace tokens using node information. + if(is_numeric($nid)) { + $node = node_load($nid); + $field['advanced_view_args'] = token_replace($field['advanced_view_args'], 'node', $node); + } + } + $view_args = array(); $view_args = array_map('trim', explode(',', $field['advanced_view_args'])); }