Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

How to use <% control %> and <% if %>

Go to End

4 Posts   1679 Views


28 Posts

18 July 2007 at 7:47pm

I'm having problems using the controllers. I can get it working for single variable returns
see BannerImg (I'm using it as text for now just to test) below but am unable to get
getChildrenof(title) to work. Below are the portions of the *.code and Layout/*.ss files
and the error I get. I've gone through the all the tuorials and the documantation on the site.
Also I get errors when I try to put Debug::message("hello") and Debug::show($variable)
in either the *.code or *.ss file how are you suposed to call them?

class SectionHolder_Controller extends Page_Controller {
function BannerImg() {
return $this->BannerImg;
function getChildrenOf($searchtitle) {
$data = DataObject::get($searchtitle, "ShowInMenus = 1");
return $data->Children();
<% if Menu(2) %>
<ul id="Menu2">
<% control Menu(2) %>
<div id="subh2"> <div class="gla-r"> <div class="gla-l">
<% control getChildrenOf($Title) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the $Title page">$MenuTitle</a></li>
<% end_control %>
<% end_control %>
<% end_if %>

error I get:
Parse error: syntax error, unexpected '}' in /tmp/silverstripe-cache/ on line 57


Forum Moderator, 5523 Posts

18 July 2007 at 9:16pm

you have the function in the class SectionHolder.php and you are trying to call it from a template Im guessing you are including in


Community Member, 231 Posts

19 July 2007 at 12:10am

<% control Children %> should work fine, I'm not sure what getChildrenOf() is supposed to do?


28 Posts

19 July 2007 at 3:51am

Willr - Yes SectionMenu is an Include to

Andy - <% control Children %> is what I wanted. I thought I tried
that before and got errors so I tried to write getChildrenOf() to get
the children of a particular page by its Title. I just tired using Children
and got the results that I wanted Thanks

But for future reference can you see why the getChildrenOf() did not
work? Am I misunderstanding the use of "control" or the way the
"DataObject::get" works.