GetDynamicContentById not found in the Umbraco namespace
Hi All,
I am a developer (django and php (yuck) mainly with some actionscript Flex/Flash work) with a company based in Scotland and I am working on a project that is using this CMS. I am 100% new to it and to .NET in general (currently learning ASP.NET C#).
I have an issue creating a navigation macro with razor, and I have seen a few examples that all seem to be based on the current page ($currentPage) when using XSLT (which I am not a fan of), and for a menu I can't see see how thats possible, but I digress.
I am trying to create this marco to first create a sub menu with a very specific design (dont ask) and I need to parse a page id and then get the child pages of that specific parent. I am passing the parameter to the macro without issue, but when I attempt to the run a foraech loop using Umbraco.GetDynamicContentById() Visual Studio reports that this is not in the namespace and obviously the macro fails. The code is:
@foreach(var child in Umbraco.GetDynamicContentById(source).Children) { if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) { <li><a href="@child.NiceUrl">@child.name</a></li> }
}
I am have not specified any @using to import and other namespases. Any pointers would be great as this project has a stupidly tight deadline. I cannot show you the menu directly as I am under a NDA. But it is a typical parent content page with some children.
Ok for those who may come up against a similar problem of dealing with a sub navigation issue I managed to cobble together this thatsnks for the feedback.
GetDynamicContentById not found in the Umbraco namespace
Hi All,
I am a developer (django and php (yuck) mainly with some actionscript Flex/Flash work) with a company based in Scotland and I am working on a project that is using this CMS. I am 100% new to it and to .NET in general (currently learning ASP.NET C#).
I have an issue creating a navigation macro with razor, and I have seen a few examples that all seem to be based on the current page ($currentPage) when using XSLT (which I am not a fan of), and for a menu I can't see see how thats possible, but I digress.
I am trying to create this marco to first create a sub menu with a very specific design (dont ask) and I need to parse a page id and then get the child pages of that specific parent. I am passing the parameter to the macro without issue, but when I attempt to the run a foraech loop using Umbraco.GetDynamicContentById() Visual Studio reports that this is not in the namespace and obviously the macro fails. The code is:
@foreach(var child in Umbraco.GetDynamicContentById(source).Children) {if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) {
<li><a href="@child.NiceUrl">@child.name</a></li>
} }
I am have not specified any @using to import and other namespases. Any pointers would be great as this project has a stupidly tight deadline. I cannot show you the menu directly as I am under a NDA. But it is a typical parent content page with some children.
Thanks
For those who want it this is the entire macro.
@{var source = string.IsNullOrEmpty(Parameter.Source) ? Model.CurrentPage.Id : Parameter.Source; <div class="subMenu"> <div>
<ul>
@foreach(var child in Umbraco.GetDynamicContentById(source).Children) {
if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) { <li><a href="@child.NiceUrl">@child.name</a></li> } } </ul> </div> <div>
</div>
</div>
}
The empty div will be populated with something else so just ignore it it
The error on the frontend is ERROR LOADING MACROENGINE SCRIPT (FILE: ********.CSHTML)
This is for version 4.9.
!BUMP!
Ok for those who may come up against a similar problem of dealing with a sub navigation issue I managed to cobble together this thatsnks for the feedback.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.