Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » Multilanguage Level1 Template Problem...

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

Page: 1
Go to End
Author Topic: 938 Views
  • Ironcheese
    Avatar
    Community Member
    33 Posts

    Multilanguage Level1 Template Problem... Link to this post

    Hello everyone.

    I'm new to SilverStripe. For some days now, i'm trying to solve a multilanguage issue in my templates.

    Let me explain:
    I'm using for all my Level1 Pages the same template. In this template i have something like a header image which should be the same in its particular section. I did this with the "Level(1).URLSegment" and it worked great in one language! But as soon I change the language the URL changes aswell and my image src breaks.

    What I need is a function which returns the Level1 URLSegment of my default Language. Which would be "en_US" in my case.
    So for example: There is a "service" Section in which are pages like Contact, Imprint, Sitemap and so on. The function should return always "service" in this section regardless of the current selected Language. I need the “MasterTranslationID”, or better: the URLSegment of the MasterPage.

    I have rudimentary knowledge of PHP and OOP and I think the solution is somewhere around "Translatable::getTranslationGroupID" function. But i lack the deeper insight to connect all this into a working function. :S

    I hope you understand my english and - more important: my problem

    Thanks in advance.
    You people here are doing an incredible job, i learned so much from this forum already =)

    cheers,
    Alex

  • Ironcheese
    Avatar
    Community Member
    33 Posts

    Re: Multilanguage Level1 Template Problem... Link to this post

    Hey folks,

    i finally managed to solve this specific problem

    public function getEnglishMasterPage(){
                
          $mypage = DataObject::get_by_id('SiteTree', Translatable::getTranslationGroup());
          
          if($this->URLSegment != 'Security'){
             return $mypage->Level(1)->URLSegment;
          }else{
             return 'service';
          }
          
       }


    The if statement is in there because without the site breaks when accessing the login page. Not sure why though.

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