求一段PHP程序,使得菜单:当前页是红色按钮,其它是蓝色按钮
我用的是smarty动态生成,该如何设定style?{section name="arr" loop=$menuArr}
<a href={$menuArr[arr].menuLink} class="topmenu">{$menuArr[arr].menuText}</a>{/section}参考
a.topmenu:link, a.topmenu:visited {
background-color: blue;
}
a.topmenu:active, a.topmenu:hover {
background-color: red;
}
我用的是smarty动态生成,该如何设定style?{section name="arr" loop=$menuArr}
<a href={$menuArr[arr].menuLink} class="topmenu">{$menuArr[arr].menuText}</a>{/section}参考
a.topmenu:link, a.topmenu:visited {
background-color: blue;
}
a.topmenu:active, a.topmenu:hover {
background-color: red;
}
-----------------------------------------------------------------
我知道css定义是不行的,所以才来问。在模板里如何判定是不是当前页?
定义一个红色按钮的css类, 和一个蓝色的css类,当if( 菜单页面名称 === 当前页面名称 ) //给a标签添加css类属性
正解.在模版里调用{section name="arr" loop=$menuArr}
{if..}
<a href={$menuArr[arr].menuLink} class="topmenu">{$menuArr[arr].menuText} </a>
{/if}
{/section}
{if $menuArr[arr].menuLink == $currentPage}
<td class="topmenu_on" nowrap> <span class="topmenu_on">{$menuArr[arr].menuText}</span></td>
{else}
<td class="topmenu_off" nowrap><a href={$menuArr[arr].menuLink} class="topmenu_off">{$menuArr[arr].menuText}</a></td>
{/if}
{/section}