Запоминать открытый пункт меню (шаблон выпадающее меню)
Сделал меню каталога товаров на базе шаблона выпадающее меню.
Как можно сделать так, чтобы при переходе в какой-то раздел второго уровня родительский раздел был развернут и сразу отображались элементы 2-го уровня, в т.ч. выбранный раздел.
Временно сделал через cookie, что не совсем красиво и удобно.
Как можно сделать так, чтобы при переходе в какой-то раздел второго уровня родительский раздел был развернут и сразу отображались элементы 2-го уровня, в т.ч. выбранный раздел.
Временно сделал через cookie, что не совсем красиво и удобно.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<!-- МенюУслуг-->
<xsl:template match="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<xsl:template match="/shop">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function show_hide_menu(id) {
if (obj = document.getElementById(id)) {
if(obj.style.display == 'none') {
obj.style.display = 'block';
SetCookie("openmenu", id, "", "/");
}
else {
obj.style.display = 'none';
DeleteCookie("openmenu", "/", "");
}
return false;
}
return true;
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<xsl:apply-templates select="group" mode="first"/>
</xsl:template>
<xsl:template match="group" mode="first">
<h2>
<a href="{/shop/path}{fullpath}" onclick="return show_hide_menu('{@id}');">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</h2>
<!-- Если есть подгруппы -->
<xsl:if test="group">
<div id="{@id}" style="display:none;">
<span class="menu_del"></span>
<div class="block">
<xsl:apply-templates select="group" mode="second"/>
</div>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="group" mode="second">
<a href="{/shop/path}{fullpath}"><xsl:value-of disable-output-escaping="yes" select="name"/></a><br />
</xsl:template>
</xsl:stylesheet>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<!-- МенюУслуг-->
<xsl:template match="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
<xsl:template match="/shop">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function show_hide_menu(id) {
if (obj = document.getElementById(id)) {
if(obj.style.display == 'none') {
obj.style.display = 'block';
SetCookie("openmenu", id, "", "/");
}
else {
obj.style.display = 'none';
DeleteCookie("openmenu", "/", "");
}
return false;
}
return true;
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<xsl:apply-templates select="group" mode="first"/>
</xsl:template>
<xsl:template match="group" mode="first">
<h2>
<a href="{/shop/path}{fullpath}" onclick="return show_hide_menu('{@id}');">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</h2>
<!-- Если есть подгруппы -->
<xsl:if test="group">
<div id="{@id}" style="display:none;">
<span class="menu_del"></span>
<div class="block">
<xsl:apply-templates select="group" mode="second"/>
</div>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="group" mode="second">
<a href="{/shop/path}{fullpath}"><xsl:value-of disable-output-escaping="yes" select="name"/></a><br />
</xsl:template>
</xsl:stylesheet>
Авторизация