|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jovenshadow11 Smarty Rookie
Joined: 28 Jun 2011 Posts: 14
|
Posted: Mon Sep 05, 2011 1:00 pm Post subject: menu template |
|
|
on my template im checking the submenu array if its empty or not so that if its empty then the <ul> for submenu will not show but i think my if {if $menu.subMenus != ""} statement is not working.
everything is working perfect to me but i want to have a clean html output. please help me how can i check if the submenu array is empty or not before printing the submenu list |
|
Back to top |
|
jovenshadow11 Smarty Rookie
Joined: 28 Jun 2011 Posts: 14
|
Posted: Mon Sep 05, 2011 1:05 pm Post subject: |
|
|
i am making template for my menu below is my menu array
Array
(
[Home] => Array
(
[name] => Home
[link] => home
[subMenus] => Array
(
)
)
[About Eleven] => Array
(
[name] => About Eleven
[link] => about_eleven
[subMenus] => Array
(
[test sub] => Array
(
[name] => test sub
[link] => test_sub
)
)
)
[Services] => Array
(
[name] => Services
[link] => services
[subMenus] => Array
(
)
)
[Contact] => Array
(
[name] => Contact
[link] => contact
[subMenus] => Array
(
)
)
[test] => Array
(
[name] => test
[link] => test
[subMenus] => Array
(
)
)
[testtest] => Array
(
[name] => testtest
[link] => testtest
[subMenus] => Array
(
)
)
)
what i want to do is show the primary menu and submenu, here is my template
<ul>
{foreach from=$menus item="menu"}
<li><a href="index.php?p={$menu.link}">{$menu.name} - {$menu.subMenu.link}</a>
{if $menu.subMenus != ""}
<ul>
{foreach from=$menu.subMenus item="subMenu"}
<li><a href="index.php?p={$subMenu.link}">{$subMenu.name}</a></li>
{/foreach}
</ul>
{/if}</li>
{/foreach}
<ul>
everything is working fine and the out put below
<ul>
<li><a href="index.php?p=home">Home - </a>
<ul>
</ul>
</li>
<li><a href="index.php?p=about_eleven">About Eleven - </a>
<ul>
<li><a href="index.php?p=test_sub">test sub - </a></li>
</ul>
</li>
<li><a href="index.php?p=services">Services - </a>
<ul>
</ul>
</li>
<li><a href="index.php?p=contact">Contact - </a>
<ul>
</ul>
</li>
<li><a href="index.php?p=test">test - </a>
<ul>
</ul>
</li>
<li><a href="index.php?p=testtest">testtest - </a>
<ul>
</ul>
</li>
<ul>
on my template im checking the submenu array if its empty or not so that if its empty then the <ul> for submenu will not show but i think my if {if $menu.subMenus != ""} statement is not working.
everything is working perfect to me but i want to have a clean html output. please help me how can i check if the submenu array is empty or not before printing the submenu list |
|
Back to top |
|
jovenshadow11 Smarty Rookie
Joined: 28 Jun 2011 Posts: 14
|
Posted: Mon Sep 05, 2011 1:36 pm Post subject: |
|
|
SOLVED!
{if $menu.subMenus == true} |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|