Hi Nicolas
I try to explain my code
We have categories and subcategories.
As you can see in attachment this is how i set the menu item Products
The layout in the frontend is a customized version of listing and listing_img_description
The parent category has a custom field named 'fotoprodottosecondario' and i get it as follows
$fieldsClass = hikashop_get('class.field');
$fields = $fieldsClass->getFields('frontcomp', $this->row, 'category');
foreach ($fields as $fieldName => $oneExtraField) {
if ($oneExtraField->field_namekey == 'fotoprodottosecondario'):
//echo $fieldsClass->show($val,$this->row->$key);
$tags = $fieldsClass->show($oneExtraField, $this->row->$fieldName);
preg_match('@src="([^"]+)"@', $tags, $match);
$src = array_pop($match);
$fotoprodotto = substr($src, 0, strpos($src, '/thumbnail_x'));
endif;
}
and I put the result in
<img src="<?php echo $fotoprodotto; ?> " onerror="this.onerror=null;this.src='<?php echo $default ?>';" alt="<?php echo $this->row->category_name; ?>" class="product-image">
First question: How can I get the full image without using function substr ?
Then for every child categories I have to get again its image in custom field 'fotoprodottosecondario' in this way
$fields2 = $fieldsClass->getFields('frontcomp', $child, 'category');
foreach ($fields2 as $childFieldName => $childOneExtraField) {
if ($childOneExtraField->field_namekey == 'fotoprodottosecondario'):
$tags = $fieldsClass->show($childOneExtraField, $child->$childFieldName);
preg_match('@src="([^"]+)"@', $tags, $match);
$src = array_pop($match);
$fotogrid = $src;
endif;
}
and I put it here
<img src="<?php echo $fotogrid; ?>" onerror="this.onerror=null;this.src='<?php echo $default ?>';" alt="Product image" class="product-image">
Any further suggestions?
Thanks in advance