0

如何向 Twitter 引导导航栏链接显示 OpenCart 父类别?

我只想显示父类别,这是我的 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>

和我正在研究的当前标记和 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 } ?>
4

1 回答 1

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 } ?>
于 2013-05-21T14:58:25.780 回答