Skip to content

Instantly share code, notes, and snippets.

@yratof
Created June 13, 2013 10:27
Show Gist options
  • Save yratof/5772752 to your computer and use it in GitHub Desktop.
Save yratof/5772752 to your computer and use it in GitHub Desktop.
Opencart: List of categories
<?php if ($categories) { ?>
<div class="category-list">
<?php if (count($categories) <= 4) { ?>
<ul class="categoryRow twelvecol clearfix first">
<?php foreach ($categories as $category) { ?>
<li class="threecol clearfix first img">
<?php if ($category['thumb']) { ?>
<a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" alt="<?php echo $category['name']; ?>" /></a>
<?php } ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
<?php } ?>
</ul>
<?php } else { ?>
<?php for ($i = 0; $i < count($categories);) { ?>
<ul class="categoryRow twelvecol clearfix first">
<?php $j = $i + ceil(count($categories) * 0 + 4); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($categories[$i])) { ?>
<li class="threecol clearfix img">
<a href="<?php echo $categories[$i]['href']; ?>">
<?php if ($categories[$i]['thumb']) { ?>
<img src="<?php echo $categories[$i]['thumb']; ?>" alt="<?php echo $categories[$i]['name']; ?>" />
<?php } ?>
<?php echo $categories[$i]['name']; ?>
</a>
</li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment