17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1324 Views |
-
Tricky Navigation

5 July 2008 at 3:37am
Hi,
I am transferring an existing static corporate website to Silverstripe. On the homepage the navigation has a group of second level navigation items open while their are other second level nav items which you can't see until you click on the top level link.
I want to be able to replicate this in SilverStripe and was thinking the best way to do it would be with in IF statement in the template as so:
<% if Children %>
<% if URLSegment="industry-practice">
<li class="$URLSegment"><a href="$Link" title="{$Title}" class="$LinkingMode">$MenuTitle</a>
<ul>
<% control Children %>
<li class="$LinkingMode"><a href="$Link" title="{$Title}" class="$LinkingMode">$MenuTitle</a></li>
<% end_control %>
</ul>
</li>
<% else %>
<li class="$LinkingMode"><a href="$Link" title="{$Title}" class="$LinkingMode">$MenuTitle</a></li><% end_if %>
<% else %>
<li class="$LinkingMode"><a href="$Link" title="{$Title}" class="$LinkingMode">$MenuTitle</a></li>
<% end_if %>Anyway this doesn't work but is it possible to do something like <% if URLSegment="industry-practice"> ? Otherwise is their an easier way to selectively display a second level menu item based on a class?
-
Re: Tricky Navigation

6 July 2008 at 10:29am
Maybe you're looking for
<% if InSection(page-url) %>
?
-
Re: Tricky Navigation

6 July 2008 at 1:08pm
have a look at -
http://doc.silverstripe.com/doku.php?id=built-in-page-controls
http://doc.silverstripe.com/doku.php?id=built-in-page-controls#links_and_class_sfor a range of things you can do. <% if InSection %> or <% LinkOrSection %> might work well
-
Re: Tricky Navigation

8 July 2008 at 10:02pm
Thanks both for your help. InSection doesn't seem to work for me. I played around with
<% if Title=PageTitle %> instead and it worked to a point. First I tried a page with only one word as the title but then I tried the page I wanted called "Industry Practices" and it doesn't work. ie
<% if Title=Industry Practices %>
It obviously doesn't like the spacing but I have no idea how to overcome this.
Any ideas?
Thanks
-
Re: Tricky Navigation

8 July 2008 at 10:12pm
Why doesn't InSection work?
Or else URLSegment must work.. but remember you shouldn't use quotes, at least that's what the docs say.
So:
<% if InSection(industry-practice) %>
<% end_if %>
or
<% if URLSegment = industry-practice %>
If none is working I think something else might be wrong...
-
Re: Tricky Navigation

8 July 2008 at 10:25pm
I gave URLSegment a go and it didn't work at first. I then renamed the page URL and it worked? So all is well now.
Thanks very much for you help.
| 1324 Views | ||
|
Page:
1
|
Go to Top |



