Within the each product in products the <h2> element is displaying the nodeID from here I would like to retrieve the displayTitle.Name and have the wrapped in a href displayTitle.Url
But cannot seem to get the code right any pointers would be appreciated.
Thanks for the reply, what I have on this page is a page picker, named items, that holds the collection of product document types. From this I get a list of Products. The product document type has, amongst others, a content picker property that I'm wanting to use as a link to the product document type page itself. Hope this isn't too confusing if there's a simpler solution I'm open to suggestions. I'm not too far off at the moment I just need to get the name and url from the content picker named displayTitle
In a nutshell yes, and then each of these nodeids (document type product) has a content picker property named displayTitle. Within the <h2> tag I currently have the node id but what I want is the name and also to be wrapped within the url.
accessing content picker details
Hi I'm new to umbraco / razor and I'm struggling to get the details from a content picker property.
I have the following snippet of code:
@{
var nodeIds = Model.Content.GetPropertyValue("items").ToString().Split(',');
List<IPublishedContent> products = new List<IPublishedContent>();
foreach (var nodeId in nodeIds)
{
if (!String.IsNullOrEmpty(nodeId))
{
var publishedContent = Umbraco.NiceUrl(Convert.ToInt32(nodeId));
if (!String.IsNullOrEmpty(publishedContent) && publishedContent != "#")
{
products.Add(Umbraco.TypedContent(nodeId));
}
}
}
}
@foreach (var product in products)
{
if(product != null)
{ <div class="feature fl">
<h2>@Html.Raw(product.GetPropertyValue("displayTitle"))</h2>
<img class="productImage" [email protected](product.GetPropertyValue("displayTitle")) [email protected](product.GetPropertyValue("displayImage")) />
</div>
}
}
Within the each product in products the <h2> element is displaying the nodeID from here I would like to retrieve the displayTitle.Name and have the wrapped in a href displayTitle.Url
But cannot seem to get the code right any pointers would be appreciated.
Many Thanks
Hi Graeme,
You mention content picker but that only picks one item and it looks like you have multiple, are you actually using a multi node tree picker?
Thanks,
Jeavon
Hi Jeavon
Thanks for the reply, what I have on this page is a page picker, named items, that holds the collection of product document types. From this I get a list of Products. The product document type has, amongst others, a content picker property that I'm wanting to use as a link to the product document type page itself. Hope this isn't too confusing if there's a simpler solution I'm open to suggestions. I'm not too far off at the moment I just need to get the name and url from the content picker named displayTitle
Ok, cool, so the property "items" is a CSV string of nodeids right?
In a nutshell yes, and then each of these nodeids (document type product) has a content picker property named displayTitle. Within the <h2> tag I currently have the node id but what I want is the name and also to be wrapped within the url.
Ok, got it, I think you need
Thanks Jeavon, works perfectly
Awesome!
is working on a reply...