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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Themes /

Discuss SilverStripe Themes.

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

changing navigation.ss???


Go to End


3 Posts   2120 Views

Avatar
dreezy

Community Member, 9 Posts

2 February 2010 at 7:33am

hello,

I got a question...

In my navigation.ss 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";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;

while ($i < $num) {
//vul variabelen met de waardes uit de database
//$variable=mysql_result($result,$i,"fieldname");

//$content[$i]=mysql_result($result,$i,"content");

$title[$i]=mysql_result($result,$i,"Title");
//print_r(mysql_fetch_lengths($result));
//echo $title[$i];
$i++;
$topmenu="";

}
if ($num=0){
$topmenu="sukkel";
};
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>";
}
else
{
$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 page.ss 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 navigation.ss working like the php function above.

I hope someone can tell me PLZ

Avatar
bummzack

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 %>
	&nbsp;|&nbsp;
	<% 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

Avatar
dreezy

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