Hei*_*ive 9 css drupal regions drupal-7
我想在Drupal 7中向我的页脚区域添加一个.clearfix类.有没有办法做到这一点?
我目前正在使用以下内容来打印我的页脚区域:
<?php print render($page['footer']); ?>
Run Code Online (Sandbox Code Playgroud)
哪个输出:
<div class="region region-footer">
<div id="block-1>....</div>
<div id="block-2>....</div>
</div>
Run Code Online (Sandbox Code Playgroud)
小智 34
这是代码片段:
function MY_THEME_NAME_preprocess_region(&$variables, $hook) {
if($variables['region'] == "MY_REGION_NAME"){
$variables['classes_array'][] = 'MY_CLASS_NAME';
}
}
Run Code Online (Sandbox Code Playgroud)
或者,如果您希望将类插入所有区域:
function MY_THEME_NAME_preprocess_region(&$variables, $hook) {
$variables['classes_array'][] = 'MY_CLASS_NAME';
}
Run Code Online (Sandbox Code Playgroud)
将region.tpl.php(在modules/system目录中找到)复制到您的主题目录.然后复制其中的所有内容并创建一个新文件.粘贴到该文件中,然后对模板进行任何更改.完成后,将其保存为region - footer.tpl.php并清除站点上的缓存以查看更改.
region.tpl.php包含(以及许多解释可能变量的注释):
<?php if ($content): ?>
<div class="<?php print $classes; ?>">
<?php print $content; ?>
</div>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
所以你需要做的就是在那个DIV上添加一个类.