5
每种内容类型的预处理功能
我有几种内容类型,需要以不同的方式进行预处理。所以template.php在我的主题中foo当前看起来像: function foo_preprocess_node(&$variables) { if ('news' ==$variables['type']) _preprocess_news($variables); if ('event'==$variables['type']) _preprocess_event($variables); if ('alert'==$variables['type']) _preprocess_alert($variables); ... } function _preprocess_news(&$variables) { ... } function _preprocess_event(&$variables) { ... } function _preprocess_alert(&$variables) { ... } 我希望能够指定特定于Drupal的预处理功能,该功能将与内容类型的计算机名称挂钩。我尝试使用,foo_preprocess_news但从未调用过。 有没有更好的办法?