Copied to clipboard

Flag this post as spam?

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


  • sun 403 posts 395 karma points
    Mar 16, 2009 @ 11:19
    sun
    0

    How can I auto redirect to a child node if a parent only have one child

    In xslt, I want to list a node's children, but when the node only has one child, I want to auto redirect to that child node.

    Who can help me?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 16, 2009 @ 11:34
    Ismail Mayat
    0

    sun,

    There are 2 ways you could do this:

    1. In the xslt write out :

    [code]

    <script type="text/javascript"><br />
       document.location.href="write xsl code here to url of page you want to redirect to";<br />
    </script>

    [/code]

    the disadvantage of this is that its client side javascript so if someone has it turned of it wont redirect. The other way would be to write xslt extension and redirect that way see here for more information. Its a bit more work but its all server side. Another alternative would be to move your stuff out of xslt and put in template and use inline c# eg

    [code]

    <script runat="server"><br />
    umbraco.presentation.nodeFactory.Node node = umbraco.presentation.nodeFactory.Node.GetCurrent();<br />
    </script>



    [/code]

    Regards

    Ismail

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 16, 2009 @ 11:39
    Dirk De Grave
    0

    Or, use other options as described in this post http://forum.umbraco.org/yafpostst8431Grouping-pages-into-a-subnav-but-without-an-intro-page-going-automatically-to-the-first-page.aspx

    Depends on your needs and how you'd like to solve this.

    Regards,
    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft