Copied to clipboard

Flag this post as spam?

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


  • Timsn 121 posts 231 karma points
    Jul 09, 2009 @ 16:34
    Timsn
    0

    Alter node url from name to id

    How can I alter the url of a page to the node id or a combination of id and name (like here in the forum).

    Should I use umbracoUrlAlias for that? I want it to be dynamic so if I change the node name, the url should change also.

  • Chris Dunn 75 posts 127 karma points
    Jul 09, 2009 @ 16:52
    Chris Dunn
    100

    Timsn,

    umbracoUrlAlias would work and be dynamic if you created an event handler on BeforePublish for the documenttype  to update the umbracoUrlAlias property to concat the nodeid + nodename. 

    Here some more info: http://umbraco.org/documentation/books/api-cheatsheet/attaching-document-eventhandlers

    -Chris

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 09, 2009 @ 16:54
    Dirk De Grave
    1

    Hi,

    using umbracoUrlAlias is fine, but in addition, you'll need an eventhandler, listing for create/update/publish event to make sure it's updated accordingly. Not that hard at all, and some pretty good examples of event handlers can be found on the wiki

    Basically, all you need is a class that inherits from ApplicationBase, register for events in the class constructor and handle the businesslogic in those handlers

    Also, Richard has a nice blog post on how to register and use event handlers.

     

    Hope this helps.

    Regards,

    /Dirk

     

  • Timsn 121 posts 231 karma points
    Jul 09, 2009 @ 17:07
    Timsn
    0

    Thanks you two, that's perfect.

Please Sign in or register to post replies

Write your reply to:

Draft