Absolutely crappy thread post. I apologise for that, let me explain. My nodes look like so:
Publications - 2010 -- January -- February - 2009 -- January -- February -- March -- And so on...
What I'd like is when someone browses to Publications, it will redirect them to the LAST child node of the FIRST child node of publications. In this case, 2010/February. When March is added, it will then go to March. When 2011/January is added, it will then be selected.
Basically I just want them to be redirected to the latest publications.
I've now idea on how to accomplish this in umbraco.
You could put a usercontrol on your Publications templates, that has the logic for getting the correct month, and does the redirect.
To find the nodes use umbraco.presentation.nodeFactory.Node.GetCurrent().Children which will get you a collection of nodes. In this case they would be 2010/2009 and so on.
Morten's solution will certainly work, however If you feel more comfortable using XSLT i'm pretty sure this could be done by putting a macro in your 'publications' template, then in your XSLT you would need to grab the 'First' year node, and the 'last' Month node, using XSLT Position().
Automatically changing URL Redirect based on child nodes
Absolutely crappy thread post. I apologise for that, let me explain. My nodes look like so:
Publications
- 2010
-- January
-- February
- 2009
-- January
-- February
-- March
-- And so on...
What I'd like is when someone browses to Publications, it will redirect them to the LAST child node of the FIRST child node of publications. In this case, 2010/February. When March is added, it will then go to March. When 2011/January is added, it will then be selected.
Basically I just want them to be redirected to the latest publications.
I've now idea on how to accomplish this in umbraco.
You could put a usercontrol on your Publications templates, that has the logic for getting the correct month, and does the redirect.
To find the nodes use umbraco.presentation.nodeFactory.Node.GetCurrent().Children which will get you a collection of nodes. In this case they would be 2010/2009 and so on.
Morten's solution will certainly work, however If you feel more comfortable using XSLT i'm pretty sure this could be done by putting a macro in your 'publications' template, then in your XSLT you would need to grab the 'First' year node, and the 'last' Month node, using XSLT Position().
The XSLT solution above would rely on your user putting the years / dates in correct order.
Though thinking about it I'm sure you could do some fancy date algorithm to grab the actual latest year and latest month regardless of node position.
(Where's the darn edit feature!)
With both of the XSLT solutions you would redirect to the correct node in the XSLT.
Here's an old post which does it using javascript thought you can do a server redirect in XSLT too.
"thought you can do a server redirect in XSLT too."
How? I'm looking through the umbraco.library xslt extensions and can't see any redirect methods?
I find working in XSLT to be much less friction then working with user controls (as alien as XSLT and XPATH is to me).
Gave up with XSLT, just ended up doing this:
is working on a reply...