Hi,

I'm using CCK nodereference to include registration webforms into some nodes. To achieve this, I chose to display the full webform node in the CCK nodereference field.
The only glitch is that the referenced node's title will link to the referenced node, which I don't want. Is it possible to theme easily these nodereference fields to remove the link?

Thanks!

Comments

Tom Ash’s picture

There's no direct way to do this - you can see this by looking at the contents of the variable for that field (which you can do by including printr($field_name); in your template file), and seeing that it only contains a linked version of the name. However, you could remove the link by passing this through something like strip_tags, or else you could run a SQL query like "SELECT title FROM node WHERE nid = $field_name[nid]" to get the title, and then print it directly in your template.

VividWind’s picture

You can remove the link in your node.tpl.php file. This is what generates the title:

<?php if ($page == 0): ?>
    <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>

So removing the "a" tag should do the trick.

Tom Ash’s picture

I really don't think that's right, he's talking about a nodereference...

christutty’s picture

The nodereference rendering still uses node.tpl.php, but so does *every other node* so this suggestion will change the title for all nodes.

You can limit the impact by adding a test for the node type

<?php 
if ($node->type == "yournodetype" ) {
  // do what's suggested
} else {
  // copy the original lines
}
?>

But I'm just starting drupal (and have to work out how to theme a nodererence) so don't treat this as gospel...

... and thanks to ryanprice's excellent article on theming nodereferences http://drupaleasy.com/trackback/192 I now know that this should (probably) be done by copying node.tpl.php to a new template called node-yourcontenttypename.tpl.php and modifying that.