Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Dec 20, 2011 @ 16:07
    trfletch
    0

    Re-writing URL based on node property

    Hi,

    I have an Umbraco 4.5.1 website with the following structure:

    Home (doc type = homepage)
    News (doc type = category)
    - Politics (doc type = sub-category)
    - Business (doc type = sub-category)
    Sport (doc type = category)
    - Football (doc type = sub-category)
    - Rugby (doc type = sub-category)
    - Cricket (doc type = sub-category)
    About Us (doc type = textpage)
    Contact Us (doc type = textpage)
    Articles (doc type= articlesFolder)
    - 2011 (doc type = yearFolder)
    - Week 52 (doc type = weekFolder)
    - Article 1 (doc type = article)
    - Week 51 (doc type = weekFolder)

    The article nodes have a property called "category" which is using uComponents Multi Node Picker datatype to select a "category" node. Lets say for example "Article 1" has sub-category "Politics" selected as it's "category" using the multi node picker. I therefore want the URL for "Article 1" to be http://www.mysite.co.uk/News/Politics/Article-1.aspx

    How can I go about setting this up? I originally thought that I could use a before publish event handler to change "umbracoUrlName" but then I realised this is only the last part of the url so in my example I would still get: http://www.mysite.co.uk/Articles/2011/Week-52/xxxxxxxxxxxxxxxxxxx

     

  • awm 187 posts 376 karma points
    Dec 20, 2011 @ 16:18
    awm
    1

    I think your idea will work, but instead of changing the 'umbracoUrlName' property, it's another one you want to change. Unfortunately I can't remember the name of it but maybe someone else can fill in? I think it might be 'umbracoUrlAlias'?

  • trfletch 598 posts 604 karma points
    Dec 20, 2011 @ 17:50
    trfletch
    0

    Hi Alimac,

    Excellent thanks for that, I have now written a document publish event handler that sets up a umbracoUrlAlias property. I just need to change my XSLT's now to use the new URL rather than the default one but it looks like the following article gives some good advice on how to do this:

    http://our.umbraco.org/forum/developers/xslt/6720-NiceUrl-and-umbracoUrlAlias

  • awm 187 posts 376 karma points
    Dec 20, 2011 @ 17:55
    awm
    0

    Ah, glad it worked!

Please Sign in or register to post replies

Write your reply to:

Draft