Im running a Umbraco 7.01, and i've created a Razor Macro (Not a partial), and I wanna render a link from a content picker (The contentpicker has the ID of the page, and I want make it to a link), however I cant quite get it to work... Im trying to use Library.NodeById(), but it doens't work?
Any ideas?
// List planets if visible
if (planetNodeStart.Children.Where("Visible").Any())
{
<div class="planets">
@foreach (var page in planetNodeStart.Children.Where("Visible"))
Link from contentpicker?
Hey Guys...
Im running a Umbraco 7.01, and i've created a Razor Macro (Not a partial), and I wanna render a link from a content picker (The contentpicker has the ID of the page, and I want make it to a link), however I cant quite get it to work... Im trying to use Library.NodeById(), but it doens't work?
Any ideas?
// List planets if visible
if (planetNodeStart.Children.Where("Visible").Any())
{
<div class="planets">
@foreach (var page in planetNodeStart.Children.Where("Visible"))
{
<div class="planet">
@{
var node = Library.NodeById(page.planetLink);
<a href="@node.Url">
@node.Name
</a>
}
</div>
}
</div>
}
Also tried doing this, but still doens't work:
<div class="planets">
@foreach (var page in planetNodeStart.Children.Where("Visible"))
{
<div class="planet">
@{
var node = Model.Library.NodeById(page.planetLink);
<a href="@node.Url">
@page.Name
</a>
}
</div>
}
</div>
Ahhh, found my error, the solution was:
@foreach (var page in planetNodeStart.Children.Where("Visible"))
{
//If there a link to a module
if (page.HasValue("planetLink")){
var node = Library.NodeById(page.planetLink);
<a href="@node.Url">
@page.Name
</a>
}
}
is working on a reply...