Copied to clipboard

Flag this post as spam?

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


  • Gerhard Grossberger 55 posts 179 karma points
    Dec 14, 2023 @ 15:09
    Gerhard Grossberger
    0

    How to get a specific Url for a page

    We have an older v8 setup where due split between backend and frontend servers and staging and production environment and also multiple languages we have up to 10 urls for a page.

    www.domain.at/de www.domain.at/en cms.domain.at/en cms.domain.at/en staging.domain.at/de staging-cms.domain.at/de staging.domain.at/en staging-cms.domain.at/en /de /en

    Now for an API to get specific pages (news entries) I want to return the correct URL, depending on culture and calling domain.

    Url() only returns 1 domain, and I canĀ“t set it to use staging environment or CMS environment to test.

    What I did now is to get the domain from the list of domains, based on the request URL and culture, but that is a really instable version.

    Is there a way to work around this and get the Url for a specific domain?

    Best, Gerhard

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Dec 14, 2023 @ 22:42
    Marc Goodson
    100

    Hi Gerhard

    I think you need to implement a SiteDomainHelper, details here

    https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/outbound-pipeline-vpre81#site-domain-helper

    This allows you to tell Umbraco how configured urls are grouped by environment...

    So if you are viewing the site on a staging url, you'll only see urls in the staging group.

    When you call. Url() on a content item, it will use this SiteDomainHelper to return the Url from the current environment grouping...

    Then you can pass in two further parameters into. Url()

    https://our.umbraco.com/apidocs/v8/csharp/api/Umbraco.Web.PublishedContentExtensions.html#UmbracoWebPublishedContentExtensionsUrlUmbracoCoreModelsPublishedContentIPublishedContentSystemStringUmbracoCoreModelsPublishedContentUrlMode

    to specify culture and Urlmode

    If tou set url mode to Absolute and pass in your specific culture... You should now get the right domain with your url..

    ... Fingers crossed

    Regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft