Hellow, my problem comes because i´m developing a multi language site, so i use php includes for change titles and texts of static contents. I created a folder lang with es.php, en.php and de.php and load one of this depends the language by url segment. The problem is the php vars only works on header and doesn´t work in the rest of page.
Example:
header:
<?php $info=”{last_segment}”; switch ($info) { case “en”: $lang=”_en”; include(“lang/en.php”); break;
case “de”: $lang=”_de”; include(“lang/de.php”); break;
default : $lang=”“; include(“lang/es.php”); } ?>
and for example en.php contains $about=’We are a company…..’; if i put <?=$about;?> on header works correctly but if i put on any template or on a footer page doesn´t work and show me a php error:
“A PHP Error was encountered
Severity: Notice
Message: Undefined variable: about”
Who can i solve this???????
Thanks
The PHP in EE templates is processed by the PHP eval() function, which means that those variables only exist in the scope of that eval() statement, which is that single template. You would need to have that same block to include the relevant PHP file on each template which requires translation. I highly recommend investigating another way.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.