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.

Template Questions /

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

Multilanguage Level1 Template Problem...

Go to End

2 Posts   1297 Views


Community Member, 36 Posts

27 May 2010 at 9:16am

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 :D

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



Community Member, 36 Posts

28 May 2010 at 6:20am

Hey folks,

i finally managed to solve this specific problem :D

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

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