• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using config item in language file

Is it possible to use a config item in a language file?

I have this in my application/config/config.php file:
$config['settings.tollfree']  = '00 800 4263 7393';

and in my application/languages/english/all_lang.php file:
$lang['call_us'] = "Please call us at ".$this->config->item('settings.tollfree').".";

When I run it, I get this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Lang::$config
Filename: english/all_lang.php
Line Number: 204 <-- this is the above line #

I am assuming this has to do with the order things are loaded in CI. Is there anything I can do about this? Any advice?

Thanks a million!

Here is a quick KLUDGE until you find a better solution.

// application/config/config.php
  const SETTINGS_TOLLFREE = '00 800 4263 7393';

  // application/languages/english/all_lang.php file:
  $lang['call_us'] = "Please call us at ".SETTINGS_TOLLFREE .".";

[eluser]Armchair Samurai[/eluser]
Here's another way to do it:

//In your language file
$lang['call_us'] = 'Please call us at %s.';

//When you need the string
printf($this->lang->line('call_us'), $this->config->item('settings.tollfree'));

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.