Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » navigation drop down control

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

Page: 1 2
Go to End
Author Topic: 5405 Views
  • Web Designer Perth
    Avatar
    Community Member
    49 Posts

    Re: navigation drop down control Link to this post

    That did it!

    Really appreciate your help!

  • Heike-san
    Avatar
    Community Member
    52 Posts

    Re: navigation drop down control Link to this post

    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 ?

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: navigation drop down control Link to this post

    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!

  • Heike-san
    Avatar
    Community Member
    52 Posts

    Re: navigation drop down control Link to this post

    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.

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: navigation drop down control Link to this post

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

  • Heike-san
    Avatar
    Community Member
    52 Posts

    Re: navigation drop down control Link to this post

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

  • Graphicator
    Avatar
    Community Member
    62 Posts

    Re: navigation drop down control Link to this post

    Thank you.

    5405 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.