[Skip to main content](#vessel-content)

#   Custom fields placement in category listing.

##

- **[coffee](/forum/user/4796-coffee "View coffee's Profile")**
- [![coffee's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4796-coffee "View coffee's Profile") Topic Author
- [ Offline](/forum/user/4796-coffee)

Less More

- Posts: 6
- Thank you received: 1
-
-

3 years 11 months ago -  3 years 11 months ago [\#347768](#347768) by [coffee](/forum/user/4796-coffee "View coffee's Profile")  *[Custom fields placement in category listing.](/forum/26-product-category-display/905588-custom-fields-placement-in-category-listing#347768 "-- 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&#95;img&#95;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 &quot;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")* was created by *[coffee](/forum/user/4796-coffee "View coffee's Profile")*

-- 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

Code:

&lt;!-- CUSTOM PRODUCT FIELDS --&gt; &lt;?php if(!empty($this-&gt;productFields)) { foreach($this-&gt;productFields as $fieldName =&gt; $oneExtraField) { if(empty($this-&gt;row-&gt;$fieldName) &amp;&amp; (!isset($this-&gt;row-&gt;$fieldName) &#124;&#124; $this-&gt;row-&gt;$fieldName !== '0')) continue; if(!empty($oneExtraField-&gt;field_products)) { $field_products = is_string($oneExtraField-&gt;field_products) ? explode(',', trim($oneExtraField-&gt;field_products, ',')) : $oneExtraField-&gt;field_products; if(!in_array($this-&gt;row-&gt;product_id, $field_products)) continue; } ?&gt; &lt;dl class="hikashop_product_custom_&lt;?php echo $oneExtraField-&gt;field_namekey;?&gt;_line"&gt; &lt;dt class="hikashop_product_custom_name"&gt; &lt;?php echo $this-&gt;fieldsClass-&gt;getFieldName($oneExtraField);?&gt; &lt;/dt&gt; &lt;dd class="hikashop_product_custom_value"&gt; &lt;?php echo $this-&gt;fieldsClass-&gt;show($oneExtraField,$this-&gt;row-&gt;$fieldName); ?&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;?php } } ?&gt; &lt;!-- EO CUSTOM PRODUCT FIELDS --&gt;

Last edit: 3 years 11 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDU1ODgtY3VzdG9tLWZpZWxkcy1wbGFjZW1lbnQtaW4tY2F0ZWdvcnktbGlzdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

3 years 11 months ago [\#347770](#347770) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom fields placement in category listing.](/forum/26-product-category-display/905588-custom-fields-placement-in-category-listing#347770 "-- 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&#95;img&#95;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 &quot;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")*

Hi,

You can copy/paste that code in different places in the layout.
Then, after the line: Code:

foreach($this-&gt;productFields as $fieldName =&gt; $oneExtraField) {

you can add the code: Code:

if(!in_array($fieldName, array('XXX','YYY','ZZZ'))) continue;

where XXX, YYY and ZZZ are the column name of three fields you want to display in the current location.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDU1ODgtY3VzdG9tLWZpZWxkcy1wbGFjZW1lbnQtaW4tY2F0ZWdvcnktbGlzdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[coffee](/forum/user/4796-coffee "View coffee's Profile")**
- [![coffee's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4796-coffee "View coffee's Profile") Topic Author
- [ Offline](/forum/user/4796-coffee)

Less More

- Posts: 6
- Thank you received: 1
-
-

3 years 11 months ago [\#347785](#347785) by [coffee](/forum/user/4796-coffee "View coffee's Profile")  Replied by *[coffee](/forum/user/4796-coffee "View coffee's Profile")* on topic *[Custom fields placement in category listing.](/forum/26-product-category-display/905588-custom-fields-placement-in-category-listing#347785 "-- 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&#95;img&#95;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 &quot;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")*

Thank you so much Nicolas.

Worked like a charm.

Happy Holidays.

Denis

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDU1ODgtY3VzdG9tLWZpZWxkcy1wbGFjZW1lbnQtaW4tY2F0ZWdvcnktbGlzdGluZz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.053 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
