Megamenü Anpassung Eben

leom

Aktives Mitglied
18. Februar 2016
2
0
Guten Tag Liebe JTL Com. Ich bin neu hier und sitze gerade an meinem ersten JTL 4.02 Testshop. Nun geht es um die Anpassung des Megamenüs. Das Ziel ist es dabei erst bei der zweiten Kategorie-Ebene zu beginnen!

Aufbau soll so sein: "Kategorie" (so als Wort) -> Obst - Gemüse - Kühlwaren und dann die nächste Ebene -> Äpfel süss - Äpfel sauer etc. In der Warenwirtschaft möchte ich aber "Kategorie" nicht als Kategorie anlegen. Dafür habe ich die categories_mega.tpl wie folgt verändert.

HTML:
{strip}
{assign var=max_subsub_items value=5}

{block name="megamenu-categories"}
{if isset($Einstellungen.template.megamenu.show_categories) && $Einstellungen.template.megamenu.show_categories !== 'N'}
    {assign var='show_subcategories' value=false}
    {if isset($Einstellungen.template.megamenu.show_subcategories) && $Einstellungen.template.megamenu.show_subcategories !== 'N'}
        {assign var='show_subcategories' value=true}
    {/if}

    {get_category_array categoryId=0 assign='categories'}
    {if !empty($categories)}
        {foreach name='categories' from=$categories item='category'}
            
            {assign var='isDropdown' value=false}
            {if isset($category->bUnterKategorien) && $category->bUnterKategorien}
                {assign var='isDropdown' value=true}
            {/if}
            <li class="{if $isDropdown}dropdown megamenu-fw{/if}{if isset($category->bAktiv) && $category->bAktiv} active{/if}">
                <a href="{$category->cURL}"{if $isDropdown} class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="300" data-hover-delay="100" data-close-others="true"{/if}>
                    Kategorie
                    {if $isDropdown}<span class="caret"></span>{/if}
                </a>
                {if $isDropdown}
                    <ul class="dropdown-menu keepopen">
                        <li>
                            <div class="megamenu-content">
                                <div class="category-title text-center">
                                    <a href="{$category->cURL}">{$category->cName}</a>
                                </div>
                                <hr class="hr-sm">
                                <div class="row">
                                    {if isset($Einstellungen.template.megamenu.show_maincategory_info) && $Einstellungen.template.megamenu.show_maincategory_info != 'N'}
                                        {if $category->cBildURL != 'gfx/keinBild.gif' || !empty($category->cBeschreibung)}
                                        <div class="col-lg-3 visible-lg">
                                            <div class="mega-info-lg top15">
                                                {if $category->cBildURL != 'gfx/keinBild.gif'}
                                                    <a href="{$category->cURL}"><img src="{$category->cBildURL}" class="img-responsive" alt="{$category->cMetaDescription|escape:'quotes'}"></a>
                                                    <div class="clearall top15"></div>
                                                {/if}
                                                <div class="description text-muted small">{$category->cBeschreibung}</div>
                                            </div>
                                        </div>
                                        {/if}
                                    {/if}
                                    <div class="col-xs-12{if !empty($category->cBild) || !empty($category->cBeschreibung)} col-lg-9{/if} mega-categories">
                                        <div class="row row-eq-height row-eq-img-height">
                                            {if $category->bUnterKategorien}
                                                {if !empty($category->Unterkategorien)}
                                                    {assign var=sub_categories value=$category->Unterkategorien}
                                                {else}
                                                    {get_category_array categoryId=$category->kKategorie assign='sub_categories'}
                                                {/if}
                                                {foreach name='sub_categories' from=$categories item='category'}
                                                    <div class="col-xs-6 col-sm-3 col-lg-3">
                                                        <div class="category-wrapper top15{if isset($sub->bAktiv) && $sub->bAktiv} active{/if}">
                                                            {if isset($Einstellungen.template.megamenu.show_category_images) && $Einstellungen.template.megamenu.show_category_images !== 'N'}
                                                                <div class="img text-center">
                                                                    <a href="{$category->cURL}"><img src="{$sub->cBildURL}" class=image alt="{$sub->cName|escape:'quotes'}"></a>
                                                                </div>
                                                            {/if}
                                                            <div class="caption{if isset($Einstellungen.template.megamenu.show_category_images) && $Einstellungen.template.megamenu.show_category_images !== 'N'} text-center{/if}">
                                                                <h5 class="title"><a href="{$category->cURL}"><span>{$category->cName}</span></a></h5>
                                                            </div>
                                                            {if $show_subcategories && $sub->bUnterKategorien}
                                                                {if !empty($sub->Unterkategorien)}
                                                                    {assign var=subsub_categories value=$sub->Unterkategorien}
                                                                {else}
                                                                    {get_category_array categoryId=$sub->kKategorie assign='subsub_categories'}
                                                                {/if}
                                                                <hr class="hr-sm">
                                                                <ul class="list-unstyled small subsub">
                                                                    {foreach name='subsub_categories' from=$subsub_categories item='subsub'}
                                                                        {if $smarty.foreach.subsub_categories.iteration <= $max_subsub_items}
                                                                            <li{if isset($subsub->bAktiv) && $subsub->bAktiv} class="active"{/if}>
                                                                                <a href="{$subsub->cURL}">
                                                                                    {$subsub->cName}
                                                                                </a>
                                                                            </li>
                                                                        {else}
                                                                            <li class="more"><a href="{$sub->cURL}"><i class="fa fa-chevron-circle-right"></i> {lang key="more" section="global"} <span class="remaining">({math equation='total - max' total=$subsub_categories|count max=$max_subsub_items})</span></a></li>
                                                                            {break}
                                                                        {/if}
                                                                    {/foreach}
                                                                </ul>
                                                            {/if}
                                                        </div>
                                                    </div>
                                                {/foreach}
                                            {/if}
                                        </div>{* /row *}
                                    </div>{* /mega-categories *}
                                </div>{* /row *}
                            </div>{* /megamenu-content *}
                        </li>
                    </ul>
                {/if}
            </li>
        {/foreach}
    {/if}
{/if}
{/block}{* /megamenu-categories*}

