Jump to content

Help with code for detecting if a category or page doesn't have products from another page.


Recommended Posts

I have a custom menu that's shown on all product pages like new-products, price-drops and category. What I want is some code for an if statement to remove links to product pages that have no products.

This is the code I have now:
prod-menu.tpl (The custom menu file)


{if $product}

<!-- AddThis Button BEGIN -->

 {l s="Skriv ut"}
{l s="Publicera på Facebook"}
{l s="Skicka som e-post"}
{l s="Fler Tjänster"}

[removed][removed]
<!-- AddThis Button END -->

{/if}

{l s="Se våra"}

{l s="Specialpris"}
{l s="Nyheter"}


{$HOOK_LEFT_COLUMN}



modules/blockcategories/blockcategories.tpl

{$arr = array()}
{foreach from=$blockCategTree.children item=child}
{if $child.children}
{foreach from=$child.children item=child2}
{if $child2.children}
{foreach from=$child2.children item=child3}
{if $child3.children}
{foreach from=$child3.children item=child4}
{if $child4.children}
{foreach from=$child4.children item=child5}
{if $child5.children}
{foreach from=$child5.children item=child6}
{if $child6.children}
{foreach from=$child6.children item=child7}
{if $child7.children}
{foreach from=$child7.children item=child8}
{if $child8.children}
{foreach from=$child8.children item=child9}
{if $child9.children}
{foreach from=$child9.children item=child10}
{$arr[$child10.id] = $child10.name}
{/foreach}
{/if}
{$arr[$child9.id] = $child9.name}
{/foreach}
{/if}
{$arr[$child8.id] = $child8.name}
{/foreach}
{/if}
{$arr[$child7.id] = $child7.name}
{/foreach}
{/if}
{$arr[$child6.id] = $child6.name}
{/foreach}
{/if}
{$arr[$child5.id] = $child5.name}
{/foreach}
{/if}
{$arr[$child4.id] = $child4.name}
{/foreach}
{/if}
{$arr[$child3.id] = $child3.name}
{/foreach}
{/if}
{$arr[$child2.id] = $child2.name}
{/foreach}
{/if}
{$arr[$child.id] = $child.name}
{/foreach}
{$list = array()}
{foreach from=$arr key=key item=value}
{if $key != 6}
{$list[$key] = $value}
{/if}
{/foreach}
{if empty($HOOK_LEFT_COLUMN)}

{l s="Sortiment" mod="blockcategories"}

{if $list|@natcasesort}
{foreach from=$list key=id item=name}
{$name|escape:'htmlall':'UTF-8'}
{/foreach}
{/if}


{elseif empty($HOOK_RIGHT_COLUMN)}

{l s="Sortiment" mod="blockcategories"}
{$var = count($list)}
{$col3 = ( ( $var - ( $var % 3 ) ) / 3 )}
{$rest = $var % 3}
{if $rest > 0}
{$col1 = $col3 + 1}
{$col2 = $col3}
{if $rest == 2}
{$col2 = $col1}
{/if}
{else}
{$col1 = $col3}
{$col2 = $col3}
{/if}
{if $list|@natcasesort}
{$i = 0}
{foreach from=$list key=id item=name}
{if $i == 0}

{$name|escape:'htmlall':'UTF-8'}
{elseif $i == $col1 - 1}
{$name|escape:'htmlall':'UTF-8'}

{elseif $i == $col1}

{$name|escape:'htmlall':'UTF-8'}
{elseif $i == $col1 + $col2 - 1}
{$name|escape:'htmlall':'UTF-8'}

{elseif $i == $col1 + $col2}

{$name|escape:'htmlall':'UTF-8'}
{elseif $i == $col1 + $col2 + $col3 - 1}
{$name|escape:'htmlall':'UTF-8'}

{else}
{$name|escape:'htmlall':'UTF-8'}
{/if}
{$i = $i + 1}
{/foreach}
{/if}

{/if}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...