I'm trying to setup my first partial view macro file and running into a syntax problem I think. Or perhaps I'm going about this all wrong, either way a little guidance would be MUCH appreciated.
I am on v6.1.6 and am trying to pull in a list of documents that have been selected to be on the current page. I hope this makes sense. In other words, the document type for document asset has a multi-node tree node picker that saves the results in csv. I would like to then place those documents on the correct page as appropriate.
I have the following hard coded which does the trick, but I can't seem to figure out how to use the @CurrentPage.ID variable in place of the hardcoded \"2524\".
Thanks
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@if (Model.MacroParameters["nodeID"] != null)
{
@* Get the start node as a dynamic node *@
var startNode = Umbraco.Content(Model.MacroParameters["nodeID"]);
var curPage = CurrentPage.Id.ToString();
var docs = startNode.Children.Where("Visible && assetPlacement.Contains(\"2524\")");
if (startNode.Children.Where("Visible").Any())
{
<ul>
@foreach (var page in docs)
{
<li><a href="#">@page.documentTitle</a>@curPage (@CurrentPage.Id) @page.assetPlacement</li>
}
</ul>
}
}
Partial Macro View File Syntax
I'm trying to setup my first partial view macro file and running into a syntax problem I think. Or perhaps I'm going about this all wrong, either way a little guidance would be MUCH appreciated.
I am on v6.1.6 and am trying to pull in a list of documents that have been selected to be on the current page. I hope this makes sense. In other words, the document type for document asset has a multi-node tree node picker that saves the results in csv. I would like to then place those documents on the correct page as appropriate.
I have the following hard coded which does the trick, but I can't seem to figure out how to use the @CurrentPage.ID variable in place of the hardcoded \"2524\".
Thanks
I normally have a field on the data type which is a MNTP.
Get the value of that field and split it into an array then get all the content nodes and iterate over them.
Then with the array:
e.g.
<li><a href="#">@relatedDoc.GetPropertyValue<string>("documentTitle")</a>
Does that help at all?
is working on a reply...