Post by MikaelSampoerna » Sat May 09, 2015 12:44 am

Hi everyone,

I try to creating a simple image module. To the point, the only problem is data is not saved/not loaded everytime I visit this module back. Here's my code in controller:

Code: Select all

if (isset($this->request->post['photo_image'])) {
	$photo_images = $this->request->post['photo_image'];
} elseif (isset($this->request->get['photo_image'])) {
	$photo_images = $this->model_module_photo->getProductImages($this->request->get['photo_image']);
	//$photo_images = $this->model_catalog_product->getProductImages($this->request->get['photo_image']);
	//$photo_images = $this->request->get['photo_image'];
} else {
	$photo_images = array();
}

$data['photo_images'] = array();

foreach ($photo_images as $photo_image) {
	if (is_file(DIR_IMAGE . $photo_image['image'])) {
		$image = $photo_image['image'];
		$thumb = $photo_image['image'];
	} else {
		$image = '';
		$thumb = 'no_image.png';
	}

	$data['photo_images'][] = array(
		'image'      => $image,
		'thumb'      => $this->model_tool_image->resize($thumb, 100, 100)
	);
}
I'm not sure about isset($this->request->get['photo_image']) code above. Because I took from product images controller.
Someone can help me figured it out? Thanks


Posts

Joined
Sun Nov 23, 2014 10:58 pm

Post by IP_CAM » Sat May 09, 2015 1:25 am

No error message, no error log, nothing?
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by MikaelSampoerna » Sat May 09, 2015 10:11 am

Nope, everything works without any error. No data returns when I need to edit this.
Previously, I build another module with single type of field, everything was ok.
Do we need kind of ID for multiple data rows/foreach function?
Thanks


Posts

Joined
Sun Nov 23, 2014 10:58 pm

Post by qart » Sun May 17, 2015 1:45 am

may be the following will help you,

Code: Select all

$this->load->model('extension/module');

if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
	$module_info = $this->model_extension_module->getModule($this->request->get['module_id']);
}

$this->load->model('module/photo');

if (isset($this->request->post['photo_image'])) {
   $photo_images = $this->request->post['photo_image'];
} elseif (!empty($module_info) {
   $photo_images = $this->model_module_photo->getProductImages($module_info['photo_image']);
} else {
   $photo_images = array();
}

.........................

Qart OpenCart Extensions

Xmod -||- Xbar -sticky navbar -||- Ajax Search -||- Brands -||- Modals -||- Linkat


New member

Posts

Joined
Sun May 03, 2015 4:02 am
Who is online

Users browsing this forum: No registered users and 7 guests