Post by haosmark » Wed Dec 26, 2012 5:28 am

I'm trying to save and retrieve settings, but it isn't working out. I keep getting this error:
Notice: Undefined property: Config::$get in C:\UwAmp\www\opencart\admin\controller\design\banner.php on line 66
This is what my code is like:

Code: Select all

    private function saveNivoSettings() {
        $this->load->model('setting/setting');
        $posted_data = $this->request->post;

        //extract titles
        for($i=0; $i < sizeof($posted_data['banner_image']); $i++) {
            $titles[] = $posted_data['banner_image'][$i]['banner_image_description'][1]['title'];
        }
        //extract speed
        for($i=0; $i < sizeof($posted_data['effect_speed']); $i++)
            $nivo_settings[$titles[$i] . '-speed'] = $posted_data['effect_speed'][$i];

        //extract labels
        for($i=0; $i < sizeof($posted_data['effect_label']); $i++)
            $nivo_settings[$titles[$i] . '-label'] = $posted_data['effect_label'][$i];

        $this->model_setting_setting->editSetting('nivoslider', $nivo_settings);

        die($this->config->get['next-banner-speed']);
    }
This creates an associative array with titles (galaxy-tab-speed, other-stuff-speed, other-stuff-label) and values for those titles. Then I save it to nivoslider settings, but when I try to retrieve the setting by its title I get an error.
What am I doing wrong here?

New member

Posts

Joined
Wed Oct 10, 2012 1:59 am

Post by Johnathan » Wed Dec 26, 2012 9:59 am

$this->config->get() is a function, not an array, so it needs regular parentheses and not square brackets. So your code would need to be:

Code: Select all

$this->config->get('next-banner-speed')
If you want to comply with standard OpenCart conventions, you should also note that settings use underscores, not hyphens, and are prefixed with the group of settings that it involves. (For example, slideshow_next_banner_speed)

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by haosmark » Wed Dec 26, 2012 10:54 am

Thank you, it works now.

New member

Posts

Joined
Wed Oct 10, 2012 1:59 am

Post by straightlight » Mon Dec 31, 2012 6:23 am

A small correction to the above regarding $this->config->get(); get() is not a function but rather a method being called from system/library/config.php file.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by rph » Mon Dec 31, 2012 3:27 pm

That's splitting hairs a bit. A method is just a function in OOP.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by Johnathan » Mon Dec 31, 2012 10:52 pm

I just called it a function because if you look in the /system/library/config.php file, it says public function get(). :)

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by straightlight » Mon Dec 31, 2012 11:32 pm

Yes, I understand. Although, the identification from the class is called a function but the nature of this function is called a method since it is amongst a constructor.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 2 guests