(注:我最初发布这个在drupal.org记住的是,我从来没有在那里的响应之前那么,比较遗憾的是跨张贴)

您好,有一种方法(内置或以其它方式)以添加预处理功能为特定的CCK节点类型?我希望做我的CCK节点类型中的一个字段的一些预处理。目前,我既可以使用theme_preprocess_node,然后做一个交换机上的$节点 - >类型或使用主题化功能为特定的字段名(和仍然做一个开关,以确保目前现场使用的是节点类型我在找内对于)。我的建议是有这样的功能...

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

...但我想不通,如果我可以建议预处理功能,以同样的方式我可以建议模板文件

谢谢!罗布

有帮助吗?

解决方案

我认为你正在寻找这个帖子。没有什么神奇的每个节点的预处理,只有每个主题/模板引擎,但你有机会在$节点类型瓦尔参数,这样你可以在上面进行切换那里。

希望帮助!

其他提示

请参阅此功能在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'];
...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top