Hello,
I am building a dynamic menu. What I am wanting to use is twitter boostrap, which is I am remembering correctly uses a ordered list for top menu items and then an ordered list inside that for sub menu items.
I currently have that syntax printing out as a simple list, but I am just wondering if there is a better way to do so?
This is what I currently have:
[php]
-
<?php
for($i=0 ; $i < count($menu); $i++)
{
echo '
- '.($menu[$i]['Category']['name']. ' '); echo '
- '.$subcategories[$j]['Subcategory']['name'] .' '; } } echo '
- ';
for($j=0; $j < count($subcategories); $j++)
{
if($subcategories[$j]['Subcategory']['category_id']== $menu[$i]['Category']['id'])
{
echo '
It simply goes through my menu array and print out the name of the top level item, and then it prints out the submenu item. This uses an ID for the top level and a category_id to know which item belong to which top level category.
The issue I am having with how this is implemented is that it will literate through the entire submenu on each pass. This means if I have a large menu it will have to literate through a lot of data that won’t be printed in that pass. So is there a better way of doing this while keeping it short, sweet and most of all dynamically created?
Thanks,
Valandor
A.K.A.
Anthony