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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Themes /

Discuss SilverStripe Themes.

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


Go to End

3 Posts   1741 Views


Community Member, 9 Posts

2 February 2010 at 7:33am


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


Community Member, 904 Posts

2 February 2010 at 9:44am

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


Community Member, 9 Posts

2 February 2010 at 12:35pm

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