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.


Discuss SilverStripe Themes.

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



3 Posts   1333 Views


2 February 2010 at 7:33am Community Member, 9 Posts


I got a question...

In my there are te following lines

<% control Menu(1) %>
<a href="$Link" title="Go to the $Title.XML page" class="topmenu_text"><span>$MenuTitle</span></a>counter
<% end_control %>

When i show the menu on the page it looks like

item1 item2 item3

I want to let it look like

item1 | item2 | item3

I've made a php solution, but it does not work into the ss files

the solution looks like this

function MyMenu() {
   $query="select * from SiteTree where parentid='0' order by sort";

   while ($i < $num) {
      //vul variabelen met de waardes uit de database


      //echo $title[$i];
   if ($num=0){
   for ($menu_counter=0;$menu_counter<$i; $menu_counter++)
         if ($menu_counter < ($i-1))
            $menutext=str_replace(" ","-",$title[$menu_counter]);
            $topmenu= $topmenu."<a style='font-size:16px;color:black;font-weight:bold;' href='$menutext/'>".$title[$menu_counter]."</a>"."<span class=menu_bar>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
            $menutext=str_replace(" ","-",$title[$menu_counter]);
            $topmenu = $topmenu."<a style='font-size:16px;color:black;font-weight:bold;' href='$menutext/'>".$title[$menu_counter]."</a>";
   return $topmenu;

in my i call this function as original, but when i want to make this website multilanguage
it work, but it shows all the menu items.

Im struggling with languages
i've three languages nl_NL, de_DE, us_EN

I take the ?locale= extention in the url by $_GET("locale), but when i hit another menu item there is no $_GET("locale).
So i went to the solution above.

My question is to make working like the php function above.

I hope someone can tell me PLZ


2 February 2010 at 9:44am Community Member, 901 Posts

Ouch. That's some horrible spaghetti-code.
What about something along these lines:

<% control Menu(1) %>
   <a href="$Link" title="Go to the $Title.ATT page" class="topmenu_text"><span>$MenuTitle</span></a>
   <% if Last %><% else %>
   <% end_if %>
<% end_control %>

The above should create:
item1 | item2 | item3

I also strongly encourage you to:
- Make use of the SilverStripe template engine and try to avoid HTML Markup in your PHP Files
- Get rid of arcane tags like <font> and use CSS for presentational stuff


2 February 2010 at 12:35pm Community Member, 9 Posts

Thanx Banal,

This is the solution... IT WORKS :)

normaly i use css, but it's fast made...
so i've put all the css code into this php

But i´m pleased that you have help me....

Thanx for that..