I have a "Menus" page with a MultiNode Tree Picker on it which selects items from a particular section.
I have created a partial view called "listMenuItems" which includes several fields such as an image, text and a link which is specified via a content picker. However, I cant for the life of me get the hyperlink to work (everything else works fine). The link Alias is "linkTo"
My Partial view is :
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ var selection = CurrentPage.insertMenuItems.Split(','); }
@foreach (var id in selection)
{
var item = Umbraco.Content(id);
<div class="col-sm-4">
<div class="service wow fadeInDown">
<div class="service-icon"><i class="fa [email protected]"></i></div>
<h3>@item.Name</h3>
<p>@item.MenuItemText</p>
<a class="big-link-1" href="@Umbraco.Content("LinkTo").Url">View Menu</a>
</div>
</div>
}
I am sure I am doing something obvious here but I have been looking at it so long and tried everything I can think of. Any Ideas would be greatfully revieved
You will also want to make sure that there is actually a link, so something like:
var item = Umbraco.Content(id);
var link = string.Empty;
if (item.HasValue("LinkTo"))
{
var linkId = item.GetPropertyValue("LinkTo");
var linkItem = Umbraco.Content(linkId);
if (linkItem != null)
{
link = linkItem.Url;
}
}
Hyperlink in Partial View not linking to the page
Hi All
I am hoping someone can help me?
I have a "Menus" page with a MultiNode Tree Picker on it which selects items from a particular section.
I have created a partial view called "listMenuItems" which includes several fields such as an image, text and a link which is specified via a content picker. However, I cant for the life of me get the hyperlink to work (everything else works fine). The link Alias is "linkTo"
My Partial view is :
The line that doesn't work is:
I am sure I am doing something obvious here but I have been looking at it so long and tried everything I can think of. Any Ideas would be greatfully revieved
Ben
I'm assuming the link is a property with the alias
LinkTo
on each item in your selection?After
var item = Umbraco.Content(id);
you probably want:The your link should look like:
You will also want to make sure that there is actually a link, so something like:
And then your link can look like:
Thank you so much Sebastiaan, That has worked perfectly.
I very much appreciate it.
is working on a reply...