2014-02-25 98 views
4

我已经创建了一个内容类型,它有大约5个组都是垂直标签。Drupal 7将标题添加到我的内容类型中的每个分组部分?

由于某些原因,字段组标签不适用于垂直制表符。 <h2>标签始终为:<h2 class="element-invisible">Vertical Tabs</h2>。标题总是Vertical Tabs,不管manage fields中设置的是什么,它总是有这个类element-invisible

我注意到在一些使用垂直制表符的主题中完全一样。

我还注意到,这些主题在每个垂直选项卡上方都有一个额外的标题标签,它显示了该组的标题。 (adaptivetheme)就是一个很好的例子。

总之,实际问题....

怎样在我的内容类型添加标题,每个分组的部分(垂直选项卡)?

注意:这是添加内容的实际形式,而不是创建内容的显示 。

任何帮助,这是非常apprciated。

+0

查看https://drupal.org/node/17565以获取有关如何通过内容类型实现主题节点的信息。 –

+0

可以肯定,你想要的是为每个组添加另一个标题(除了不可见的标题之外)或者是否希望使不可见标题可见?如果是第二部分,我同意@nmc答案和模板文件。 – Djouuuuh

+0

谢谢@justinelejeune,但是如何为每个组添加标题?我没有看到一个选项...只是为用户添加内容的字段。 – Cybercampbell

回答

1

使用Drupal 7 content theming将标题添加到您的内容类型。举例来说,如果你的内容类型被评为为myContent然后在你的主题文件夹中创建下面的脚本:

{theme path}/page--node--mycontent.tpl.php 

预处理内容类型使用以下功能:

function mycontent_preprocess_page(&$vars) { 
    if (isset($vars['node']->type)) { 
     $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type; 
    } 
} 

更多信息的template_preprocess_page功能可用here

+0

嗨,感谢您的回应,但这是为了添加内容的实际形式而不是创建内容的显示。任何其他想法? – Cybercampbell

1

您可以在主题的template.php或自定义模块中自定义您的内容类型表单。这是记录here。例如,如果您使用自定义内容类型文章有一个自定义模块在你的主题Mymodule中,那么你可以自定义,像这样:

<?php 
/** 
* Implements hook_theme(). 
*/ 
function MYMODULE_theme($existing, $type, $theme, $path) { 
    return array(
    'article_node_form' => array(
     'render element' => 'form', 
     'template' => 'article-node-form', 
     // this will set to module/theme path by default: 
     'path' => drupal_get_path('module', 'MYMODULE'), 
    ), 
); 
} 
?> 

要输出的自定义数据:

<?php 
/** 
* Preprocessor for theme('article_node_form'). 
*/ 
function template_preprocess_article_node_form(&$variables) { 
    // nodeformcols is an alternative for this solution. 
    if (!module_exists('nodeformcols')) { 
    $variables['sidebar'] = array(); // Put taxonomy fields in sidebar. 
    $variables['sidebar'][] = $variables['form']['field_tags']; 
    hide($variables['form']['field_tags']); 
    // Extract the form buttons, and put them in independent variable. 
    $variables['buttons'] = $variables['form']['actions']; 
    hide($variables['form']['actions']); 
    } 
} 
?> 
1

其他这个问题的答案是正确的。负责垂直制表标题的代码是includes/form.inc文件中的theme_vertical_tabs函数。

如果你有自己的主题,你可以复制和改变你的主题的template.php文件中此功能来覆盖它:

function YOUR_THEME_NAME_vertical_tabs($variables) { 
    $element = $variables['element']; 

    // Add required JavaScript and Stylesheet. 
    drupal_add_library('system', 'drupal.vertical-tabs'); 

    // Following line changed to use title set in field settings and remove class="element-invisible 
    $output = '<h2>' . t($element['#title']) . '</h2>'; 
    $output .= '<div class="vertical-tabs-panes">' . $element['#children'] . '</div>'; 

    return $output; 
} 

如果您正在寻找使垂直标签标题出现在内容编辑屏幕,你有一个管理主题设置,然后上述修改需要做的管理主题。

相关问题