问题描述
我正在使用下面的代码将节点的字段打印到特定的区域,它的效果非常好。但是,这是一个我只想打印你没有标签的字段的值的实例。似乎应该很容易,但我有一点麻烦。我很感激任何帮助,因为我是新来的drupal。感谢
I'm using the code below to print the out the field of nodes to specific areas and it works great. But theres an instance where I just want to print the value you of field without the label. Seems as it should be pretty easy but I'm having a bit of trouble. I'd appreciate any help as i'm pretty new to drupal. Thanks
<?php
print drupal_render(field_view_field('node', $node, 'field_description')); ?>
推荐答案
field_view_value() code>需要一个
$ display
参数,您可以使用它来隐藏标签:
field_view_value()
takes a $display
argument that you can use to hide the label:
$display = array('label' => 'hidden');
$view = field_view_field('node', $node, 'field_description', $display);
print drupal_render($view);
如果您只想提取字段的原始值,您可以使用
field_get_items()
/ a>代替:
If you just want to extract the raw value of the field you can use
field_get_items()
instead:
$items = field_get_items('node', $node, 'field_description');
$first_item = array_shift($items);
$description = $first_item['value'];
这篇关于仅打印drupal field_view_field值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!