Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting plain text of a field in drupal 7

Tags:

drupal-7

I have a content type including two fields: First name(node title) and Last name(text field) In node.tpl I want to print first name and last name sequentially.

I use the following code to do this but it prints first name and last name in seperate lines.That's because last name is wrapped in a div.Is there any way to get raw text of the last name field?

<?php print $node->title . render($content['field_last_name']);?>
like image 487
Nick.h Avatar asked Jan 20 '23 15:01

Nick.h


1 Answers

Try this out:

<?php
print $content['field_phone_number'][0]['#markup'];
?>

Simply replace the 'field_phone_number' with 'field_last_name'. You can do the same for the first name too.

like image 77
zach Avatar answered Mar 12 '23 15:03

zach