Drupal 6:在views_customfield中使用php显示CCK字段值
已排序
http://drupal.org/node/467190#comment-2068324
嗨朋友们,
我花了一整天的时间寻找但找不到:(
如何在views_customfield中用php显示CCK字段值?我尝试了下面的,但没有结果
$node->field_homepage_linking[0]["view"]
$node->field_homepage_linking[0]["value"]
value_get('field_homepage_linking')
感谢帮助!
$node->field_homepage_linking[0]["视图"]
这适用于 tpl.php 文件,而不适用 在视图模块面板中工作如下 (截图)
替代文本http://img.skitch.com/20100616-dy2pxkdichni7nu1h747tptfa8.jpg
<?php
if ($node->field_homepage_linking[0]["view"] == 1) { ?>
<a href="<?php print drupal_get_path_alias("node/" .$data->nid) ; ?>" title="<?php print $data->node_title; ?>">
<?php } ?>
<?php print $data->node_title; ?>
<?php if ($node->field_homepage_linking[0]["view"] == 1) { ?>
</a>
<?php } ?>
SORTED
http://drupal.org/node/467190#comment-2068324
Hi friends,
I've spent all day to find but can't find :(
How can I display CCK Field value with php in views_customfield? I tried the ones below, but no result
$node->field_homepage_linking[0]["view"]
$node->field_homepage_linking[0]["value"]
value_get('field_homepage_linking')
Appreciate helps!!
$node->field_homepage_linking[0]["view"]
this works in tpl.php files, not not
working in View Module panel as below
(screenshot)
alt text http://img.skitch.com/20100616-dy2pxkdichni7nu1h747tptfa8.jpg
<?php
if ($node->field_homepage_linking[0]["view"] == 1) { ?>
<a href="<?php print drupal_get_path_alias("node/" .$data->nid) ; ?>" title="<?php print $data->node_title; ?>">
<?php } ?>
<?php print $data->node_title; ?>
<?php if ($node->field_homepage_linking[0]["view"] == 1) { ?>
</a>
<?php } ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这对我有用:
customfield 中用于加载 cck 字段的 PHP 代码
This works for me:
The PHP code in customfield for loading cck field
已排序
http://drupal.org/node/467190#comment-2068324
SORTED
http://drupal.org/node/467190#comment-2068324
看起来像是一个笔误。
应该是:
虽然,如果它是 CCK 字段,为什么不将其添加为字段呢?所有 CCK 字段都位于字段的内容类别下。另外,为此,您需要加载 $node 对象并准备好供视图使用,这也可能是您看不到任何内容的原因。
看起来您想要有条件显示。我不知道如何在自定义字段中执行此操作,但我已经使用特定字段的 .tpl 字段多次执行此操作。您可以将主题 tpl 文件添加到视图中并在其中包含 PHP 代码,还可以转储视图的 $row 和 $data 对象以查看必须使用哪些字段/值。
Looks like a clerical error.
Should be:
Although, if its a CCK field, why not just add it as a Field? All CCK fields are under the Content category of the Fields. Also, to do this, you need the $node object loaded and ready to use by Views, which may also be why you aren't seeing anything.
Looks like you want to have a conditional display. I am not sure how to do this in Customfield, but I have done this many times with a .tpl field for particular fields. You can add theme tpl files to Views and have PHP code inside it, and also dump out the $row and $data object of views to see what fields/values you have to work with.