- Posts: 6
- Thank you received: 1
Custom fields placement in category listing.
3 years 10 months ago - 3 years 10 months ago #347768
by coffee
Custom fields placement in category listing. was created by coffee
-- HikaShop version -- : 4.7.0
-- Joomla version -- : 4
-- PHP version -- : 8.1
-- Browser(s) name and version -- : firefox latest
Hi,
I'm using business version and on the category listing for products I have a number of custom fields.
I found the file associated with the view (listing_img_title) and in it is the code (see bottom of posting)
which calls the custom fields.
However it puts them in a block and I'd like to be able to split them up. So I looking for a way to keep the backend options for displaying the fields (ie "Display in listing etc) but be able to put individual fields elswhere in the layout.
I've done this on the product page but can't work out the code changes needed for the listing.
Thanks for any help
Denis
-- Joomla version -- : 4
-- PHP version -- : 8.1
-- Browser(s) name and version -- : firefox latest
Hi,
I'm using business version and on the category listing for products I have a number of custom fields.
I found the file associated with the view (listing_img_title) and in it is the code (see bottom of posting)
which calls the custom fields.
However it puts them in a block and I'd like to be able to split them up. So I looking for a way to keep the backend options for displaying the fields (ie "Display in listing etc) but be able to put individual fields elswhere in the layout.
I've done this on the product page but can't work out the code changes needed for the listing.
Thanks for any help
Denis
Code:
<!-- CUSTOM PRODUCT FIELDS -->
<?php
if(!empty($this->productFields)) {
foreach($this->productFields as $fieldName => $oneExtraField) {
if(empty($this->row->$fieldName) && (!isset($this->row->$fieldName) || $this->row->$fieldName !== '0'))
continue;
if(!empty($oneExtraField->field_products)) {
$field_products = is_string($oneExtraField->field_products) ? explode(',', trim($oneExtraField->field_products, ',')) : $oneExtraField->field_products;
if(!in_array($this->row->product_id, $field_products))
continue;
}
?>
<dl class="hikashop_product_custom_<?php echo $oneExtraField->field_namekey;?>_line">
<dt class="hikashop_product_custom_name">
<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
</dt>
<dd class="hikashop_product_custom_value">
<?php echo $this->fieldsClass->show($oneExtraField,$this->row->$fieldName); ?>
</dd>
</dl>
<?php
}
}
?>
<!-- EO CUSTOM PRODUCT FIELDS -->
Last edit: 3 years 10 months ago by nicolas.
Please Log in or Create an account to join the conversation.
3 years 10 months ago #347770
by nicolas
Replied by nicolas on topic Custom fields placement in category listing.
Hi,
You can copy/paste that code in different places in the layout.
Then, after the line:
you can add the code:
where XXX, YYY and ZZZ are the column name of three fields you want to display in the current location.
You can copy/paste that code in different places in the layout.
Then, after the line:
Code:
foreach($this->productFields as $fieldName => $oneExtraField) {
Code:
if(!in_array($fieldName, array('XXX','YYY','ZZZ'))) continue;
Please Log in or Create an account to join the conversation.
3 years 10 months ago #347785
by coffee
Replied by coffee on topic Custom fields placement in category listing.
Thank you so much Nicolas.
Worked like a charm.
Happy Holidays.
Denis
Worked like a charm.
Happy Holidays.
Denis
The following user(s) said Thank You: nicolas
Please Log in or Create an account to join the conversation.
Time to create page: 0.068 seconds