我目前正在努力将 foreach 循环分类为自己的 div 和 ul,这就是我目前拥有的:
<ul class="thumbnails parts-page">
<?php $show = false; ?>
<?php foreach ($this->items as $item) : ?>
<?php if($item->state == 1 || ($item->state == 0 && JFactory::getUser()->authorise('core.edit.own',' com_parts'))):
$show = true;
?>
<li class="span4">
<a href="<?php echo $item->brand_link; ?>" style="background:url(<?php echo $item->brand_image; ?>) no-repeat center center #FFF; " class="thumbnail parts" target="_blank">
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
基本上这会产生:
<ul class="thumbnails parts-page">
<li class="span4">
<a href="http://www.canecreek.com/" style="background: url('/torqzone/images/brands/cane-creek.png') no-repeat center center #FFF; " class="thumbnail parts" target="_blank">
</a>
</li>
<li class="span4">
<a href="http://www.amclassic.com/en/" style="background: url('/torqzone/images/brands/american-classic.png') no-repeat center center #FFF; " class="thumbnail parts" target="_blank">
</a>
</li>
<li class="span4">
<a href="http://www.avid.com/US/" style="background: url('/torqzone/images/brands/avid.png') no-repeat center center #FFF; " class="thumbnail parts" target="_blank">
</a>
</li>
</ul>
但我需要拆分它,以便每 9 个项目都是独立的:
<ul class="thumbnails parts-page">
9ITEMS
</ul>
我尝试了在网上找到的各种解决方案,但似乎没有任何效果..
非常感谢任何帮助。