How to get the title of a page from a content ID using a grid editor partial view?
Hi all,
I've created a grid editor partial view which will display an image and a link of the users choice, however I can only seem to get the content ID for the link the user selects and am struggling to render the text of the link instead of the ID.
Here's my code:
@inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
@using RJP.MultiUrlPicker.Models;
@using Umbraco.Web.Templates
@if (Model.Items.Any())
{
var item = Model.Items.ElementAt(0);
var imageList = item.GetValue<string>("circularResponsiveImage");
var borderColour = item.GetValue("approvedColour");
var link = item.GetValue("link");
if (!string.IsNullOrWhiteSpace(imageList))
{
var imgList = imageList.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var imgListCollection = Umbraco.TypedMedia(imgList);
if (imgListCollection != null)
{
foreach (var img in imgListCollection)
{
<img style="@(!string.IsNullOrWhiteSpace(borderColour) ? "border: 16px solid #" + borderColour : "" ); padding: 0; height: 260px; width: 260px;" src="@img.Url" alt="@img.GetPropertyValue("altText")" class="img-responsive img-circle" />
@Umbraco.RenderMacro("FullPagePath")
<ul class = "nav">
<li class ="more">
<p>@link</p>
</li>
</ul>
}
}
}
}
I've tried a number of different methods like GetPropertyValue, GetPropertyValue
Thanks for taking the time to reply to me, it was a content picker and this solved the problem for me! I'll also remember to reference this when using a multi url picker.
How to get the title of a page from a content ID using a grid editor partial view?
Hi all,
I've created a grid editor partial view which will display an image and a link of the users choice, however I can only seem to get the content ID for the link the user selects and am struggling to render the text of the link instead of the ID.
Here's my code:
I've tried a number of different methods like GetPropertyValue, GetPropertyValue
Any help would be really appreciated :)
Thanks,
David
Hi David
Is it this line
is the link a RJP.MultiUrlPicker?
how about
then you can access
@link.Url @link.Target @link.Name
It depends a little on the version of the RJP you are using where MultiUrls has been replaced by an IEnumerable but same theory should work...
If I'm wrong and the link is a content picker then
should get you details of the picked item.
regards
marc
Hi Marc,
Thanks for taking the time to reply to me, it was a content picker and this solved the problem for me! I'll also remember to reference this when using a multi url picker.
Thanks again, I really appreciate it.
David
is working on a reply...