【问题标题】:Can someone please help me, where on earth is this div tag located? in which module or theme?有人可以帮我吗,这个 div 标签到底在哪里?在哪个模块或主题中?
【发布时间】:2012-12-20 07:40:08
【问题描述】:
下面是代码
<div id="block-search-form" class="block block-search contextual-links-region first last odd" role="search">
..........................
...............
</div>
这个块里面是搜索表单。此代码位于标题中。我想摆脱 class="" 中的块类,但我找不到这个模板文件。我已经搜索了几个小时,也搜索了整个互联网。有人可以帮帮我吗?我也在使用 Zen Theme
谢谢!!!!!!
【问题讨论】:
标签:
drupal
drupal-7
drupal-theming
【解决方案1】:
第一件事:devel_themer 模块可以帮助您找到这个。
第二:您正在寻找block.tpl.php 模板。它可能会被覆盖,因此请查找以block-- 开头的模板。
【解决方案2】:
block.tpl.php文件使用的代码如下。
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
<?php print render($title_suffix); ?>
<div class="content"<?php print $content_attributes; ?>>
<?php print $content ?>
</div>
</div>
模板文件不包含使用的类,但您可以使用hook_preprocess_block() 删除部分类。
function mymodule_preprocess_block(&$variables) {
if (strpos($variables['classes'], 'block-search') !== FALSE) {
$variables['classes'] = str_replace('block ', '', $variables['classes']);
}
}
相同的代码可用于主题,在其 template.php 文件中。