I have the following razor macro which is nearly working but I can't work out why it outputs "if(countItem==1) </div>" to the page. Any help would be great as I've been staring at this for ages now and making no progress:-
Looks like the Razor parses is not distinguishing correctly between the markup and code, this is possibly because you don't close the div inside the if statement. Try changing to something like this (not tested)
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ int level =2; var subjects =@Model.AncestorOrSelf(level).Children.Where("nodeTypeAlias == \"SideGallerySectionHeading\""); int countItem =1;
Newbie issue
Hi,
I have the following razor macro which is nearly working but I can't work out why it outputs "if(countItem==1) </div>" to the page. Any help would be great as I've been staring at this for ages now and making no progress:-
Craig
Hi. Try to replace
foreach(dynamic image in subjectName.Children) {
with
@foreach(dynamic image in subjectName.Children) {
That gives:-
Error occured
Unexpected "foreach" keyword after "@" character. Once inside code, you do not need to prefix constructs like "foreach" with "@".
Looks like the Razor parses is not distinguishing correctly between the markup and code, this is possibly because you don't close the div inside the if statement. Try changing to something like this (not tested)
is working on a reply...