如何将Contao变量拆分为几个HTML元素

时间:2018-08-27 14:29:10

标签: php contao

我从Contao CMS中获得了此模板:

<?php $helper = new \ContaoBootstrap\Navbar\Helper\NavigationHelper($this); ?>


<?php foreach ($this->items as $item) : ?>

    <?php
        $currentLevelStringParts = explode('_', $this->level);
        $currentLevelNumber = $currentLevelStringParts[1];
    ?>

    <?php $itemHelper = $helper->getItemHelper($item); ?>

    <li class="<?php echo str_replace(array('_'), array('-'), $itemHelper->getItemClass());
                if (!empty($item['subitems'])) {echo ' subnav';} ?>
    ">

        <<?= str_replace(array('strong'), array('a'), $itemHelper->getTag()); ?>
        <?= str_replace(array('dropdown-item', 'dropdown-toggle', 'nav-link', 'data-toggle="dropdown"'), array(' ', ' ', ' ', ' '), $itemHelper) ?>>

        <?php if ($item['isActive']) : ?>
            <?= $item['link']?>
        <?php else : ?>
            <span itemprop="name"><?= $item['link']?></span>
        <?php endif; ?>
        </<?= str_replace(array('strong'), array('a'), $itemHelper->getTag()); ?>>

        <?php if (!empty($item['subitems'])) { ?>
            <span class="subnav-pull-down hidden-lg-up <?php if ($item['isTrail']) : ?>active<?php endif; ?>"></span>

        <div class="subnav-container <?php if ($item['isTrail']) : ?>open<?php endif; ?>">
            <div class="relative">
                <ul class="nav sub-nav level-<?php echo (int)$currentLevelNumber+1 ?>">
                    <?= $item['subitems'] ?>
                    <div class="clear"></div>
                </ul>

            </div>
        </div>
    <?php } ?>
    </li>
<?php endforeach; ?> 

我的问题是,我需要一个类似HTML的结构:

<ul>
<li><a></a></li>
<li><a></a></li>
<li>
<ul>
<li><a></a></li>
</ul>
</ul>

更改导航的链接()和说明。我尝试使用bootstrap API,但对PHP和Bootstrap还是陌生的。

我希望你们能帮助我。

0 个答案:

没有答案
相关问题