Copied to clipboard

Flag this post as spam?

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


  • Helmuth Bederna 17 posts 78 karma points c-trib
    Feb 10, 2015 @ 14:24
    Helmuth Bederna
    0

    Short Url's

    Hi Alain,

    I don't know if something is possible with your package so I'm just asking right away is it supported to create shorter URL's? For example if you have a Folder structure in the backend and don't want to reflect that in the frontend.

    Folder Structure: Previews\Year\Month\Week\ArticleName
    Current Url: http://www.domain.com/previews/2015/februaray/my-awesome-article
    Short Url: http://www.domain.com/my-awesome-article

    Best Regards,
    Helmuth

  • Sören Deger 733 posts 2844 karma points c-trib
    Feb 10, 2015 @ 14:38
    Sören Deger
    0

    Hi Helmuth,

    Should it not be possible with the package, you can use the default umbracoUrlAlias in document types:

    https://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracourlalias

     

    Best,

    Sören

     

     

  • Alain 73 posts 520 karma points c-trib
    Feb 10, 2015 @ 15:34
    Alain
    103

    Hi Helmuth,

    This is one of the goals of the package.

    If the nodeId for the content "my-awesome-article" is 1290, then the following route will do it.

    <?xml version="1.0" encoding="utf-8"?>
    <Routes>
      <Route UrlSegments="/my-awesome-article/" Enabled="true" DocumentTypeAlias="" PropertyAlias="" Template="" ForceTemplate="false" FallbackNodeId="1290" Description="" />
    </Routes>
    

    If you have more than one article you could do:

    <?xml version="1.0" encoding="utf-8"?>
    <Routes>
      <Route UrlSegments="/my-awesome-article/" Enabled="true" DocumentTypeAlias="" PropertyAlias="" Template="" ForceTemplate="false" FallbackNodeId="1290" Description="" />
      <Route UrlSegments="/my-awesome-article2/" Enabled="true" DocumentTypeAlias="" PropertyAlias="" Template="" ForceTemplate="false" FallbackNodeId="1291" Description="" />
      <Route UrlSegments="/my-awesome-article3/" Enabled="true" DocumentTypeAlias="" PropertyAlias="" Template="" ForceTemplate="false" FallbackNodeId="1292" Description="" />
    </Routes>
    

    To avoid creating a new route for every article, you can set up a more generic route:

    Let's assume that all the articles use the same Document Type whose alias is "article" and that you have only 2 articles whose names are: "my awesome article" and "most awesome article"

    <?xml version="1.0" encoding="utf-8"?>
    <Routes>
      <Route UrlSegments="/" Enabled="true" DocumentTypeAlias="article" PropertyAlias="name" Template="" ForceTemplate="false" FallbackNodeId="" Description="" />
    </Routes>
    

    The following urls will display properly both articles:

    For any other Url, since there are no more articles, the routing engine will not be able to find an article and will fall back on Umbraco's routes. This is because no fallbacknodeid was setup in the route config. If you set up a fallbackNodeId then any other Url would display the fallbackNodeId. Since this is the website root url that wouldn't be the best practice.

    The fallbackNodeId is more for scenarios like:

    with a route config like

    <?xml version="1.0" encoding="utf-8"?>
    <Routes>
      <Route UrlSegments="/article/" Enabled="true" DocumentTypeAlias="article" PropertyAlias="name" Template="" ForceTemplate="false" FallbackNodeId="1630" Description="" />
    </Routes>
    

    In this case the Urls below will redirect to the node id 1630 (FallbackNodeId) that could be a landing page with a listing of all available articles, for example.

    If in the future you create a new article whose name is "k3xasdddddcm" then the routing engine will detect it and the url "http://www.domain.com/article/k3xasdddddcm" would display this content node instead of the fallbacknodeid.

    Hope that helps.

    Best,

    Alain

  • Helmuth Bederna 17 posts 78 karma points c-trib
    Feb 10, 2015 @ 16:02
    Helmuth Bederna
    0

    @Sören, thanks for the reply!
    The downside is that you need to hook the umbraco Event API and overwrite this property to provide an alternative route. So something Alen described is pretty just right now would be kind of amazing.

    @Alan
    That's, as already stated above, AMAZING. I will definitelly us this package just because of this feature. Thats really awesome! Keep up the great work!

    Regards,
    Helmuth 

  • Alain 73 posts 520 karma points c-trib
    Feb 10, 2015 @ 19:00
    Alain
    0

    Helmuth, thanks and glad it is useful!

    I just want to clarify (as Sören said) that umbracoUrlAlias is another option. Further, I would say that it is the option to consider for simple scenarios.

    This package has been created to handle more complex scenarios like:

    • huge amount of urls
    • urls managed automatically
    • necessary to have a fallback landing pages in the case that a url is not correct or has changed
    • assign dynamically umbraco templates or full path views (~/views/mysubfolder/myview.cshtml) for some routes and/or document types
    • ...

    Alain

  • Abdul Rahim 14 posts 84 karma points
    May 03, 2016 @ 10:28
    Abdul Rahim
    0

    Hi Alain,

    Its Working for me.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft