That did it!
Really appreciate your help!
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
That did it!
Really appreciate your help!
Hello,
I am a newbie and I think that I have the same problem as all of the listed above, although there is a tiny difference.
What I am trying to do is to get a my menu to generate a drop down menu.
So I figured out that this should be done with if statement as to know whether there should be a drop down list or not.
So I came up with this code:
<ul>
<% control Menu(1) %>
<li><a href="$Link" id="menu_$Title" title="$Title">$MenuTitle</a></li>
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="$Title">$MenuTitle</a></li>
<% end control %>
</ul>
</li>
<% else %>
</li>
<% end_if %>
<% end_control %>
</ul>
Now it shoul dbe working fine but it does not, apparently my <% if Children %> statement is not recognised and causing an error to occur.
As I have said I am totally new to OOP PHP and SilverStripe use, so I don't know if I need to create a class and an object for the Children (I am somewhat ashamed of saying it but that is the truth).
I have also seen people using this: <% if LinkOrSection = section %> but I do not know whether it is related or not.
Can somebody help me please ?
Hi,
What error are you getting?
<% if Children %> should work fine, but you're doing something wrong with the html.
Instead of
<ul>
<% control Menu(1) %>
<li><a href="$Link" id="menu_$Title" title="$Title">$MenuTitle</a></li>
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="$Title">$MenuTitle</a></li>
<% end control %>
</ul>
</li>
<% else %>
</li>
<% end_if %>
<% end_control %>
</ul>
try
<ul>
<% control Menu(1) %>
<li>
<a href="$Link" id="menu_{$Title}" title="$Title">$MenuTitle</a>
<% if Children %>
<ul>
<% control Children %>
<li><a href="$Link" title="$Title">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>
Don't forget to flush!
Hi,
thanks for helping.
Although I am getting the same error as before:
"Parse error: syntax error, unexpected $end in C:\WINDOWS\Temp\silverstripe-cacheC--wamp-www-onedoor2\.cacheC..wamp.www.onedoor2.themes.onedoor.templates.Home.ss on line 162"
I do not know which $end it is refering too, even the line numbers are odd.
end control should be end_control that's one thing I see right now that is wrong
Seems that your right and that I am unbelivably blind!
Although I tried once with you version and it did not quite work, I retried it right now and it works just fine!!
Thanks a lot!!
Thank you.