We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

php vars declared on header only work on header not on footer and content

Development and Programming

brainbrain.es's avatar
brainbrain.es
9 posts
14 years ago
brainbrain.es's avatar brainbrain.es

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

       
Ian from Aus's avatar
Ian from Aus
94 posts
14 years ago
Ian from Aus's avatar Ian from Aus

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.