Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Simple question. How do I get the niceurl from a property (contentpicker)
<a href='@Model.mylinkproperty'>Test</a>
This only gets me the id. Tried a couple of versions but cannot seem to find the right one.
Help please :)
/ Niklas
Hi Niklas,
Try using the NiceUrl function. I know nothing about Razor but believe it would be:
<a href="@umbraco.library.NiceUrl(Model.Id)">Test</a>
-Tom
Hi Tom,
I try to implement this in this Razor code:
var disclaimerpage = umbraco.library.NiceUrl(Model.Parent.siteDisclaimerPage);
But when I run the code, I get an error on this line with the error message:
"The best overloaded method match for 'umbraco.library.NiceUrl(int)' has some invalid arguments"
There is an argument issue because the property 'siteDisclaimerPage' is of type string (an id from selecting a page with the Content Picker)
greetings,
Anthony
Hi Anthony,
Try something like this instead:
var disclaimerPage = Library.NodeById(Model.Parent.siteDisclaimerPage);<a href="@disclaimerPage.Url">@disclaimerPage.Name</a>
Otherwise you can convert the string to int and use NiceUrl but this might be better.
Oh I see,
I found this solution to work:
@{
var disclaimerpage = Library.NodeById(Model.Parent.siteDisclaimerPage);
var url = umbraco.library.NiceUrl(disclaimerpage.Id);
}
I'll try yours also, because it's one line of code less :)
yep, your suggestion also works. I'll take your code, as it's one line of code less and one variable (= memory allocation) less.
Thanks,
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Niceurl for contentpicker property
Simple question. How do I get the niceurl from a property (contentpicker)
<a href='@Model.mylinkproperty'>Test</a>
This only gets me the id. Tried a couple of versions but cannot seem to find the right one.
Help please :)
/ Niklas
Hi Niklas,
Try using the NiceUrl function. I know nothing about Razor but believe it would be:
-Tom
Hi Tom,
I try to implement this in this Razor code:
var disclaimerpage = umbraco.library.NiceUrl(Model.Parent.siteDisclaimerPage);
But when I run the code, I get an error on this line with the error message:
"The best overloaded method match for 'umbraco.library.NiceUrl(int)' has some invalid arguments"
There is an argument issue because the property 'siteDisclaimerPage' is of type string (an id from selecting a page with the Content Picker)
greetings,
Anthony
Hi Anthony,
Try something like this instead:
Otherwise you can convert the string to int and use NiceUrl but this might be better.
-Tom
Oh I see,
I found this solution to work:
@{
var disclaimerpage = Library.NodeById(Model.Parent.siteDisclaimerPage);
var url = umbraco.library.NiceUrl(disclaimerpage.Id);
}
I'll try yours also, because it's one line of code less :)
Anthony
yep, your suggestion also works. I'll take your code, as it's one line of code less and one variable (= memory allocation) less.
Thanks,
Anthony
is working on a reply...