Copied to clipboard

Flag this post as spam?

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


  • Bob 38 posts 160 karma points
    Dec 14, 2016 @ 12:57
    Bob
    0

    Redirect sub page

    I have a parent directory which contains a sub directory or just a page.

    I would like to have the option to redirect these directory and or pages using a macro/xslt.

    I'm struggling to go through each node from parent to page in order to redirect. Does anyone have a sample I could follow/use so that if the directory/page had a value to redirect then it does it?

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Dec 14, 2016 @ 13:06
    Nik
    0

    Hi Bob,

    I was wondering if you could give a bit more of an explanation of your setup and what you are trying to achieve. I'm not exactly sure I understand.

    Nik

  • Bob 38 posts 160 karma points
    Dec 14, 2016 @ 13:28
    Bob
    0

    Yes sure.

    I have a site, first level is Managers, under managers is a second level called supervisor and below this is a page called users.

    What I would like to do is if a user types in

    Mysite.com/manager

    To redirect to a chosen page (external or internal)

    If they navigate to

    Mysite.com/manager/supervisor or / user then it should redirect to the page that had been set.

    In my document type I have created the option to allow users to redirect to a specific page but need some help in getting this to work using xlst.

    Does this make more sense?

    Thanks for your help

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Dec 14, 2016 @ 15:08
    Nik
    0

    Hi Bob,

    So there are various ways you could do this.

    Personally, I don't know enough about xlst. It's not something I've had to do before. However you can do your redirect in your cshtml template file.

    I've used code like this for something in a project recently that had a load of nodes that were effectively "redirect" nodes. You could extrapolate the concept and use it in your own templates:

     @{
       if (Model.Content.HasValue("redirectUrl"))
       {
           Response.RedirectPermanent(Model.Content.GetPropertyValue<string>("redirectUrl"));
       }
       else
       {
           Response.RedirectPermanent("~/");
       }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft