我正在尝试更改显示在 drupal 网站首页上的文章的标记,以便将它们集成到幻灯片中。(我不能使用幻灯片模块)。我有一个 page--front.tpl.php 文件,但我需要添加比这里更具体的标记。
您如何仅更改首页特定区域的标记?
我相信我需要编写一个预处理钩子,但我不确定如何仅针对首页上的文章节点。这是我想要生成的标记:
<div class="slidewrap" data-autorotate="5000">
<ul class="slidecontrols">
<li><a href="#sliderName" class="next">Next</a></li>
<li><a href="#sliderName" class="prev">Prev</a></li>
</ul>
<ul class="slider" id="sliderName">
<li class="slide">
<h2 class="slidehed">First Slide</h2>
<img src="1.jpg" />
<p>In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien. Phasellus quis est sed turpis sollicitudin venenatis sed eu odio. Praesent eget neque eu eros interdum malesuada non vel leo. Sed fringilla porta ligula egestas tincidunt. Nullam risus magna, ornare vitae varius eget, scelerisque a libero.</p>
</li>
<li class="slide">
<h2 class="slidehed"><a href="#">Second Slide</a></h2>
<img src="2.jpg" />
<p>In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien.</p>
</li>
<li class="slide">
<h2 class="slidehed">Third Slide</h2>
<img src="3.jpg" />
<p>Phasellus quis est sed turpis sollicitudin venenatis sed eu odio. Praesent eget neque eu eros interdum malesuada non vel leo. Sed fringilla porta ligula egestas tincidunt. Nullam risus magna, ornare vitae varius eget.</p>
</li>
<li class="slide">
<h2 class="slidehed"><a href="#">Fourth Slide</a></h2>
<p>In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien. Phasellus quis est sed turpis sollicitudin venenatis sed eu odio.</p>
</li>
<li class="slide">
<h2 class="slidehed">Fif' Slide</h2>
<p>In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien.</p>
</li>
</ul>
</div>
我一直在尝试使用视图模块来做到这一点。但是,当我创建一个新模板时,我收到此错误消息:警告:在 include() 中为 foreach() 提供的参数无效(/d7install/path_to_theme/views-view--featured--block.tpl.php 的第 12 行) .
这是我通过主题信息复制的模板文件:
<?php if (!empty($title)): ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
<div class="<?php print $classes_array[$id]; ?>">
<?php print $row; ?>
</div>
<?php endforeach; ?>