I cannot get access to a top level controller's methods or properties in an IF statement within a control loop:
Here is the code in the template:
<% control Children %> <div class="nav-item"> <% if ID == Top.GetVideoPageId %> <a class="navigation-link-selected" href="$Top.URLSegment/?vpid=$ID">$MetaTitle</a> <% else %> <a class="navigation-link" href="$Top.URLSegment/?vpid=$ID">$MetaTitle</a> <% end_if %> </div> <% end_control %>
The current controller has a method called GetVideoPageId which just returns the VideoPageId property.
The issue is this line of code:
<% if ID == Top.GetVideoPageId %>
When I run this, I get a blank page, and no error log entries. I've put the site in dev mode and no joy there either, I get the same problem
Initially I tried
<% if ID == Top.videoPageId %>
to access the property directly with the same results.
I thought Top could be used to access the current controller from within a template control loop? Where I use $Top in the URLs, it is working fine. Have I just got the syntax wrong for the If statement?