diff --git a/weblinks.module b/weblinks.module index 314592d..96eaaf3 100644 --- a/weblinks.module +++ b/weblinks.module @@ -646,13 +646,22 @@ function weblinks_view($node, $view_mode) { function weblinks_preprocess_node(&$variables) { // We only do this for our content and only on the links page. if ($variables['type'] == 'weblinks' && arg(0) == 'weblinks') { - // Set the node title destination (1 = node, 0 = site). + dd('-- weblinks_preprocess_node --'); + // Set the node title destination. The variable 'weblinks_title_link' is the + // setting for whether the node title should link to the node (1, default) + // or the site (0). The same name 'weblinks_title_link' is also used to hold + // the intermediate url value of that link. This is created as a property of + // $node in weblinks_node_view.tpl.php which then becomes available via the + // $variables[] array here. Finally $node_url is used in node.tpl.php. if (variable_get('weblinks_title_link', TRUE)) { $variables['node_url'] = url(drupal_get_path_alias('node/' . $variables['nid'])); } else { - $variables['node_url'] = $variables['weblinks_title_link']; + $variables['node_url'] = url($variables['weblinks_title_link']); + $variables['node_url'] .= '##in_weblinks_preprocess_node'; ### DEBUG } + dd($variables['node_url'], '$variables[node_url]'); + dd('-- weblinks_preprocess_node -- END'); } } @@ -678,6 +687,7 @@ function template_preprocess_weblinks_link(&$variables) { * Implements hook_weblinks_preprocess(). */ function weblinks_weblinks_preprocess($node) { + dd('-- weblinks_weblinks_preprocess() --'); global $user; // Making these static means we only need to set them the first time we come here. static $description, $urlnode, $options, $dest, $comments, $user_link; @@ -704,12 +714,15 @@ function weblinks_weblinks_preprocess($node) { // Note that drupal_attributes will do a check_plain. $options['attributes']['title'] = $node->title; + dd(variable_get('weblinks_title_link', TRUE) ? 'TRUE = node' : 'FALSE = site', 'variable_get(weblinks_title_link)'); + dd(isset($variables['title']) ? $variables['title'] : 'not set', 'before: $variables[title]'); if (variable_get('weblinks_title_link', TRUE)) { $variables['title'] = l($node->title, 'node/' . $node->nid); } else { $variables['title'] = check_plain($node->title); } + dd($variables['title'], 'after: $variables[title]'); // If this is a full-page view (node/xxx), then disregard "description" setting. if (!$node->is_teaser) { $description = 'body'; @@ -750,6 +763,7 @@ function weblinks_weblinks_preprocess($node) { default: drupal_set_message(t('Unknown value "%description" for $description in weblinks_weblinks_preprocess()', array('%description' => $description)), 'error'); } + dd('calling theme(weblinks_node_view ..)'); $variables['link'] = theme('weblinks_node_view', array('node' => $node, 'options' => $options)); if (user_access('view weblinks click count')) { @@ -763,6 +777,7 @@ function weblinks_weblinks_preprocess($node) { } } + dd('-- weblinks_weblinks_preprocess -- END'); return $variables; } diff --git a/weblinks_node_view.tpl.php b/weblinks_node_view.tpl.php index e26bcf1..737091d 100644 --- a/weblinks_node_view.tpl.php +++ b/weblinks_node_view.tpl.php @@ -10,8 +10,20 @@ * - $options: Options for the URL. */ if ($node->url != NULL) { + dd('-- weblinks_node_view.tpl.php --'); switch (variable_get('weblinks_view_as', 'url')) { + case 'visit': + $title_text = variable_get('weblinks_visit_text', t('Visit [title]')); + if (function_exists('token_replace')) { + $title = token_replace($title_text, array('node' => $node)); + } + else { + $title = str_replace('[title]', $node->title, $title_text); + } + break; + case 'url': + default: if (variable_get('weblinks_strip', FALSE)) { // Note this also strips a port. $parts = parse_url($node->url); @@ -23,30 +35,23 @@ if ($node->url != NULL) { } $title = _weblinks_trim($url, variable_get('weblinks_trim', 0)); break; - - case 'visit': - $title_text = variable_get('weblinks_visit_text', t('Visit [title]')); - if (function_exists('token_replace')) { - $title = token_replace($title_text, array('node' => $node)); - } - else { - $title = str_replace('[title]', $node->title, $title_text); - } - break; } + dd(variable_get('weblinks_redirect', FALSE) ? 'TRUE' : 'FALSE', 'variable_get(weblinks_redirect)'); if (variable_get('weblinks_redirect', FALSE)) { $node->weblinks_title_link = 'weblinks/goto/'. $node->nid; } else { $node->weblinks_title_link = $node->url; } + $node->weblinks_title_link .= '++in_view_tpl_php'; ### DEBUG + dd($node->weblinks_title_link, '$node->weblinks_title_link'); $link = l($title, $node->weblinks_title_link, $options); + dd($link, 'in .tpl.php $link'); if (arg(0) == 'node' || variable_get('weblinks_show_url', TRUE)) { echo ''; } // Make the options available to the theme, just in case the user wants them. - //

< ?php print l($title, $node_url, $weblinks_options);? >

$node->weblinks_options = $options; }