繁体   English   中英

特定内容类型的主题所有Drupal 7 Web表单

[英]Theme ALL Drupal 7 webforms of a certain content type

我知道如何使用webform-form-[nid].tpl.php覆盖Drupal 7 Webform,但是如何将特定内容类型的所有Drupal 7 Webforms作为主题。

该内容类型始终具有相同的形式,但是nid随新的节点ID更改,因此我不能使用常规方法。

能做到吗?

您可以将节点类型添加到主体类中。

// Replace hook with your theme name and put this in your template.php
function hook_preprocess_html(&$vars) {
  //  Add  class to body if certain node type
  if ($node = menu_get_object()) {
    $vars['classes_array'][] = "node-type-" . $node->type;
  }
}

然后,您可以按节点类型设置表单样式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM