File: /home/iestorre/www2/modules/node_menu/node_menu_handler_field_link_title.inc
<?php
// $Id: node_menu_handler_field_link_title.inc,v 1.1.2.1 2009/04/10 11:52:56 develCuy Exp $
/**
* Field handler for node menu title.
*/
class node_menu_handler_field_link_title extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['link_to_path'] = array('default' => FALSE);
return $options;
}
/**
* Provide link to node option
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['link_to_path'] = array(
'#title' => t('Link this field to its path'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_path']),
);
}
/**
* Render whatever the data is as a link to the path.
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
node_menu_nodeapi($values, 'prepare');
if (!empty($this->options['link_to_path'])) {
return l($values->node_menu['title'], $values->node_menu['link_path'], array('html' => TRUE));
}
else {
return $values->node_menu['title'];
}
}
function render($values) {
return $this->render_link(check_plain($values->{$this->field_alias}), $values);
}
}