I'm trying to write a little Macro that I will use in my Homepage (using Runway) that should redirect to the first child if possible. I thought this would be a neat work around for me, since I didn't like Home is used as a root element.
Anywho, since I suck at xslt I didn't come that far. What I currently have is this:
[code]
.. Stripped header
[/code]
This idea is that it should take the first child from the root (which is at level 2, right?) and redirect to it. This, however is not even accepted by the editor.
Would someone be so kind to explain what I am doing wrong?
umbraco uses some nifty 'hidden' gems to redirect to other pages...
Have a look at this thread http://forum.umbraco.org/yafpostst8431Grouping-pages-into-a-subnav-but-without-an-intro-page-going-automatically-to-the-first-page.aspx to see some alternatives, though your solution may also work of course.
Two questions though:
- If I still wanted to do it the way I did it above, how would I fix the xslt code? I've just started learning it and since it's unlike anything I know it's quite a pain in the ass to get used to it.
- How could I ever know that using 'umbracoRedirect' as an alias will cause a redirect? What other of such super awesome alias'es are there?
In my personal opinion I would have tackled this differently, but the way you have done it is perfectly OK.
Just for your info this is how I would have tacked it. I would create an XSLT extension, that allows you to call some C# code.
For example something like this.
[code]
[/code]
Here is a great tutorial on how to help you understand XSLT extensions
[url]http://www.nibble.be/?p=60[/url]
I would recommend you build a common library of XSLT functions that you see that you would use again and again so you can take it with you with each Umbraco project you work on.
Redirect
I'm trying to write a little Macro that I will use in my Homepage (using Runway) that should redirect to the first child if possible. I thought this would be a neat work around for me, since I didn't like Home is used as a root element.
Anywho, since I suck at xslt I didn't come that far. What I currently have is this:
[code]
.. Stripped header
[/code]
This idea is that it should take the first child from the root (which is at level 2, right?) and redirect to it. This, however is not even accepted by the editor.
Would someone be so kind to explain what I am doing wrong?
Thanks!
Hi,
umbraco uses some nifty 'hidden' gems to redirect to other pages...
Have a look at this thread http://forum.umbraco.org/yafpostst8431Grouping-pages-into-a-subnav-but-without-an-intro-page-going-automatically-to-the-first-page.aspx to see some alternatives, though your solution may also work of course.
Regards,
/Dirk
Awesome! Got it working, thanks.
Two questions though:
- If I still wanted to do it the way I did it above, how would I fix the xslt code? I've just started learning it and since it's unlike anything I know it's quite a pain in the ass to get used to it.
- How could I ever know that using 'umbracoRedirect' as an alias will cause a redirect? What other of such super awesome alias'es are there?
Your axis is pointing in the wrong direction:
umbraco.library:NiceUrl($currentPage/descendant-or-self::id [@level=2])
In my personal opinion I would have tackled this differently, but the way you have done it is perfectly OK.
Just for your info this is how I would have tacked it. I would create an XSLT extension, that allows you to call some C# code.
For example something like this.
[code]
[/code]
Here is a great tutorial on how to help you understand XSLT extensions
[url]http://www.nibble.be/?p=60[/url]
I would recommend you build a common library of XSLT functions that you see that you would use again and again so you can take it with you with each Umbraco project you work on.
Warren :)
is working on a reply...