I'm running 4.7.3 and trying to customize the display of a CCK field called "field_web_site".

I'm want to modify the node.tpl.php file to include this field as a link from the title (instead of the title linking to the node)....

Here is the existing code:

  <a href="<?php print $node_url ?>"><?php print $title; ?></a>

Here is what I'm inserting:

  <a href="<?php print $field_web_site ?>"><?php print $title; ?></a>

And the link resolves as http://domain.com/Array - which leads me to think that there is array somewhere that stores this variable (field_web_site), and I'm just missing it? Or I need to create it?

Any help or pointers is greatly appreciated.
mcspoon

Comments

boneless’s picture

try $field_web_site['value'] or $field_web_site['view']
if you wanna know what exactly is in the array, try 'variable_set('my_field',$field_web_site);'
and have a look for my_field in table 'variable'.
or use devel.module.

lanexa’s picture

But thanks. I tried both 'value' and 'view'. I still can't seem to print what's in the array....

I installed devel.module, but it doesn't show up in my list of installed modules.

Still looking,
mcspoon

lanexa’s picture

But thanks. I tried both 'value' and 'view'. I still can't seem to print what's in the array....

I installed devel.module, but it doesn't show up in my list of installed modules.

Still looking,
mcspoon

rick hood’s picture

I believe you should use this in your node.tpl.php file:

<?php print $node -> content['field_web_site']['#value']; ?>
lanexa’s picture

Thanks Rick. That works and I can print the pair, but I'm trying to populate a
<a href=" "> tag with the URL only (the value), not the field name. Here is what I'm using:

<a href="<?php print $node  -> content....  ?>"><?php print $title; ?></a>

I want the title to be a link to the #value URL, if that makes sense.
mcspoon

rick hood’s picture

Boy, I'm not sure what you mean. The '#value' I just the value of the field (text or a number or whatever).

You said you "want the title to be a link to the #value URL". Do you mean you want the node title ($title) to be the text of the link and you want $node -> content['field_web_site']['#value'] to be the URL of the link?

If so, the way you are doing it seems OK, I think.

However, one thing that comes to mind is that $title is already a link because the node variable $title links to the node by default. I am not sure how to make $title just text and not a link.

The 'l' function (http://api.drupal.org/api/5/function/l) might help you out with this – not sure.

lanexa’s picture

Yes, the #value is what I want displayed (in these case, the #value is a URL). What I don't want displayed is the 'field_web_site', but it seems I can't just show the #value.

Does that make sense?
Thanks for all of your ideas and input.

rick hood’s picture

Ah, I think I see what you want to do – you want the "label" of the field to be hidden – you just want to show the value of the field, but not the label.

OK here is how you do that:

1. Go into your CCK content type (edit it)
2. Click the 'Display fields' tab.
3. See the first column is called 'Label' - you can choose 'hidden' for that URL field that you want to get rid of the label on.

Is that what you meant?

lanexa’s picture

yes, thats what i want, but within the tag above......sorry, but ive recently broken my arm and i cant type well. thx 4 the effort.