Custom Url Provider "This document is published bu...
# help-with-umbraco
m
My provider returns the url as expected but the UI is instead saying it cant be routed. GetOtherUrls (also custom) is working as expected though. Events are shared between several root nodes and sit in a list view'd container in the root.
Copy code
public override UrlInfo? GetUrl(IPublishedContent content, UrlMode mode, string? culture, Uri current)
    {
        if (content.ContentType.Alias != UmbracoModels.EventPage.ModelTypeAlias)
        {
            return base.GetUrl(content, mode, culture, current);
        }

        var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
        var domain = DomainUtilities.SelectDomain(umbracoContext.PublishedSnapshot.Domains?.GetAll(false), current);

        var eventsPage = umbracoContext.Content?.GetById(domain.ContentId).Descendant<UmbracoModels.EventsPage>();

        var uri = AssembleUrl(domain, $"/{eventsPage.UrlSegment}/{content.UrlSegment}", current, mode)
            .ToString();

        return UrlInfo.Url(uri, culture);
    }
I think I need the content finder in place and it will sort it 🤞
p
@Matt Wise You are correct that the reason for this issue is in fact a missing content finder - I was just caught by that. However, I have a slight variation on this issue in that I have a multi-site installation and so the method of selecting the domain will only work for the domain being used to access the back office and will fail when viewing nodes in any of the other sites. The routes do not include the top level node for each site so trying to match on a route but without the domain also fails. In a similar fashion, we are using the content delivery API which will result in the same problem since the same domain is used to make all of the requests instead of making API request under each domain. Any ideas how to handle this?
m
I think that's where other URLs comes in on the class
@ProNotion the content finder I shared here might be of use as well https://discord.com/channels/869656431308189746/1266812457117024287
p
@Matt Wise Thanks, I've implemented my ContentFinder already which resolved the issue. There is some other information on that thread though which is of use in regards to translations of url segments so thanks for sharing 👍
3 Views