Post by alfaone78 » Tue Jan 15, 2013 9:07 pm

Hi,

first sorry for my bad english!
Hi have developed a module for opencart. this is like information module but i need to view an image near link.
I' ve added this code in the controller part(catalog side) of the module:

Code: Select all

	
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
in the index function

Code: Select all

protected function index($setting)
but i don' t know how retrieve the $setting array.

Some people can help me?
thanks a lot

C U

Newbie

Posts

Joined
Tue Jan 15, 2013 8:31 pm

Post by almix » Sun Oct 26, 2014 4:51 am

me interesting too! alfaone78, did you find where is $setting array?

Newbie

Posts

Joined
Thu Jun 20, 2013 11:58 pm

Post by uksitebuilder » Sun Oct 26, 2014 5:35 am

$this->config->get('SETTING_NAME');

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by straightlight » Sat Nov 22, 2014 10:53 pm

The $this->config->get object is set initially from index.php file as a current setting and not as a module tracking. The $setting array passed into the index method is the one initialized whenever the current module is loaded at that point in the loop. The $setting object should be initialized automatically by ensuring that the same basic key names are being added from the admin modules before loading the array on the store-front end. Additional key names can be added along with the basic key names as there should be no problem to re-catch those additional keys by using the $setting array either. This methodology should not interfere with other modules nor with other basic key names since each $setting array are being fetched accordingly from the database.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by justcurious » Thu Nov 27, 2014 4:29 pm

The function you are calling (resize) takes three parameters - image url, width and height. It takes this information and creates a "copy" of the original image at the dimensions specified.

Thee are several image sizes in the "settings" table any of which you can get by using the line of code suggested by UKSitebuilder.

Or, if you know the size that you want the image to be, you can use constants eg:

Code: Select all

$image = $this->model_tool_image->resize($result['image'], 250, 250);

Google Product Feed - Get your products into Google Shopping. Includes a bulk update facility.
Backup Pro - Backup (on demand or scheduled), Restore and Clone your store.
Freestyle Box - Add multiple information boxes on multiple pages of your store. Includes optional "Code Mode".
View my other extensions


User avatar
Active Member

Posts

Joined
Sat Dec 24, 2011 4:36 pm
Location - UK

Post by fido-x » Sun Nov 30, 2014 9:22 pm

alfaone78 wrote:Hi,

first sorry for my bad english!
Hi have developed a module for opencart. this is like information module but i need to view an image near link.
I' ve added this code in the controller part(catalog side) of the module:

Code: Select all

 
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
in the index function

Code: Select all

protected function index($setting)
but i don' t know how retrieve the $setting array.

Some people can help me?
thanks a lot

C U
The $setting array is loaded through the index function and contains an array of settings for that instance of the module. These are then retrieved in the front-end module controller through $setting[''SETTING_NAME']. These settings are defined in the module in the back-end (admin).

To use the image resize function, you need to load the model first:

Code: Select all

$this->load->model('tool/image');

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: No registered users and 15 guests