{block name="megamenu-pages"}
{if isset($Einstellungen.template.megamenu.show_pages) && $Einstellungen.template.megamenu.show_pages !== 'N'}
    {include file='snippets/linkgroup_list.tpl' linkgroupIdentifier='megamenu' dropdownSupport=true tplscope='megamenu'}
{/if}
{/block}{* megamenu-pages *}

{block name="megamenu-manufacturers"}
{if isset($Einstellungen.template.megamenu.show_manufacturers) && $Einstellungen.template.megamenu.show_manufacturers !== 'N'}
    {get_manufacturers assign='manufacturers'}
    {if !empty($manufacturers)}
        <li class="dropdown bs-hover-enabled">
            <a href="#" class="dropdown-toggle" id="dropdown-manufacturer-top" data-toggle="dropdown" aria-expanded="true">
                {lang key="manufacturers" section="global"}
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu" role="menu" aria-labelledby="dropdown-manufacturer-top">
                {foreach name=hersteller from=$manufacturers item=hst}
                    <li role="presentation">
                        <a role="menuitem" tabindex="-1" href="{$hst->cSeo}"">{$hst->cName|escape:"html"}</a>
                    </li>
                {/foreach}
            </ul>
        </li>
    {/if}
{/if}
{/block}{* megamenu-manufacturers *}


{block name="megamenu-global-characteristics"}
{*
{if isset($Einstellungen.template.megamenu.show_global_characteristics) && $Einstellungen.template.megamenu.show_global_characteristics !== 'N'}
    {get_global_characteristics assign='characteristics'}
    {if !empty($characteristics)}

    {/if}
{/if}
*}
{/block}{* megamenu-global-characteristics *}
{/strip}


Problem ist! Das die oberste {foreach name='categories' from=$categories item='category'} Schleife mir Probleme macht. Diese wird so häufig durchlaufen wie ich Kategorien habe. Könnt Ihr mir helfen???
 

leom

Aktives Mitglied
18. Februar 2016
2
0
AW: Megamenü Anpassung Eben

hat sich erledigt. Foreach raus und if anfragen umschreiben und gut