Can i get the download link of a custom file field? (Possible solution found)

  • Posts: 239
  • Thank you received: 29
  • Hikashop Business
7 years 3 months ago #287015

-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.8.4

Hi, sorry to bother you guys... again.
I try to implement an audio player in the view of product page (Display > View > show_block_custom_main).
This is my code:

<audio controls>
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
If i paste in the source this link (witch is the download link of the file uploaded in this custom field), it works:
/component/hikashop/order/download/field_table-product/field_namekey-YXVkaW9kZW1v/name-ZnVsbG1ldGFsLWFsY2hlbWlzdC1icm90aGVyaG9vZC1pbnRyby1zb3VuZC10cmFjay5tcDM=
But i want this to happen dinamicaly. How can i get this link in my code?
Frome what i see, i can get the name (witch is displayed in front end to) the price and others, but i don't see the link if i use print_r($this) or any variable..
I can't use the variable $value cuz it return to me the entire <a href > tag with link and the value to click on.

UPDATE
I've found a solution, i don't know if it's the best but for the moment those the trick for me.
Please let me know if there is a better solution.
My code:
<span>
<?php $audioSrc = new SimpleXMLElement($this->fieldsClass->show($oneExtraField, $value)); ?>
<audio controls>
   <source src="<?php echo $audioSrc['href'] ?>" type="audio/mpeg">
                Your browser does not support the audio element.
</audio>
</span>

Attachments:
Last edit: 7 years 3 months ago by oxido.

Please Log in or Create an account to join the conversation.

  • Posts: 83778
  • Thank you received: 13564
  • MODERATOR
7 years 3 months ago #287018

Hi,

No, it's a good solution. I would have said using regex to extract the href from the a tag, but it's basically the same.

Last edit: 7 years 3 months ago by nicolas.
The following user(s) said Thank You: oxido

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum