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

#   Add custom-field to product /listing\_img\_title.php

##

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

Less More

- Posts: 22
- Thank you received: 0
-
-

9 years 10 months ago [\#260317](#260317) by [kenny.kang](/forum/user/39538-kenny-kang "View kenny.kang's Profile")  *[Add custom-field to product /listing\_img\_title.php](/forum/32-content-creation/888454-add-custom-field-to-product-listing-img-title-php#260317 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.5 -- PHP version -- : 5.5  I want to add custom-filed display in listing&#95;img&#95;title.php I have added the following code in php , but can't display $this-&gt;element-&gt;myfield , always empty  what else code do I need to add!!  foreach ($this-&gt;fields as $fieldName =&gt; $oneExtraField) { $value = ''; if(empty($this-&gt;element-&gt;$fieldName) &amp;&amp; !empty($this-&gt;element-&gt;main-&gt;$fieldName))$this-&gt;element-&gt;$fieldName = $this-&gt;element-&gt;main-&gt;$fieldName; if(isset($this-&gt;element-&gt;$fieldName)) $value = trim($this-&gt;element-&gt;$fieldName); if(!empty($value)){ $hide&#95;specs = 0; break; } }")* was created by *[kenny.kang](/forum/user/39538-kenny-kang "View kenny.kang's Profile")*

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.5

I want to add custom-filed display in listing_img_title.php
I have added the following code in php , but can't display $this-&gt;element-&gt;myfield , always empty

what else code do I need to add!!

foreach ($this-&gt;fields as $fieldName =&gt; $oneExtraField) {
$value = '';
if(empty($this-&gt;element-&gt;$fieldName) &amp;&amp; !empty($this-&gt;element-&gt;main-&gt;$fieldName))$this-&gt;element-&gt;$fieldName = $this-&gt;element-&gt;main-&gt;$fieldName;
if(isset($this-&gt;element-&gt;$fieldName))
$value = trim($this-&gt;element-&gt;$fieldName);
if(!empty($value)){
$hide_specs = 0;
break;
}
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODg4NDU0LWFkZC1jdXN0b20tZmllbGQtdG8tcHJvZHVjdC1saXN0aW5nLWltZy10aXRsZS1waHA/dG1wbD1tYXJrZG93bg==) 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
-
-

9 years 10 months ago [\#260323](#260323) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Add custom-field to product /listing\_img\_title.php](/forum/32-content-creation/888454-add-custom-field-to-product-listing-img-title-php#260323 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.5 -- PHP version -- : 5.5  I want to add custom-filed display in listing&#95;img&#95;title.php I have added the following code in php , but can't display $this-&gt;element-&gt;myfield , always empty  what else code do I need to add!!  foreach ($this-&gt;fields as $fieldName =&gt; $oneExtraField) { $value = ''; if(empty($this-&gt;element-&gt;$fieldName) &amp;&amp; !empty($this-&gt;element-&gt;main-&gt;$fieldName))$this-&gt;element-&gt;$fieldName = $this-&gt;element-&gt;main-&gt;$fieldName; if(isset($this-&gt;element-&gt;$fieldName)) $value = trim($this-&gt;element-&gt;$fieldName); if(!empty($value)){ $hide&#95;specs = 0; break; } }")*

Hi,

The variable $this-&gt;element contains the data of the main category of the listing.
So if your listing is displaying the products of the category X, $this-&gt;element will contain the data of that category X.
If you want the data of the product being displayed, you'll find it in $this-&gt;row
So the code should be $this-&gt;row-&gt;myfield instead of $this-&gt;element-&gt;myfield

Such code should do it: Code:

&lt;?php echo $this-&gt;row-&gt;myfield; ?&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODg4NDU0LWFkZC1jdXN0b20tZmllbGQtdG8tcHJvZHVjdC1saXN0aW5nLWltZy10aXRsZS1waHA/dG1wbD1tYXJrZG93bg==) 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.049 seconds

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