Jump to content

Make Array in variable global


BlackSwan

Recommended Posts

Hey guys,

I would like to offer my VA Site in multiple languages. I created a new LangData.class.php. Everything works fine, The function Lang($pilot) returns the array $lang. When I define on any template $lang = LangData::Lang($pilot); or inside the module $this->set('lang', LangData::Lang($pilot)); it works perfectly fine. But I want to make the variable $lang accesable globaly, without having to set the variable in all modules or templates. I tried to set the variable inside the layout.php, because it covers all templates as the top file, but in that way I can only echo the array inside layout.php.

I use simpilot 5.5.2 

Here is my code for LangData.class.php:

<?php
/////////////////////////////////////////////////
///   Langugage Package by GermanExpress VA   ///
///         Author germanexpressva.de         ///
///            Packed at 06/08/2019           ///
///  Copyright (c) 2019, germanexpressva.de   ///
/////////////////////////////////////////////////

class LangData extends CodonData {
	
	public static function Lang($pilot) {
		
		//GERMAN
		if($pilot->lang == 'de') {
			$lang = array(
				'TEST_TITLE'		=>		'testtextde'
			);
		//ENGLISH AS STANDARD
		} else {
			$lang = array(
				'TEST_TITLE'		=>		'testtexten'
			);
		};
		
		return $lang;
		
	}
}
?>

 

Thanks in advance,
Tolga

Edited by BlackSwan
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...