Soldato
- Joined
- 12 Feb 2006
- Posts
- 17,628
- Location
- Surrey
i'm using opencart 1.40 and have come across a simple problem. i posted this on their forums but it's extremely slow to get a response and feel i'd get more help posting here. i've pretty much copy and pasted the thread i made so hope it makes enough sense. althoug it's for opencart, it's just simple a bit of php so should be ok.
from opencart thread:
i'm trying to show the manufacturer image rather then their name on the product page. i'm trying to edit the files and i'm so so close but last bit is beating me and i need help.
here is what i have (with what i think is not needed removed)
i added this to model/manufacuter.php page...
then on controller/product.php page added this...
print_r($manu); shows the exact string i want, which is the location of the image, great as then i guess my database query is fine, but on the template page i want it i'm stuck and it doesn't work, which i assume is down to me incorrectly doing something e.g. treating an array as a string
on view/product.tpl page i have the 3 following lines to try see if either will make a difference
print_r shows: Array ( [0] => Array ( [image] => d ) )
echo $manu shows the word Array,
echo $manu['image'] shows error message saying undefined call to...
where am i going wrong? sure it must be so simple and i just have one/two things slightly incorrect.
many thanks
from opencart thread:
i'm trying to show the manufacturer image rather then their name on the product page. i'm trying to edit the files and i'm so so close but last bit is beating me and i need help.
here is what i have (with what i think is not needed removed)
i added this to model/manufacuter.php page...
PHP:
public function getManufacturerImg($manufacturer_name) {
$query = $this->db->query("SELECT image FROM " . DB_PREFIX . "manufacturer WHERE name = '" . $manufacturer_name . "'");
return $query->row;
}
then on controller/product.php page added this...
PHP:
$this->load->model('catalog/manufacturer');
$manu = $this->model_catalog_manufacturer->getManufacturerImg($product_info['manufacturer']);
print_r($manu);
$this->data['manu'] = array();
foreach ($manu as $manus) {
$this->data['manu'][] = array(
'image' => $manus['image']
);
}
print_r($manu); shows the exact string i want, which is the location of the image, great as then i guess my database query is fine, but on the template page i want it i'm stuck and it doesn't work, which i assume is down to me incorrectly doing something e.g. treating an array as a string
on view/product.tpl page i have the 3 following lines to try see if either will make a difference
PHP:
<?php print_r($manu); ?>
<?php echo $manu; ?>
<?php echo $manu['image']; ?>
echo $manu shows the word Array,
echo $manu['image'] shows error message saying undefined call to...
where am i going wrong? sure it must be so simple and i just have one/two things slightly incorrect.
many thanks