Drupal 6:通过视图模块在块中使用 php 获取 CCK 字段值

发布于 2024-09-06 00:17:24 字数 617 浏览 4 评论 0原文

我是一个 drupal 新手(认真的:)

我有一个块,是用视图模块创建的。并且该块内容具有CCK字段。我在视图模块中使用字段框显示任何字段。这很酷。

问题是,CCK 字段之一具有是否在主页链接的条件值。所以我需要获取field_homepage_linking CCK字段值的值,并说

  • 如果是1,则显示当前记录的链接,

  • 如果没有,则仅列出标题。

我安装了 http://drupal.org/project/views_customfield 模块,现在我可以在其中编写 php块视图。我尝试过

$node->field_homepage_linking["0"]["view"]

$node->field_homepage_linking["0"]["value"]

value_get('field_homepage_linking')

,但无法获取值! :/ 我怎样才能得到这个值?

赞赏有很大帮助!多谢!!

I'm a drupal newbie (mean it :)

I have a Block, created with View Module. and this block content has CCK fields. I display any of field with Fields Box in View Module. It's cool.

the issue is, one of the CCK field has a condition value for linking at homepage or not. So I need to get the value of field_homepage_linking CCK field value, and saying

  • if it is 1, displaying the link for the current record,

  • if not, just listing the title.

I installed the http://drupal.org/project/views_customfield module, now I can write php in Block View. I tried

$node->field_homepage_linking["0"]["view"]

$node->field_homepage_linking["0"]["value"]

value_get('field_homepage_linking')

but can't get the value! :/ how can I get the value?

Appreciate helps so much!! thanks a lot!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冬天旳寂寞 2024-09-13 00:17:24

我不完全确定我是否明白你想要做什么,但你必须确保 $node 对象指向有效的东西。

一般来说,如果您在 page.tpl.php 或 node.tpl.php 中打印 $node,您就会得到结果。在大多数其他情况下,您必须使用 node_load() 函数(http:// api.drupal.org/api/function/node_load/6)来获取节点对象。

i'm not totally sure if i get what you're trying to do, but you have to make sure the $node object points to something valid.

generally speaking, if you would print the $node in the page.tpl.php or node.tpl.php you'd get a result. in most other cases you'd have to use the node_load() function (http://api.drupal.org/api/function/node_load/6) to get the node object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文