欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Best way to display field values from a referenced node (CCK - Contemplate) 输出 node 字段 变量 节点 变量 view 有大用 有大大用

见下面红色字的部分

从引用节点显示字段值的最佳方法(CCK - Contemplate)

我使用考虑提供我的节点体的布局。我有几个使用CCK创建的节点类型,我的几个节点类型引用其他节点类型(使用CCK节点引用字段类型)。我显示来自不同节点类型的主体中的一个节点类型的字段值。哦,我使用版本5.1

我的例子:
我有一个'项目'节点类型,它的领域之一是“描述”(名称:dr_item_desc,类型:文本)
我有一个“任务”节点类型,它的领域之一是'项目'(名称: rel_dr_item,类型:节点参考)
在“任务”我想要显示的引用'项目'节点'说明'字段的身体

我目前的方法:
获得参考节点的“NID”价值
- $ item_nid = $于节点> field_rel_dr_item [0] ['NID']; 
使用Drupal的node_load()函数加载相应的节点对象
- $ item_node = node_load($ item_nid); 
构建使用Drupal的node_build_content()函数节点内容
- $ item_node = node_build_content($ item_node); 
得到我想要显示的字段“视图”价值
- $ ITEM_DESC = $ item_node-> field_dr_item_desc [0] ['查看'];

我的问题:
我关心的开销,而且在我看来,我的方法需要大量的开销来获取值。是否有更好/更快/更优雅的方法,我应该采取?我曾经考虑过直接使用SQL和Drupal的数据库基础设施提取数据,但似乎我不应该需要。任何想法将不胜感激。

注释

Lioz的图片

我试过你的解决方案没有成功。
你可以发布确切的代码?你把它放在节点模板中吗?

Lioz的图片

这是我使用的确切代码...

$item_nid = $node->field_rel_dr_item[0]['nid'];
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->field_dr_item_desc[0]['view'];

我把代码中的“身体模板”字段用于节点类型的模板在
/管理/内容/模板/ {节点型}

Lioz的图片

工作完美!

我有一个“库”内容与节点引用角色内容(filed_persona),我想显示引用节点的“qualifica”属性。

