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.

Template Questions

navigation drop down control


Reply

15 Posts   5665 Views

Avatar
Web Designer Perth

21 September 2009 at 11:07am Community Member, 49 Posts

That did it!

Really appreciate your help!

Avatar
Heike-san

14 October 2009 at 1:55am Community Member, 52 Posts

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

14 October 2009 at 2:47am (Last edited: 14 October 2009 3:27am), Community Member, 501 Posts

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

14 October 2009 at 3:19am Community Member, 52 Posts

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

14 October 2009 at 3:27am Community Member, 501 Posts

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

Avatar
Heike-san

14 October 2009 at 3:54am Community Member, 52 Posts

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

15 June 2010 at 2:09am (Last edited: 15 June 2010 2:10am), Community Member, 62 Posts

Thank you.