Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • SaphuA 124 posts 87 karma points
    Apr 17, 2009 @ 20:13
    SaphuA
    0

    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!

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 17, 2009 @ 20:34
    Dirk De Grave
    0

    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

  • SaphuA 124 posts 87 karma points
    Apr 17, 2009 @ 20:44
    SaphuA
    0

    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?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Apr 18, 2009 @ 11:57
    Morten Bock
    0

    Your axis is pointing in the wrong direction:

    umbraco.library:NiceUrl($currentPage/descendant-or-self::id [@level=2])

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Apr 18, 2009 @ 20:18
    Warren Buckley
    0

    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 :)

Please Sign in or register to post replies

Write your reply to:

Draft