Jump to:

1384 Posts in 493 Topics by 522 members

Themes

SilverStripe Forums » Themes » changing navigation.ss???

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1322 Views
  • dreezy
    Avatar
    Community Member
    9 Posts

    changing navigation.ss??? Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: changing navigation.ss??? Link to this post

    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

  • dreezy
    Avatar
    Community Member
    9 Posts

    Re: changing navigation.ss??? Link to this post

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

    1322 Views
Page: 1
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.