We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Accessing Config file data from main.volt template (layout)

Hi,

I'm trying to access an attribute in my phalcon config file.

For example in the config.ini I have got the following code:

[website] title = website_title

I would like to access title from main.volt in the views->layout please.

I have already added the config to the di using the following:

$config = new Phalcon\Config\Adapter\Ini(DIR . '/../app/config/config.ini'); $di = new \Phalcon\DI\FactoryDefault();

$di->set('config', $config);

I can access the config in the views easily and it does work as follwo:

{{ config.website.title }}

but when I use the same in the main.volt it doesn't get the value and it's just blank.

Would you please help?

Thanks a lot



10.9k

Could you just clarify what view it does work in?

I can access the config in the views easily and it does work..