Error with .URL of content picker but .UrlSegment works fine.
m
In a block element I have a Content Picker type (called 'Test') and am trying to use it to generate a link to a page. In the code for the block list template I use @content.Test.Name and this work fineish. While it prints the name of the content node and the URL, the URL is relative to the current page and not the root so links are broken. If I try to use @content.Test.Name Visual Studio will give the error "The delegate type could not be inferred" on the 'Url' part of the content. Why is this error being thrown and how do I fix it so I can get the correct URLs generated?
m
URL is a function not a property so you need to use Url()
m
Beat me to it.. that would be a valuable addition to https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/content-picker Seen as most would use a contentPicker to get the Name and Url() ?
Copy code
Returns the Url to the page.
@Model.Url(PublishedUrlProvider)
haven't we just decided
@Model.Url()
will do 🙂
m
Ok I see it now. I was confused cause in the MultiUrlPicker '.Url' is valid (See @Mike Chambers 's link). Thanks for the clarification. @Mike Chambers From my novice, entry level, perspective I would agree an example on the Content Picker page showing Url() would be nice to have. And the IPublishedContent page you linked. A lot of that goes over my head but iun the .Url() section '@Model.Url(PubliushedUrlProvider)' is a bit confusing to me seeing how I can do .Url() and not have to pass in any paramters but as that page looks like it is intended to be more for highly experianced people.
6 Views