如何向Twitter Bootstrap DropDown主导航菜单显示OpenCart父类别?

时间:2013-05-20 16:49:39

标签: twitter-bootstrap opencart

如何将OpenCart父类别显示到Twitter Bootstraped Navbar链接?

我只想显示父类别,这是我的HTML标记

<ul class="nav" role="navigation">
    <li class="dropdown" id="fat-menu">
        <a data-toggle="dropdown" class="dropdown-toggle" role="button" id="drop3" href="#">Store<b class="caret"></b></a>
        <ul aria-labelledby="drop3" role="menu" class="dropdown-menu">
        <li role="presentation"><a href="#" tabindex="-1" role="menuitem">Shop Front</a></li>
        <li class="divider" role="presentation"></li>
        <li role="presentation"><a href="#" tabindex="-1" role="menuitem">Parent Category 1</a></li><!-- Show Parent Category Here -->
        <li role="presentation"><a href="#" tabindex="-1" role="menuitem">Parent Category 2</a></li>
        </ul>
    </li>
</ul>

AND我正在研究的当前标记和PHP代码......我试图复制LI但它给出了一个解析错误。

<?php if ($categories) { ?>
<div id="menu-holder" class="<?php echo (isset($styler['menu_style']) && ($styler['menu_style']!='')) ? $styler['menu_style']."_menu" : '' ;?>">
<div id="menu">
<ul>
    <li><a href="<?php echo $home; ?>"><span class='home_icon'></span></a>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?><?php if ($category['children']) { ?><span></span><?php } ?></a>
        <?php if ($category['children']) { ?>
        <div>
            <?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<?php echo ($i==(count($category['children'])-1) ? " class='last_submenu_item'" : '');?> href="<?php echo $category['children'][$i]['href']; ?>"><span><?php echo $category['children'][$i]['name']; ?></span></a></li>
                <?php } ?>
                <?php } ?>
            </ul>
            <?php } ?>
        </div>
        <?php } ?>
    </li>
    <?php } ?>
</ul>
</div>
</div>
<?php } ?>

1 个答案:

答案 0 :(得分:0)

我得到了它的工作。无论如何我都是这样做的。

我把php代码块放在像这样的li ......

    <?php if ($categories) { ?>
    <?php foreach ($categories as $category) { ?>
    <li role="presentation"><a tabindex="-1" role="menuitem" href="<?php echo $category['href']; ?>" ><?php echo $category['name']; ?></a></li><?php } ?><?php } ?>