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've moved the forum!

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.

Template Questions /

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

navigation drop down control


Go to End


15 Posts   8631 Views

Avatar
Web Designer Perth

Community Member, 49 Posts

21 September 2009 at 11:07am

That did it!

Really appreciate your help!

Avatar
Heike-san

Community Member, 52 Posts

14 October 2009 at 1:55am

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 ?

Avatar
dio5

Community Member, 501 Posts

14 October 2009 at 2:47am

Edited: 14/10/2009 3:27am

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!

Avatar
Heike-san

Community Member, 52 Posts

14 October 2009 at 3:19am

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.

Avatar
dio5

Community Member, 501 Posts

14 October 2009 at 3:27am

end control should be end_control that's one thing I see right now that is wrong

Avatar
Heike-san

Community Member, 52 Posts

14 October 2009 at 3:54am

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!!

Avatar
Graphicator

Community Member, 62 Posts

15 June 2010 at 2:09am

Edited: 15/06/2010 2:10am

Thank you.

Go to Top