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

custom config file loaded - then data disappears

Development and Programming

Jayson Ng's avatar
Jayson Ng
67 posts
15 years ago
Jayson Ng's avatar Jayson Ng

So I have loaded a custom config file in my class __construct().

$this->EE->config->load('custom_config');

It’s working well in the control panel area of the site.

But now that I’m working with my templates, the config item seems to have disappeared off of the config object.

when PRE’d within the template

<pre>
$this->EE->config
</pre>

<p>
</pre>

there is no mention of the loaded config file.

why so?

       
Derek Jones's avatar
Derek Jones
7,561 posts
15 years ago
Derek Jones's avatar Derek Jones

Can you give some more context? Which class file? What do you mean “working with my templates” - is this front end or back end, and are you talking about ExpressionEngine’s templates, or something your own add-on is using?

       
Jayson Ng's avatar
Jayson Ng
67 posts
15 years ago
Jayson Ng's avatar Jayson Ng

I created my own library class that is autoloaded.

in the library class -

class my_class {

    function my_class()
    {
        $this->EE =& get_instance();
        
        // Load config items
    $this->EE->config->load('my_custom_config');

        echo '<pre>';
        print_r($this->EE->config);
        echo '</pre>

<p>’;
    }</p>

<pre><code>function test()
{
    echo '<pre>';
    print_r($this->EE->config);
    echo '</pre>';
}

}</pre>

this code will print the “my_custom_config” file items when loaded.

however, if accessed within a template (and template group) i created in EE

via this code

$this->EE->my_class->test();

none of the custom config files are loaded. (or maybe overwritten?)

       
Derek Jones's avatar
Derek Jones
7,561 posts
15 years ago
Derek Jones's avatar Derek Jones

Er, are you not the same Jayson that filed this bug report where we discussed this?

       
Jayson Ng's avatar
Jayson Ng
67 posts
15 years ago
Jayson Ng's avatar Jayson Ng

yes i am, but that report is different from this.

the previous one, I mistakenly assumed that EE would be able to autoload custom config files. knowing that I can’t, I now load my config file manually in the __construct() of my custom library - like so.

$this->EE->config->load('my_custom_config');

The problem now however, is that even though I loaded it manually, it still disappears later on…

*** re-reading your comment on the last bug report ***

ok, so I probably didn’t understand what you mentioned in the last bug report correctly - are you saying, that in the initialization of a class, a default config file is passed to it, clearing all config items possibly on it? (in this case, my custom loaded config file?)

       
Derek Jones's avatar
Derek Jones
7,561 posts
15 years ago
Derek Jones's avatar Derek Jones

No, not with a class specifically, but anything that loads to settings to the Config class prior to site preferences being set will be lost. Where is the library being loaded?

       
Jayson Ng's avatar
Jayson Ng
67 posts
15 years ago
Jayson Ng's avatar Jayson Ng

library is loaded using autoload.php - i guess that’s why my config file disappears. :O

       
Derek Jones's avatar
Derek Jones
7,561 posts
15 years ago
Derek Jones's avatar Derek Jones

Yep, linking to your feature request to close the loop.

       

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.