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

#   Ajax file custom field display

##

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

Less More

- Posts: 431
- Thank you received: 22
-

1 year 10 months ago [\#364749](#364749) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#364749 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")* was created by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")*

-- HikaShop version -- : 5.1.2
-- Joomla version -- : 5.2
-- PHP version -- : 8.3.3

Im using product custom field Ajax file for audio mp3 file. Two problems:

1. If I enter in Format for each file field Code:

&lt;audio controls&gt; &lt;source src="images/audiosample/{value}" type="audio/mpeg" /&gt; Your browser does not support the audio tag. &lt;/audio&gt;

the "controls" audio tag is removed after saving the field.

2. How to show that field in template layout override for product?
If I use Code:

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

only the value is in html output.
Is there a way to show formated field?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDg5MzItYWpheC1maWxlLWN1c3RvbS1maWVsZC1kaXNwbGF5P3RtcGw9bWFya2Rvd24=) 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: 86285
- Thank you received: 14263
-
-

1 year 10 months ago [\#364753](#364753) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#364753 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Hi,

1. Thank you for your feedback. I've made a patch to better handle this. Download again the install package of HikaShop on our website and install it on yours to get the patch.

2. Yes. We've covered this here for example:
[ www.hikashop.com/forum/product-category-...t-layout.html#339434](https://www.hikashop.com/forum/product-category-display/903971-get-text-of-custom-field-in-product-layout.html#339434)

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

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

Less More

- Posts: 431
- Thank you received: 22
-

1 year 10 months ago [\#364771](#364771) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#364771 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

1. OK now.
2. So solution for audio player for ajax file custom field:
In view override place (where "audiotest" is custom field column name) Code:

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

In format for each file field place code like Code:

&lt;div class="media-preview"&gt;&lt;p&gt;Audio preview&lt;/p&gt;&lt;audio controls&gt; &lt;source src="images/audiosample/{value}" type="audio/mpeg" /&gt; Your browser does not support the audio tag. &lt;/audio&gt;&lt;/div&gt;

Where images/audiosample is folder for your audio files.
And final result is
[ ![audio-files.jpg](/forum/attachment/60056) ](/forum/attachment/60056 "audio-files.jpg")

This is game changer for custom fields. Thank you Hikashop!

- [ ![audio-files.jpg](/forum/attachment/60056) ](/forum/attachment/60056 "audio-files.jpg") [ ](/forum/attachment/60056?download=1 "audio-files.jpg")

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

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

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

Less More

- Posts: 431
- Thank you received: 22
-

1 year 6 months ago [\#366489](#366489) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366489 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Nicolas, please help on this.
When viewing a product, I would like to allow customers to directly listen to audio files if they are logged in and have access. The file download works, but the stream does not.
This is the code I am using in the show_block_product_files.php override.
Code:

&lt;div id="hikashop_product_files_main" class="hikashop_product_files_main"&gt; &lt;?php if(!empty($this-&gt;element-&gt;files)) { $user = JFactory::getUser(); $files = array(); foreach($this-&gt;element-&gt;files as $file) { if(empty($file-&gt;download_link)) continue; if(empty($file-&gt;file_name)) $file-&gt;file_name = $file-&gt;file_path; $attributes = ''; if(!empty($this-&gt;element-&gt;product_canonical) &amp;&amp; strpos(hikashop_currentURL(),$this-&gt;element-&gt;product_canonical) &amp;&amp; !empty($user-&gt;guest)) { $attributes .= ' rel="nofollow"'; } $files[] = '&lt;a'.$attributes.' class="hikashop_product_file_link d-none" href="' . $file-&gt;download_link . '"&gt;' . $file-&gt;file_name . '&lt;/a&gt;&lt;br/&gt;&lt;audio controls&gt;&lt;source src="' . $file-&gt;download_link . '" type="audio/mpeg"&gt;Vaš brskalnik ne podpira predvajanja zvočnih datotek.&lt;/audio&gt;&lt;br/&gt;&lt;a href="' . $file-&gt;download_link . '" class="file-download-link" download&gt;Prenesi datoteko&lt;/a&gt;'; } if(count($files)) { ?&gt; &lt;fieldset class="hikashop_product_files_fieldset"&gt; &lt;legend&gt;&lt;?php echo JText::_('DOWNLOADS'); ?&gt;&lt;/legend&gt; &lt;?php echo implode('&lt;br/&gt;', $files); ?&gt; &lt;/fieldset&gt; &lt;?php } } ?&gt; &lt;/div&gt;

I assume the mp3 preview plugin does not have this option?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDg5MzItYWpheC1maWxlLWN1c3RvbS1maWVsZC1kaXNwbGF5P3RtcGw9bWFya2Rvd24=) 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: 86285
- Thank you received: 14263
-
-

1 year 6 months ago [\#366492](#366492) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366492 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Hi,

I don't see a problem with that. It could be a problem with your server setup.
Could you provide the URL of the page with the issue so that I can look deeper into it ?

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

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

Less More

- Posts: 431
- Thank you received: 22
-

1 year 6 months ago -  1 year 6 months ago [\#366499](#366499) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366499 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Here is the link, but you must login first to see the player.
This message contains confidential information

Here you can see working preview
This message contains confidential information

Last edit: 1 year 6 months ago by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDg5MzItYWpheC1maWxlLWN1c3RvbS1maWVsZC1kaXNwbGF5P3RtcGw9bWFya2Rvd24=) 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: 86285
- Thank you received: 14263
-
-

1 year 6 months ago [\#366501](#366501) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366501 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Hi,

So could you provide a test user account so that I could check it ?

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

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

Less More

- Posts: 431
- Thank you received: 22
-

1 year 6 months ago -  1 year 6 months ago [\#366509](#366509) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366509 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Sure

Last edit: 1 year 6 months ago by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDg5MzItYWpheC1maWxlLWN1c3RvbS1maWVsZC1kaXNwbGF5P3RtcGw9bWFya2Rvd24=) 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: 86285
- Thank you received: 14263
-
-

1 year 6 months ago [\#366510](#366510) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366510 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

It seems the MP3 file you're using on this product is corrupted.
Some players, like VLC can handle corrupted files up to a point. But the players of browsers are more sensitive.

You can use [ checkmate.gissen.nl/](https://checkmate.gissen.nl/) to check your MP3 files.
If you do, you'll see that it detects that MP3 file as broken, but the MP3 file from your other link as valid.

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

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

Less More

- Posts: 431
- Thank you received: 22
-

1 year 6 months ago [\#366523](#366523) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Ajax file custom field display](/forum/26-product-category-display/908932-ajax-file-custom-field-display#366523 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2 -- PHP version -- : 8.3.3  Im using product custom field Ajax file for audio mp3 file. Two problems:  1. If I enter in Format for each file field  the &quot;controls&quot; audio tag is removed after saving the field.  2. How to show that field in template layout override for product? If I use  only the value is in html output. Is there a way to show formated field?")*

Thanks. It looks like I have quite a few corrupted files. Apparently a result of copying from an old disk.

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

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

[](#top)
