Is there a way to print field content without getting all the markup? I’m new to Drupal, but I’m aware of the field.tpl.php, however, I’m just wondering if there’s a quicker way to get the content in a node–custom.tpl.php. It would compare to WordPress’s <?php echo get_field('field_name'); ?>
Is there a way to print field content without getting all the markup? I’m
Share
Well, apart from using field.tpl.php, I can think of 2 solutions:
first:
Use a php snippet to strip html tags in your template.php.
in your template.php
then call the function
mytheme_strip_html_tags($field_name)if you use several themes, however, you need to copy this snippet to each one of them.
EDIT: You can make a module and place that snippet inside. This way it works with every theme.
second:
Download the tokens module. Tokens are references to your fields. Tokens module have a output mode that strips html for you. [field_name-raw]
You need to follow instructions in how to add tokens, but is not that difficult.