mruz / base-app

The base application in PhalconPHP
63 stars 19 forks source link

PHP siteLangs error #28

Closed amsharma9 closed 10 years ago

amsharma9 commented 10 years ago

Hi,

I am using the latest version now, although the site works but I keep getting the following errors in my PHP error log. Is there any way to remove it. Its a single error.

PHP Notice:  Undefined variable: siteLangs in C:\Wamp\www\myapp\app\common\cache\volt\app\frontend\views\index.phtml on line 73
...
PHP Warning:  Invalid argument supplied for foreach() in C:\Wamp\www\myapp\app\common\cache\volt\app\frontend\views\index.phtml on line 73

Thanks Amal

mruz commented 10 years ago

Hi, Do you have in the IndexController initialize():

// Send langs to the view
$this->view->setVars(array(
    // Translate langs before
    'siteLangs' => array_map('__', $this->config->i18n->langs->toArray())
));

and in the /app/common/config/config.ini config file:

[i18n]
lang = "en-gb"
dir = ROOT_PATH"/app/common/i18n/"
langs[en-gb] = "English"
langs[pl-pl] = "Polish"
amsharma9 commented 10 years ago

Sorry for the late reply. All above code in present both the files you mentioned. First code is the last two-three lines of initialize() and the other code is in the config.ini.

mruz commented 10 years ago

Please try setVar() instead of setVars():

$this->view->setVar('siteLangs', array_map('__', $this->config->i18n->langs->toArray()));

or move it to afterExecuteRoute.

amsharma9 commented 10 years ago

Moving it to afterExecuteRoute solved the issue, first solution still gives original error.