cck 节点类型的预处理函数

发布于 2024-08-17 17:09:57 字数 482 浏览 8 评论 0原文

(注:我最初将其发布在 drupal.org 上,然后才想起我从未在那里得到回复。因此,对于交叉发布感到抱歉)

您好,有没有一种方法(内置或其他方式)为特定添加预处理函数cck 节点类型?我希望对我的 cck 节点类型中的字段进行一些预处理。目前,我可以使用 theme_preprocess_node 然后在 $node->type 上进行切换,或者对特定字段名称使用主题函数(并且仍然进行切换以确保当前字段使用在我所在的节点类型内)寻找)。我建议的是有一个这样的函数...

theme_preprocess_mynodetype(&$vars) {
    // Now I can preprocess a field without testing whether the field is within the target content type
}

...但我不知道我是否可以像建议模板文件一样建议预处理函数

谢谢!抢

(Note: I originally posted this on drupal.org before remembering that I never get a response over there. So, sorry for the cross-posting)

Hello, is there a way (built-in or otherwise) to add preprocessing functions for particular cck node types? I am looking to do some preprocessing of a field within my cck node type. Currently I can either use theme_preprocess_node and then do a switch on the $node->type or use a theming function for a particular field name (and still do a switch to make sure the current field usage is within the node type i'm looking for). What I am suggesting is to have a function like this...

theme_preprocess_mynodetype(&$vars) {
    // Now I can preprocess a field without testing whether the field is within the target content type
}

...but I can't figure out if I can suggest preprocess functions the same way I can suggest template files

Thanks! Rob

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

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

发布评论

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

评论(2

多情出卖 2024-08-24 17:09:57

在cck的content.module中看到这个函数:


/**
 * Theme preprocess function for field.tpl.php.
 *
 * The $variables array contains the following arguments:
 * - $node
 * - $field
 * - $items
 * - $teaser
 * - $page
 *
 * @see field.tpl.php
 *
 * TODO : this should live in theme/theme.inc, but then the preprocessor
 * doesn't get called when the theme overrides the template. Bug in theme layer ?
 */
function content_preprocess_content_field(&$variables) {
  $element = $variables['element'];
...

See this function in content.module of cck:


/**
 * Theme preprocess function for field.tpl.php.
 *
 * The $variables array contains the following arguments:
 * - $node
 * - $field
 * - $items
 * - $teaser
 * - $page
 *
 * @see field.tpl.php
 *
 * TODO : this should live in theme/theme.inc, but then the preprocessor
 * doesn't get called when the theme overrides the template. Bug in theme layer ?
 */
function content_preprocess_content_field(&$variables) {
  $element = $variables['element'];
...

悍妇囚夫 2024-08-24 17:09:57

我认为您正在寻找这篇文章。没有神奇的每个节点预处理,只有每个主题/模板引擎,但您确实可以访问 $vars 参数中的节点类型,因此您可以在那里打开它。

希望有帮助!

I think that you're looking for this post. There's no magic per-node preprocess, only per theme/template engine, but you do have access to the node type in the $vars parameter so you can switch on it there.

Hope that helps!

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