<?php
$item_nid = $node->field_persona[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->field_qualifica[0]['view'];
print $item_desc;
?>

所以我进入库节点

persona - qualifica

只是另一个问题。引用可以有多个值。

persona1 - qualifica1 
persona2 - qualifica2 
persona3 - qualifica3

任何建议?也许我们可以使用像

<?php foreach ($field_persona as $alias) { ?>

没有PHP的大知识
:(

Lioz的图片

看看通过考虑CCK字段提出的代码。这个foreach语句用于打印每个值

    <?php foreach ((array)${EXAMPLE FIELD NAME} as $item) { ?>
      <div class="field-item"><?php print $item['view'] ?></div>
    <?php } ?>

所以在你的代码中,你把变量$ item_desc赋给一个特定的值,这里...

$item_desc = $item_node->field_qualifica[0]['view'];

如果你改为分配的对象(或数组 - 不确定它是在这一点,但它不重要)值,像这样...

$item_desc = $item_node->field_qualifica;

然后,在理论上,遵循考虑的代码,以下应该输出每个值(我想)

    <?php foreach ((array)$item_desc as $item) { ?>
      <div class="field-item"><?php print $item['view'] ?></div>
    <?php } ?>
Lioz的图片

谢谢,这些片段是非常有用的!

我需要打印从单个节点引用字段引用的多个节点的标题和正文。对于任何想要这样做的人,这里的代码为我工作:

<?php foreach ((array)$field_example_node_reference_field as $item) { ?>
<?php 
$item_nid = $item['nid'];
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->body;  ?>
<div class="field-item"><h3><?php print $item['view'] ?></h3></div>
<div class="field-item" style="margin-left:20px;"><?php print $item_desc ?></div>
    <?php } ?>

我相当肯定,你可以将$ item_node-> body更改为$ item_node-> whatever_field_you_want。

Lioz的图片

没关系

Lioz的图片

我加载的节点,然后做一个打印...和所有的字段没有一个['view']选项。我的理解是,这是处理输入过滤器的字段。为了保持整个网站的一致性,使用['view']是最好的选择。

node_build_content()没有在任何字段上产生['view']选项,而是node_view()。因此,我目前使用的代码是:


foreach($node->field_referenced_field as $item)
{
  $refNode = node_load($item['nid']);
  node_view($refNode);//好像调用了它就临时缓存起来了.

  print $refNode->field_field[0]['view'];
  //etc.

我理解这可能是最处理器密集的方式来做它...但与缓存,谁在乎?似乎是对我最好的选择 - 但我只是在我走了。

Lioz的图片

我不能得到一个非常概括你正在努力。视图不适合整理各种内容类型的字段吗?您还可以融合更复杂聚合的视图。

Lioz的图片

是的,我尝试使用视图,但我只想从“父”节点获取字段(“field_dr_item_desc”)的具体值。

在我的case - 一个“项目”节点可能有许多“任务”节点(所以“项目”是所谓的“任务”的“父”我使用nodereference字段类型与我的“任务”选择相关的“项目”节点,“项目”节点具有要在“任务”节点的节点页面上显示的字段“”field_dr_item_desc“。

仅显示视图,允许我显示完整节点,前导广告,表格或节点列表。我能够在表或节点列表中获取字段“field_dr_item_desc”的值。我也能够在“任务”节点页面中插入该视图,但视图给了我所有的额外的html标记,我不想要或需要。我不知道如何获取视图只输出“field_dr_item_desc”的值,没有任何额外的标记 - 我不认为这是一个选项?

我没有试图“融合”anyting - 这是你所指的融合模块还是别的什么?

Lioz的图片

不幸的是,这听起来似乎视图不工作对你,由于2约束:(1)项目节点不知道它是在哪个任务视图(2)项节点字段添加到视图时不呈现。

除非你的任务/项目只是一个例子,你看着任务模块:http://drupal.org/project/tasks

Lioz的图片

我试图得到一个CCK节点参考加载到一个单独的块在页面上,有一个艰难的时间,直到我找到你的帖子。我刚刚开始这样(node_build_content)是关键。如果有更有效的方式这样做,那么也许有人会更新这个线程。

Lioz的图片

我试图使用您的技术显示节点引用节点的标题。I节点从另一个CCK节点类型引用location_type,然后使用计算字段来计算我选择的位置类型节点的标题。

$item_nid = $node->field_location_type[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->field_title[0]['value'];
$node_field[0]['value'] = "title = " . $item_desc;

我得到的显示是...  title =

我可以确认item_nid正在返回正确的节点。该内容类型只有标题字段,没有其他字段。

我试着使用两者

$item_desc = $item_node->field_title[0]['value'];

$item_desc = $item_node->field_title[0]['view'];

具有相同的结果。

任何想法,我可能会误入歧途?

您的帮助是赞赏。

Lioz的图片

尝试对你的$ item_node做一个print_r(),它可以真正帮助,当试图找出是否应该使用['value']或['view']或['nid']或别的东西。

这里有一大块代码我使用一些成功(在body字段中放置输入格式设置为PHP代码)

$nid = arg(1);
$node = node_load($nid);
$out = strip_tags(print_r($node, TRUE));
print ''. $out .'';

对不起,我还没有使用任何计算字段,所以没有提供在那个级别。

Lioz的图片

谢谢,这是有帮助的。对我来说,它不提供完整的答案,虽然我想做一些完全不同的事情。这可能不是正确的地方问,但也许有人在这里可以帮助我或指导我到正确的地方。

我想在节点中放置一个“节点”,特别是一个webform节点,包含字段和提交按钮。

有没有人知道一个通用的方式来渲染任何类型的完整节点,将在另一个节点中运行,就像在自己的页面上?

谢谢!
道格

------------------------ 
天色技术
关于过敏
---------------------- - -

Lioz的图片

不正是你想要做什么ADDNODE集成了一个节点中的一个节点,创建表单帮助吗?

Lioz的图片

有什么方法可以使用您的方法检索图像的filepath字段?
我使用imagefield将图像上传到我的节点,我只是找不到一种方法来检索图像的文件路径,当我使用视图。

Lioz的图片

如果您使用CCK,你可以叫module_invoke,而不诉诸node_build_content返回格式化的项目。

例如,我需要一个来自节点的imceimage字段的图像显示在一个块...我能够通过调用CCK的格式化函数获得渲染的html。

$image = module_invoke('content', 'format', 'field_image', $node->field_image[0]);

打印$ image无论你想要的图像HTML结束。

这里是content.module的格式函数的完整描述:

/**
 * Format a field item for display.
 *
 * Used to display a field's values outside the context of the $node, as
 * when fields are displayed in Views, or to display a field in a template
 * using a different formatter than the one set up on the Display Fields tab
 * for the node's context.
 *
 * @param $field
 *   Either a field array or the name of the field.
 * @param $item
 *   The field item(s) to be formatted (such as $node->field_foo[0],
 *   or $node->field_foo if the formatter handles multiple values itself)
 * @param $formatter_name
 *   The name of the formatter to use.
 * @param $node
 *   Optionally, the containing node object for context purposes and
 *   field-instance options.
 *
 * @return
 *   A string containing the contents of the field item(s) sanitized for display.
 *   It will have been passed through the necessary check_plain() or check_markup()
 *   functions as necessary.
 */

function content_format($field, $item, $formatter_name = 'default', $node = NULL) {
...
Lioz的图片

使用

$image = module_invoke('content', 'format', 'field_image', $node->field_image[0]);

为我工作。

在我的情况下,默认格式化是不够的,所以我添加了一个自定义imagecache格式化器在最后使用这段代码:

$image = module_invoke('content', 'format', 'field_image', $node->field_image[0], 'name_of_imagecache_preset');

希望帮助别人

Lioz的图片

** 书签 **

Lioz的图片

订阅

Lioz的图片

订阅,问候,Martijn

Lioz的图片

订阅

Lioz的图片

订阅

Lioz的图片

订阅

Lioz的图片

这适用于我:

内部node.tpl.php,或节点TYPE.tpl.php

其中:field_FIELDNAME =要从中检索条目的nodereference字段。要找到这个,print_r($ node),这样你可以看到字段被调用。

<?
	/* Setup Variables — this isn't needed if this code is inside node.tpl.php */
	//$field_FIELDNAME = $node->field_FIELDNAME;
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	 * loop through all node-reference related items and print a list */
	if ($field_FIELDNAME[0]['nid']) {
	print "<h3>" . t("Related Items") . "</h3>";
	print "<ul>";
	foreach ($field_FIELDNAME as $value) {
			$value2 = node_load($value[nid]);
			$nodetoview = $value2;
			print "<li>";
			print "<strong>" . $nodetoview->title . "</strong>";
			print node_view($nodetoview,$teaser = FALSE, $page = True, $links = FALSE);
			print "</li>";
		}
		print "</ul>";
	}		

?>

---- 
关键字搜索:
负载节点引用节点,查看nodereference节点负载参考节点


wOOge | adrianjean.ca

Lioz的图片

订阅!

大线程。但是有没有人回答原来的海报问题关于开销?我也很感兴趣。

Lioz的图片

OMG - 我一直想要一个答案我的原始问题了!所以,当然,开销是可怕的,我会避免使用它在预告片,如果可能的话。缓存也有很大的帮助。Views自从我最初发布的问题也有很大的进步,所以如果你可以把你需要的值在一个块或东西,可能是一个很好的方式去。

cdesautels的图片

功能custom_misc_retrieve_single_field($ NID,$场){ 
$查询= db_select('field_revision_'$领域,'F'); 
$查询
- >状态('f.entity_id',$ NID)
- >字段('F',阵列($场'_value'))
- >排序依据('REVISION_ID','DESC')
- >范围(0 ,1); 
$ result = $ query-> execute() - > fetchCol(); 
return $ result [0]; 
}}

Lioz的图片

大家好。这不工作在Drupal 7 / Contemplate 7.x-1.0。

如何在D7上打印节点引用字段值?

Lioz的图片

我也需要知道如何在D7中打印节点参考值。任何人知道如何?

Lioz的图片

Drupal 7的解决方案,
我花了很多时间找一个,所以我将分享。

$node = node_load($nid);
$values = field_get_items('node', $node, 'field_XXXX');
$output = field_view_value('node', $node, 'field_XXXX', $values[0]);
print render($output);

该解决方案可与“ node_reference ”域“,选择 ”域“ 文本 ”字段或任何其他字段类型,这样就可以通过各个领域的环路,做同样的过程中无一例外。

来自  https://www.drupal.org/node/129295



 

Best way to display field values from a referenced node (CCK - Contemplate)

 

I am using contemplate to provide the layout of my node body. I have several node types created using CCK, and several of my node types reference other node types (using the CCK node reference field type). I am displaying field values from one node type in the body of a different node type. Oh, and I am using version 5.1

My example:
I have an 'Item' node type, one of its fields is 'Description' (name: dr_item_desc, type: text)
I have a 'Task' node type, one of its fields is an 'Item' (name: rel_dr_item, type: node reference)
In the body of the 'Task' I want to display the referenced 'Item' node's 'Description' field

My current methodology:
Get the 'nid' value of the referenced node
- $item_nid = $node->field_rel_dr_item[0]['nid'];
Load the corresponding node object using Drupal's node_load() function
- $item_node = node_load($item_nid);
Build the node content using Drupal's node_build_content() function
- $item_node = node_build_content($item_node);
Get the 'view' value of the field I want to display
- $item_desc = $item_node->field_dr_item_desc[0]['view'];

My question:
I am concerned about overhead, and it seems to me that my method takes a lot of overhead to get the value. Is there a better / quicker / more elegant approach I should be taking? I had thought about pulling the data directly using SQL and Drupal's database infrastructure, but it seems I shouldn't need to. Any thoughts would be appreciated.

Comments

Lioz的图片

i tried your solution without success.
can you post the exact code? did you put it in the node template?

Lioz的图片

This is the exact code I am using...

$item_nid = $node->field_rel_dr_item[0]['nid'];
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->field_dr_item_desc[0]['view'];

I put the code in the "body template" field for the node-type template at
/admin/content/templates/{node-type}

Lioz的图片

Worked perfectly!

I have a "library" content with a node reference to persona content (filed_persona) and i wanted to display the "qualifica" attribute of the refernced node.

<?php
$item_nid = $node->field_persona[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->field_qualifica[0]['view'];
print $item_desc;
?>

so i get into the library node

persona - qualifica

just another question. The reference can have mutliple values.

persona1 - qualifica1
persona2 - qualifica2
persona3 - qualifica3

any suggestion? maybe we can use something like

<?php foreach ($field_persona as $alias) { ?>

don't have big knowledge of php
:(

Lioz的图片

Looking at the code presented by contemplate for CCK fields. This foreach statement is used to print out each value

    <?php foreach ((array)${EXAMPLE FIELD NAME} as $item) { ?>
      <div class="field-item"><?php print $item['view'] ?></div>
    <?php } ?>

So in your code, where you assign the variable $item_desc to a specific value, here...

$item_desc = $item_node->field_qualifica[0]['view'];

If you instead assigned it the object (or array - not sure which it is at this point, but it shouldn't matter) value, like so...

$item_desc = $item_node->field_qualifica;

Then, in theory, following the contemplate code, the following should output each value (I think)

    <?php foreach ((array)$item_desc as $item) { ?>
      <div class="field-item"><?php print $item['view'] ?></div>
    <?php } ?>
Lioz的图片

Thanks, these snippets were very useful!

I needed to print the title & body of multiple nodes referenced from a single node-reference field. For anyone who's looking to do this, here's the code that worked for me:

<?php foreach ((array)$field_example_node_reference_field as $item) { ?>
<?php 
$item_nid = $item['nid'];
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->body;  ?>
<div class="field-item"><h3><?php print $item['view'] ?></h3></div>
<div class="field-item" style="margin-left:20px;"><?php print $item_desc ?></div>
    <?php } ?>

I'm reasonably sure you could change the $item_node->body to $item_node->whatever_field_you_want.

Lioz的图片

nevermind

Lioz的图片

I'm loading up the node, then doing a print...and all of the fields don't have a ['view'] option. My understanding is that this is the field that has processed the input filter. In the interest of keeping everything consistent across the site, using the ['view'] is the best option.

node_build_content() did not produce the ['view'] option on any fields, but node_view() did. Therefore the code I'm using at the moment is:


foreach($node->field_referenced_field as $item)
{
  $refNode = node_load($item['nid']);
  node_view($refNode);

  print $exercise->field_field[0]['view'];
  //etc.

I understand this is probably the most processor intensive way to do it...but with caching on, who cares? Seems like the best option to me--but I just made it up as I went.

Lioz的图片

I couldn't get a very overview of what you're working towards. Wouldn't views be more appropriate for collating the fields from various content types? You can also fuse views for more complex aggregates.

Lioz的图片

Yes, I tried using Views, but I only wanted to get the specific value of a field ("field_dr_item_desc") from a "parent" node.

In my case - one "item" node may have many "task" nodes (so "item" is the so-called 'parent' of "task". I am using the nodereference field type with my "task" nodes to be able to choose the related "item" node. The "item" node has the field ""field_dr_item_desc" that I want to display on the node page of the ""task" node.

Views only appears to allow me to show a Full Node, a Teaser, Table, or a Node List. I was able to get the value of the field "field_dr_item_desc" in a Table or a Node List. I was also able to insert that View in the "task" node page, but the View gave me all the extra html markup that I didn't want or need. I couldn't figure out how to get Views to just output the value of "field_dr_item_desc" without any additional markup - I don't think that is an option?

I haven't tried to "fuse" anyting - Is this the views fusion module you are referring to or something else?

Lioz的图片

Unfortunately, it sounds like views isn't working for you due to 2 constraints: (1) the item node wouldn't know which task view it was in (2) the item node fields are not rendered when added to the view.

Unless your tasks/items was just an example, have you looked into the task module: http://drupal.org/project/tasks

Lioz的图片

I was trying to get a CCK node-reference loaded into a separate block on the page and was having a tough time until I found your post. I'm just starting so (node_build_content) was the key. If there is a more efficient way of doing this, then maybe someone else will update this thread.

Lioz的图片

I am trying to display the title of a node referenced node using your technique. I node reference a location_type from another CCK node type and then use a computed field to compute the title of the location type node that I selected.

$item_nid = $node->field_location_type[0]['nid'] ;
$item_node = node_load($item_nid);
$item_node = node_build_content($item_node);
$item_desc = $item_node->field_title[0]['value'];
$node_field[0]['value'] = "title = " . $item_desc;

The display that I get is ...  title =

I can confirm that item_nid is returning the correct node. That content type only has a title field, and no other fields.

I tried using both

$item_desc = $item_node->field_title[0]['value'];

and

$item_desc = $item_node->field_title[0]['view'];

with the same results.

Any idea where I might be going astray?

Your help is appreciated.

Lioz的图片

Try doing a print_r() on your $item_node, it can really help when trying to figure out if you should use ['value'] or ['view'] or ['nid'] or something else.

Here's a chunk of code I use with some success (place in a body field with input format set to PHP code)

$nid = arg(1);
$node = node_load($nid);
$out = strip_tags(print_r($node, TRUE));
print ''. $out .'';

Sorry I also haven't worked with any calculated fields yet, so have nothing to offer on that level.

Lioz的图片

Thanks, that was helpful. For me though, it does not provide the full answer, although I am trying to do something quite different. This may not be the right place to ask but maybe someone here can help me or direct me to the right place.

I want to place a "node within a node", specifically a webform node, complete with fields and submit button.

Does anyone know a general way to render a complete node of any type that will function within another node just as if it was on its own page?

Thanks!
Doug

------------------------
Partly Technical
About Allergies
------------------------

Lioz的图片

Not exactly what you're trying to do the Addnode incorporates a node and creation form inside a node does that help?

Lioz的图片

Is there any way you could retrieve the filepath field of an image using your method?
I'm using imagefield to upload images into my node, I just can't find a way to retrieve the filepath of the image when I'm using views.

Lioz的图片

If you're using CCK, you can call module_invoke to return the formatted item without resorting to node_build_content.

For example, I needed an image from a node's imceimage field to display in a block... I was able to get the rendered html by calling CCK's format function.

$image = module_invoke('content', 'format', 'field_image', $node->field_image[0]);

Print $image wherever you want the image HTML to end up.

Here's the full description of the format function from content.module:

/**
 * Format a field item for display.
 *
 * Used to display a field's values outside the context of the $node, as
 * when fields are displayed in Views, or to display a field in a template
 * using a different formatter than the one set up on the Display Fields tab
 * for the node's context.
 *
 * @param $field
 *   Either a field array or the name of the field.
 * @param $item
 *   The field item(s) to be formatted (such as $node->field_foo[0],
 *   or $node->field_foo if the formatter handles multiple values itself)
 * @param $formatter_name
 *   The name of the formatter to use.
 * @param $node
 *   Optionally, the containing node object for context purposes and
 *   field-instance options.
 *
 * @return
 *   A string containing the contents of the field item(s) sanitized for display.
 *   It will have been passed through the necessary check_plain() or check_markup()
 *   functions as necessary.
 */

function content_format($field, $item, $formatter_name = 'default', $node = NULL) {
...
Lioz的图片

Using

$image = module_invoke('content', 'format', 'field_image', $node->field_image[0]);

worked for me.

In my case default formatter was not enough, so i added a custom imagecache formatter at the end using this code:

$image = module_invoke('content', 'format', 'field_image', $node->field_image[0], 'name_of_imagecache_preset');

Hope helps someone

Lioz的图片

** bookmark **

Lioz的图片

Subscribing

Lioz的图片

Subscribing, greetings, Martijn

Lioz的图片

Subscribing

Lioz的图片

subscribe

Lioz的图片

subscribe

Lioz的图片

This works for me:

Inside node.tpl.php, OR node-TYPE.tpl.php

Where: field_FIELDNAME = the nodereference field you want to retrieve entries from. To locate this, print_r($node) so you can see what the field is called.

<?
	/* Setup Variables — this isn't needed if this code is inside node.tpl.php */
	//$field_FIELDNAME = $node->field_FIELDNAME;
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	 * loop through all node-reference related items and print a list */
	if ($field_FIELDNAME[0]['nid']) {
	print "<h3>" . t("Related Items") . "</h3>";
	print "<ul>";
	foreach ($field_FIELDNAME as $value) {
			$value2 = node_load($value[nid]);
			$nodetoview = $value2;
			print "<li>";
			print "<strong>" . $nodetoview->title . "</strong>";
			print node_view($nodetoview,$teaser = FALSE, $page = True, $links = FALSE);
			print "</li>";
		}
		print "</ul>";
	}		

?>

----
For Keyword Searching:
Load node referenced nodes, view nodereference nodes, load referenced node

--
wOOge | adrianjean.ca

Lioz的图片

Subscribing!

Great thread. But did anyone answer the original posters question about the overhead? I am interested in that as well.

Lioz的图片

OMG - I have always wanted an answer to my original question too! So, of course the overhead is terrible, and I would avoid using it in a teaser, if possible. Caching helps a great deal as well. Views has also advanced greatly since I originally posted the question, so if you can put the value you need in a block or something that might be a good way to go as well.

cdesautels的图片

function custom_misc_retrieve_single_field($nid, $field) {
$query = db_select('field_revision_' . $field, 'f');
$query
->condition('f.entity_id', $nid)
->fields('f', array($field . '_value'))
->orderBy('revision_id', 'DESC')
->range(0, 1);
$result = $query->execute()->fetchCol();
return $result[0];
}

Lioz的图片

Hey guys. This does not work on Drupal 7/Contemplate 7.x-1.0.

How do you print node reference field values on D7?

Lioz的图片

I, too, need to know how to print node reference values in D7. Anyone know how?

Lioz的图片

Drupal 7 solution
I spent hours to find that one so I will share it.

$node = node_load($nid);
$values = field_get_items('node', $node, 'field_XXXX');
$output = field_view_value('node', $node, 'field_XXXX', $values[0]);
print render($output);

This solution works with "node_reference" fields, "select" fields, "text" fields or any other field types, so you can loop through all fields and do the same process without exception.

来自 https://www.drupal.org/node/129295


普通分类: