Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter
Powered by Vanilla. Made with Bootstrap.
Theme built by Kasper Kronborg Isager
Submenus dublicate at the beginning and end
  • Hi,
    I'm just starting to work with Feindura for the first time! ;) So sorry for any stupid questions!

    Im doing a menu like in the example site and use the following code:


    <?php foreach($feindura->createMenu('category',0,'ul') as $item) {
    echo $item['startTag'];
    echo $item['link'];
    foreach($feindura->createSubMenuOfPage($item['pageId'],'ul') as $subItem) {
    echo $subItem['menuItem'];
    }

    echo $item['endTag'];
    }


    ?>


    Unfortunately it prints the one subcategory that I have one time at the beginning one time in the end and of course also at the right position:


    <ul>
    <!-- wrong -- >
    <ul>
    <li><a title="Diagnostik" href="/cms/seite/leistungen/diagnostik/">Diagnostik</a></li>
    <li><a title="Therapien" href="/cms/seite/leistungen/therapien/">Therapien</a></li>
    </ul>

    <li><a title="Praxisprofil" href="/cms/seite/praxisprofil/">Praxisprofil</a></li>
    <li class="active"><a class="active" title="Leistungen" href="/cms/seite/leistungen/">Leistungen</a>
    <!-- correct-- >
    <ul>
    <li><a title="Diagnostik" href="/cms/seite/leistungen/diagnostik/">Diagnostik</a></li>
    <li><a title="Therapien" href="/cms/seite/leistungen/therapien/">Therapien</a></li>
    </ul>

    </li>
    <li><a title="Team" href="/cms/seite/team/">Team</a></li>
    <li><a title="Kooperationen" href="/cms/seite/kooperationen/">Kooperationen</a></li>
    <li><a title="Impressum" href="/cms/seite/impressum/">Impressum</a></li>

    <!-- wrong -- >
    <ul>
    <li><a title="Diagnostik" href="/cms/seite/leistungen/diagnostik/">Diagnostik</a></li>
    <li><a title="Therapien" href="/cms/seite/leistungen/therapien/">Therapien</a></li>
    </ul>

    </ul>


    Does anybody have an idea why this is happening?

    Thanks in advance for any help and effort ;)

    Sascha
  • hi sascha, thats quite right, that ist wrong ;-)

    because your have to check if you are in a in the loop for createing a link. In the first loop it only creates the <ul>.

    so what you have to do is:
    <?php          
    foreach($feindura->createMenu('category',0,'ul') as $item) {
    echo $item['startTag'];
    echo $item['link'];
     
    if($item['link']) {
    foreach($feindura->createSubMenuOfPage($item['pageId'],'ul') as $subItem) {
    echo $subItem['menuItem'];
    }
    }
     
    echo $item['endTag'];
    }
  • Thanks! That did the trick! And so obvious! ;)