I have a shortcut in the top navigation menu to "current issue", I use that to redirect the user to the correct page under another node (archive of issues). However it would be nice if the user could still be on the "current issue" url.
Changed to System.Web.HttpContext.Current.Server.Transfer("/default.aspx?id=" & nodeId)
but that killed the response, error 101.
I think I'll just skip this method, doing some other better or worse workaround... Perhaps a template that prints bodytext 'n stuff from another node than current.
I might have misunderstood your question, but it sounds like you could use the "umbracoInternalRedirectId" property alias on your "current issue" page?
Ah, yes, If I could use umbracointernalredirectid from xslt it would be the way to do it. The thing is that "current issue" is set from the main node as it is used for other stuff aswell. And we wish it to be set only at one place.
Perhap I should use event handling to copy that setting, dunno.
@Jonas, I can't help but think that a redirect isn't the right way to go about this. I'm keeping consideration that you said you'd like to keep the "current issue" URL the same ... so it sounds like you want to display the selected content (via the "TeaserCurrentIssue" property)?
If so, then how about using GetXmlNodeById from umbraco.library?
yeah, I think I will - creating the content from that $currentIssueNode and adding all necessary content + creating an alternative template for that page.
It will require that extra template though, and I really thought I could go a shortcut by server.transfer. How is umbracointernalredirectid doing its work internally? I'd perhaps look that up just for curiousity at least.
The way the "umbracoInternalRedirectId" property works is in the umbraco.requestHandler class. If it is set, then the (Umbraco) request uses the node of that Id, rather than the page/node that is being requested. So on the front-end, the context is still with the requested page.
Take a look at the source-code on CodePlex, or crack open the umbraco.dll in Reflector if you want to know the inner workings.
Hidden redirect (server transfer?) with Xslt
Hi!
I have a shortcut in the top navigation menu to "current issue", I use that to redirect the user to the correct page under another node (archive of issues). However it would be nice if the user could still be on the "current issue" url.
[home] [yada yada yada] [current issue] [archive of issues] [about us]
I thought I could do that with a server transfer (inline .net-code), but it just did the same as response redirect. Dunno how to do this.
The editor select the current issue from a global settings node, and that works fine. Here's the xslt
Thanks
Changed to System.Web.HttpContext.Current.Server.Transfer("/default.aspx?id=" & nodeId)
but that killed the response, error 101.
I think I'll just skip this method, doing some other better or worse workaround... Perhaps a template that prints bodytext 'n stuff from another node than current.
Hi Jonas,
I might have misunderstood your question, but it sounds like you could use the "umbracoInternalRedirectId" property alias on your "current issue" page?
http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracointernalredirectid
Let us know if I misunderstood... there's bound to be an easier solution for it! :-)
Cheers, Lee.
Hi Lee
Ah, yes, If I could use umbracointernalredirectid from xslt it would be the way to do it. The thing is that "current issue" is set from the main node as it is used for other stuff aswell. And we wish it to be set only at one place.
Perhap I should use event handling to copy that setting, dunno.
Cheers
Jonas
You could use some javascript to do the redirect from within xslt, as below (also has fallback if js is disabled):
<xsl:variable name="redirectNodeId">
<xsl:for-each select="$currentPage/descendant::node [@nodeTypeAlias = 'blah']">
<xsl:sort select="./data [@alias = 'articleDate']" order="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="./@id"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<script language="javascript">
document.location.href="<xsl:value-of select="umbraco.library:NiceUrl($redirectNodeId)"/>";
</script>
Please follow <a href="{umbraco.library:NiceUrl($redirectNodeId)}">this link</a>.
Cheers,
Neil
Thanks Neil, but I'd really like it to be moved by the server, and preferrably "under the hood" so the url is kept as it is.
@Jonas, I can't help but think that a redirect isn't the right way to go about this. I'm keeping consideration that you said you'd like to keep the "current issue" URL the same ... so it sounds like you want to display the selected content (via the "TeaserCurrentIssue" property)?
If so, then how about using GetXmlNodeById from umbraco.library?
http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid
Here's an example with XSLT:
I added a couple of <xsl:if> conditions, just in case! ;-)
Cheers, Lee.
Lee,
yeah, I think I will - creating the content from that $currentIssueNode and adding all necessary content + creating an alternative template for that page.
It will require that extra template though, and I really thought I could go a shortcut by server.transfer. How is umbracointernalredirectid doing its work internally? I'd perhaps look that up just for curiousity at least.
Hi Jonas,
The way the "umbracoInternalRedirectId" property works is in the umbraco.requestHandler class. If it is set, then the (Umbraco) request uses the node of that Id, rather than the page/node that is being requested. So on the front-end, the context is still with the requested page.
Take a look at the source-code on CodePlex, or crack open the umbraco.dll in Reflector if you want to know the inner workings.
Cheers, Lee.
I know this doesn't exactly fit your problem, but I found it searching for a similar problem
If "umbracoInternalRedirectId" is not for you (eg: you want to check a condition first)
And you want to do a "Server.Transfer" in code behind, you can do something like this:
is working on a reply...