as you see, the linkbutton is used to switch "Mode" in which website is currently displayed. [and page load sets session variable if session variable is null.]
2) xslt macro = it is a menu navigation macro for level=1. every content page at level 1 has these properties - (a) isMode1Page (isConsumerPage), (b) isMode2Page (isBusinessPage). xslt should generate menu according to current active mode (reading from session variable.)
<!-- Input the documenttype you want here --> <xsl:variable name="level" select="1"/> <xsl:variable name="sessionmode" select="umbraco.library:Session('MODE')"/>
when I load page for first time, nothing is displayed. I have to refresh to see changed effect.
when I click on "switch" linkbutton, session variable is changed, however, to see updated menu, I have to refresh that page again. after refreshing, menu appears correct.
what I would want is, ideally, menu should be updated the very moment I click on "switch" link button.
the xslt macro should execute exactly after usercontrol macro finishes its execution.
either I am doing a very small mistake or very big mistake :P
The problem might be that your xslt macro is executed before your usercontrol. You have no control of this in Umbraco. A way to work around this is to use the querystring /pagename.aspx?mode=1 and do the following:
Let the xslt check the querystring "mode" and for session mode. If you're usercontrol does nothing else then the xslt file could also set the session variable.
Session variables and xslt
Hi there
I am new with umbraco. I have following doubt.
I got two macros in my masterpage template. 1) usercontrol , 2) xslt
1) usercontrol macro - this is one linkbutton. code is following
public partial class GlobalMenu : System.Web.UI.UserControl
{
//sessionmode : zero : consumer mode : default
//sessionmode : one : business mode
private const string sessionvar_mode = "MODE";
protected void Page_Load(object sender, EventArgs e)
{
if(string.IsNullOrEmpty(library.Session(sessionvar_mode)))
library.setSession(sessionvar_mode,"0");
}
protected void lnkBtnSwitchMode_Click(object sender, EventArgs e)
{
if (library.Session(sessionvar_mode) == "0")
library.setSession(sessionvar_mode, "1");
else
library.setSession(sessionvar_mode, "0");
}
}
as you see, the linkbutton is used to switch "Mode" in which website is currently displayed. [and page load sets session variable if session variable is null.]
2) xslt macro = it is a menu navigation macro for level=1. every content page at level 1 has these properties - (a) isMode1Page (isConsumerPage), (b) isMode2Page (isBusinessPage). xslt should generate menu according to current active mode (reading from session variable.)
<!-- Input the documenttype you want here -->
<xsl:variable name="level" select="1"/>
<xsl:variable name="sessionmode" select="umbraco.library:Session('MODE')"/>
<xsl:choose>
<xsl:when test="$sessionmode = '0'">
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='isMainMenu']) = '1'] ">
<xsl:if test="string(data [@alias='isConsumerPage']) = '1'" >
<!--li-->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--/li-->
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:when test="$sessionmode = '1'">
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='isMainMenu']) = '1'] ">
<xsl:if test="string(data [@alias='isBusinessPage']) = '1'" >
<!--li-->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--/li-->
</xsl:if>
</xsl:for-each>
</xsl:when>
</xsl:choose>
However it is not happening 100% correct.
when I load page for first time, nothing is displayed. I have to refresh to see changed effect.
when I click on "switch" linkbutton, session variable is changed, however, to see updated menu, I have to refresh that page again. after refreshing, menu appears correct.
what I would want is, ideally, menu should be updated the very moment I click on "switch" link button.
the xslt macro should execute exactly after usercontrol macro finishes its execution.
either I am doing a very small mistake or very big mistake :P
Please help me...
Best,
Sandeep Khandewale
forgot this info : I am working on
Umbraco 4 latest build
.net 3.5
cassini web server.
windows xp
Hi Sandeep,
The problem might be that your xslt macro is executed before your usercontrol. You have no control of this in Umbraco. A way to work around this is to use the querystring /pagename.aspx?mode=1 and do the following:
Let the xslt check the querystring "mode" and for session mode.
If you're usercontrol does nothing else then the xslt file could also set the session variable.
/Jesper Ordrup
is working on a reply...