Copied to clipboard

Flag this post as spam?

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


  • AN 22 posts 42 karma points
    Jun 09, 2010 @ 16:51
    AN
    0

    Using umbracoRedirect to redirect to node with umbracoUrlAlias

    Is it possible to have 1 node with an umbracoRedirect content picker, redirect to another nodes umbracoUrlAlias?

    I've got quite the insane structure going, and it would be a much neater solution if I could.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 09, 2010 @ 16:55
    Ismail Mayat
    0

    An,

    Guess you could do it with .net macro, so for the page check if umbracoRedirect property has been set get the target document get its umbracoUrlAlias property and redirect to that.  Actually thinking about it that wont work as the redirect will probably already have happened so you may need to create a faux umbracoRedirect property and set that ensuring actual umbracoRedirect property has not been set.

    Regards

    Ismail

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jun 09, 2010 @ 17:26
    Douglas Robar
    1

    I haven't tried it but I think it should work.

    As I understand the order of events, the umbracoRedirect simply takes the built-in ID of the page to go to, which doesn't care about the url of the target page. That means you can move, rename, or change over-ride the url of the page and the redirect will still work. Then, once the target of the umbracoRedirect page loads it determines its own url, which will be determined by the umbracoUrlAlias that over-rides the built-in url for the page that umbraco would normally use.

    If you give it a try let us know how it works out in practice.

    cheers,
    doug.

  • AN 22 posts 42 karma points
    Jun 09, 2010 @ 17:34
    AN
    0

    Hi Doug, I don't understand :(

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jun 09, 2010 @ 17:35
    Douglas Robar
    0

    Let me go give it a try and I'll get back to you with a conclusive answer.

    cheers,
    doug.

  • AN 22 posts 42 karma points
    Jun 09, 2010 @ 17:37
    AN
    0

    Ismail, I've thought about the same thing. Doing a simple macro, that takes the ID from a content picker, and redirect to that urlalias.

  • AN 22 posts 42 karma points
    Jun 09, 2010 @ 17:39
    AN
    0

    Thank you Doug!

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jun 09, 2010 @ 17:42
    Douglas Robar
    0

    Just tried it and it works perfectly.

    Here's what I did...

    1. Added a two properties to my document type:
         - - Name: Redirect to this page
         - - Alias: umbracoRedirect
         - - Datatype: Content Picker

         - - Name: Override URL
         - - Alias: umbracoUrlName
         - - Datatype: Textstring

    2. Set the umbracoRedirect to point to a page on my site (save and publish the page)

    3. Set the umbracoUrlName field to "something.aspx" on the page that the umbracoRedirect points (save and publish the page)

    4. When I visited the page with the umbracoRedirect I was sent to the page I expected to be sent to, and that page's url was "something.aspx".

     

    It worked just as it should.

    cheers,
    doug.

  • AN 22 posts 42 karma points
    Jun 10, 2010 @ 08:59
    AN
    0

    Hi Doug,

    What you described works as it should, so thank you for doing the test and telling about it!

    However, umbracoUrlName just changes the name of the file, It does not allow me to change the path of the file.

    What I'm trying to archive is the following.

    frontpage.aspx
    folder1
    - folder1a
    - - news.aspx
    folder2
    - redirect2news.aspx


    I would like for it, so that folder1/folder1a/news.aspx was in the root node, that I can archive with umbUrlAlias. However, when visiting folder2/redirect2news.aspx I would like for it to use the umbUrlAlias of news.aspx, instead of the actual path.



  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jun 10, 2010 @ 11:47
    Douglas Robar
    0

    Thanks for the extra details. That will be a problem since the umbracoUrlAlias does not change the url of the page but simply adds more urls that the page will respond to.

    If you were to add the umbracoUrlAlias property to your /folder1/foldera/news.aspx page and give it the alias of 'news' you would be able to access the news page at its default url (http://localhost/folder1/folder1a/news.aspx) and also at its alias url (http://localhost/news.aspx).

    The real url for the page hasn't been changed by umbracoUrlAlias so when you redirect a different page to the news page it will show the default url with all the folders rather than the shortened, alternative url alias.

    This makes sense because you can have multiple aliases to a page and umbraco would never be able to know what url to use if not its default url.

     

    In your situation I would create a "pointer" document Type that has only an umbracoInternalRedirectId property and put it in your content tree. For instance, you'd have a 'news' page in the root of your site that was a "pointer" to the real news page. But because it uses the umbracoInternalRedirectId alias rather than umbracoRedirect the url won't change when the page is visited. Your redirect from the /folder2/redirect2news.aspx page would use an umbracoRedirect to the news pointer page at /news.aspx.

    Or, you could be clever with URLrewriting or a custom not-found-handler in umbraco.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft