I'm new to Umbraco world. Currently I'm using nested content in my project, this is an amazing plugin. Now I have a question about how to use url picker in nested content?
Here is my code (but always show me the error:'object' does not contain a definition for 'url' and no extension method 'url' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)):
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web
@{
var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("nestedItem");
foreach (var item in items)
{
var image = item.GetPropertyValue("itemImage");
var UrlPicker = item.GetPropertyValue("itemUrl");
if (image != null)
{
<div class="col-xs-6 col-md-3">
<img src="@Umbraco.Media(image).UmbracoFile" alt="">
<h3>
@Umbraco.Field(item, "itemTitle")
</h3>
<p>
@Umbraco.Field(item, "itemText")
</p>
<a href="@UrlPicker.url" target="#" style="text-align: center; margin: 20px;"><h2 style="text-align:center">CONTACT US TODAY</h2></a>
</div>
}
}
}
when I run this code, the images, texts was able to works correctly, but the url is working wrong. Did I made some mistake in the code? Can anyone help me to check or give me some idea how does the url picker work in nested content?
how to use url picker in nested content?
Hi All,
I'm new to Umbraco world. Currently I'm using nested content in my project, this is an amazing plugin. Now I have a question about how to use url picker in nested content?
Here is my code (but always show me the error:
'object' does not contain a definition for 'url' and no extension method 'url' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
):when I run this code, the images, texts was able to works correctly, but the url is working wrong. Did I made some mistake in the code? Can anyone help me to check or give me some idea how does the url picker work in nested content?
Thanks very much!
UrlPicker returns a collection of links, even if only one is selected. I'm guessing something like this will work:
Michaël is right. My answer is only valid if you're using this: https://our.umbraco.org/projects/backoffice-extensions/multi-url-picker/
Thanks very much David.
Hi Yuxuan Li,
if your url picker is a content picker then the value of
UrlPicker
will be the Id of the selected node.You can get the url of the node by using:
or by getting the node:
/Michaël
Thanks Michael, it works great!
Hi Yuxuan,
Glad that I could help you out!
/Michaël
is working on a reply...