Jump to content

how can i split categories into equal columns in this menu?


toolman

Recommended Posts

I currently have a drop down menu which displays categories, but i want them to display in equal columns horizontally.

 

How could I do that using PHP?

 

This is what I have:

 

<div id="menu" class="grid_12">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div class="sixth_color_border">
        <?php for ($i = 0; $i < count($category['children']) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo  $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <div class="categories_spacer"></div>
    <?php } ?>
  </ul>
</div>

 

Any ideas?

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.