cck 节点类型的预处理函数
(注:我最初将其发布在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在cck的content.module中看到这个函数:
See this function in content.module of cck:
我认为您正在寻找这篇文章。没有神奇的每个节点预处理,只有每个主题/模板引擎,但您确实可以访问 $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!