Copied to clipboard

Flag this post as spam?

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


  • Bruno Toledo 1 post 72 karma points
    Mar 01, 2022 @ 10:59
    Bruno Toledo
    1

    Can I set a different Umbraco context (or set a domain path context) in my Umbraco api for url providers?

    Hi guys,

    My case is that I have a multi-path (and multi-language) setup pointing to an Home (root) item, e.g:

    • Home (paths: [/], [/en], [/en/global], [/da], [/da/dk], ...)
      • About Us
      • Page 1
      • Page 2
      • ...

    In my Umbraco API controller, I get the content url path from the query string param and use the umbracocontext.Content.GetByRoute to get the published content.

    The request looks something like this: ".../api/content/page?url=/en/global/about-us"


    My issue is that whenever I get the Url for content or content link, it's a contextual property, it always returns based on my root path. A breadcrumb example:

        "breadcrumb": {
        "items": [
            {
                "url": "/"
            },
            {
                "url": "/about-us"
            }
        ]
    },
    

    I would like instead to make it follow my "url" param and generates relative links like this:

        "breadcrumb": {
        "items": [
            {
                "url": "/en/global"
            },
            {
                "url": "/en/global/about-us"
            }
        ]
    }
    

    I'm wondering if I can manipulate somehow the Umbraco context in my request lifecycle and make it follow my url custom path and possibly fix it in a "native" way, using the default providers.

    Alternatively, It seems I can achieve that by using a custom url provider as explained here https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/outbound-pipeline#custom-url-provider

    Is this the way to go or is there a better solution?

    Thanks in advance

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies