By mdupont on
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
There's no direct way to do
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.
Modify your node.tpl.php file
You can remove the link in your node.tpl.php file. This is what generates the title:
So removing the "a" tag should do the trick.
I really don't think that's
I really don't think that's right, he's talking about a nodereference...
It's fine, but
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
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.