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

#   Display Custom Field

##

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 11 months ago [\#337323](#337323) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337323 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")* was created by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")*

-- HikaShop version -- : 4.4.4
-- Joomla version -- : 3.10.3
-- PHP version -- : 7.4
-- Browser(s) name and version -- : Chome

Hi.
For some reason, I want to manually display my categories Ajax image extrafield.

My extrafield name is "img2"
and I used an image named "tree.jpg" for example

when I put the code
$this-&gt;element-&gt;img2;

I the file name correctly but I need the full path of image to as the src of my img tag.

how can I get the extrafield with correct tag and not plain file name ??

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDM1MzYtZGlzcGxheS1jdXN0b20tZmllbGQ/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

4 years 11 months ago [\#337329](#337329) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337329 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Hi,

Supposing we're talking about a custom field of the table "category", you need code like that: Code:

&lt;?php $fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('img2', 'category'); echo $fieldClass-&gt;show($field,$this-&gt;element-&gt;img2); ?&gt;

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 11 months ago [\#337331](#337331) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337331 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Thank you.

I put this code in "listing_img_title.php" file and got the following error :

0 - Call to undefined method hikashop::show()

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDM1MzYtZGlzcGxheS1jdXN0b20tZmllbGQ/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

4 years 11 months ago [\#337332](#337332) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337332 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Hi,

I don't see how the code I gave can generate that error message.
Either you made a typo, or the error comes from somewhere else.
Please double check.
And if you don't see the problem, please activate the debug system setting of the Joomla configuration and try again. You'll get an error with more information on what's going on. In that case, please also provide a screenshot of the modification you've made.

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 11 months ago [\#337356](#337356) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337356 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

I checked the code multi times.

the error refers to the third line of the code :
echo $fieldClass-&gt;show($field,$this-&gt;element-&gt;img2);

when I comment this code, error message disappears

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 11 months ago [\#337357](#337357) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337357 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

I turned on debug system and atached the screenshot :

- [ ![2021-11-24&#95;3-41-52.png](/forum/attachment/53914) ](/forum/attachment/53914 "...24&#95;3-41-52.png") [ ](/forum/attachment/53914?download=1 "...24&#95;3-41-52.png")

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 11 months ago [\#337358](#337358) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337358 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

That was a kiddy mistake by me ... the code worked perfect. thank you.

my last question is can i use this code for product page as well by replacing the field name and changing 'category' to 'product' ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDM1MzYtZGlzcGxheS1jdXN0b20tZmllbGQ/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

4 years 11 months ago [\#337362](#337362) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337362 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Hi,

Well, it depends what you mean.
If you want to display the value of a custom field of the table "category" for the category of the current product, it's possible but you need to leave "category" in that code. Instead you want to change Code:

$this-&gt;element

by Code:

$this-&gt;categories[0]

If you want to display the value of a custom field of the table "product" for the current product, it's possible and you indeed need to change "category" to "product". However, if your product has variants, $this-&gt;element will point to the default variant of the product and $this-&gt;element-&gt;main will point to the main product. So you might need to change that, or make it dynamically use main or not based on weither it's there or not.

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 11 months ago [\#337364](#337364) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#337364 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Thanks alot.

Everything is solved

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

4 years 4 months ago [\#342411](#342411) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#342411 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Hi Nicolas.

Previously you sent this great piece of code to me which was very useful to display custom fields.

Now i have a problem.
when using product variants, when I change the characteristic, the value of displayed custom field doesnt change the way it changes when using default custom fields layout.

is there any solution for that problem as well ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDM1MzYtZGlzcGxheS1jdXN0b20tZmllbGQ/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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14271
-
-

4 years 4 months ago [\#342416](#342416) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Display Custom Field](/forum/26-product-category-display/903536-display-custom-field#342416 "-- HikaShop version -- : 4.4.4 -- Joomla version -- : 3.10.3 -- PHP version -- : 7.4 -- Browser(s) name and version -- : Chome  Hi. For some reason, I want to manually display my categories Ajax image extrafield.  My extrafield name is &quot;img2&quot; and I used an image named &quot;tree.jpg&quot; for example  when I put the code $this-&gt;element-&gt;img2;  I the file name correctly but I need the full path of image to as the src of my img tag.  how can I get the extrafield with correct tag and not plain file name ??")*

Hi,

There is, but it's more complex.
You need to wrap your custom field in a div with an id starting with hikashop_product_ and ending wih _main

You also need to loop on the $this-&gt;element-&gt;variants array to call $fieldClass-&gt;show on each element and wrap each HTML around a div with a display:none on it, an id which is similar to the main div but with the id of each value for the current variant instead of "main". I would recommend to do this in product / show as there is already a loop for all the rest of the variant data there with the variable $variant_name you can use instead of calculating the ids of the variants yourself.

And lastly, you need to modify the javascript in product / show_block_characteristic to add to this array Code:

var names = ['id','name','code','image','price','quantity','description','weight','url','width','length','height','contact','custom_info','files'];

the text you have between hikashop_product_ and _main in the id of the main div.

So it's totally possible but instead of 1 line of code at one place, you need several lines in several places.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDM1MzYtZGlzcGxheS1jdXN0b20tZmllbGQ/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.139 seconds

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

[](#top)
