Page 1 of 1

Products modules auto ignore video tag

Posted: Thu Jul 27, 2023 9:44 am
by duyquyen1710
I have a problem with Products module
When i write to Details field of Item products, every html tags working ok but video tags like: iframe, video, embed are ignored. After i click save they're disappeared. May be Products module auto ignore video tags.
How to insert youtube video to Details fied of Products module? Thank you very much!

Re: Products modules auto ignore video tag

Posted: Thu Jul 27, 2023 1:03 pm
by velden
What about adding a custom field for the Youtube video ID and creating the needed html (iframe, embed, video) in the detail template.
You can make it conditionally (so only if the field has a value).

Think that would have multiple benefits. Like you can change that templated html-code in the future.

Re: Products modules auto ignore video tag

Posted: Fri Jul 28, 2023 6:05 am
by duyquyen1710
Thank you for your help Velden! Your method i've already used, but it's not flexible because the video is inserted at fixed position in detail tempalte, before or after {$entry->details}. I'm looking for method to insert video tags without ignore of Products module.

Re: Products modules auto ignore video tag

Posted: Fri Jul 28, 2023 2:49 pm
by velden
I think I should have started with a warning: the Products module is abandoned bij it's developer. Consider this if starting with this module.

Flexibility could be added by using two 'details' fields; one before an optional video and one after.

Another option would be to create a UDT (user-defined tag) which provides an editor with a simple method to insert a Youtube video.
E.g.

Code: Select all

blabla {Youtube id=mCXQ6vJ1Enw} blabla
or

Code: Select all

blabla {Youtube url=https://youtu.be/mCXQ6vJ1Enw} blabla
I stand by the fact that I think you should be able to change the video code when for example YouTube decides it should be completely different. You then don't want to change it in 1000 product details.

BTW: are you sure this behavior is Products-module specific? Or is it the wysiwyg editor doing it? What happens when you add such code to a normal page for example?

Re: Products modules auto ignore video tag

Posted: Fri Jul 28, 2023 7:55 pm
by Dr.CSS
Have you tried eval..?

Re: Products modules auto ignore video tag

Posted: Fri Jul 28, 2023 8:34 pm
by velden
Eval shouldn't be of any help in this case. That's for Smarty, not for disappearing html.

Re: Products modules auto ignore video tag

Posted: Fri Jul 28, 2023 8:57 pm
by DIGI3
The WYSIWYG will strip out tags, but depending on which one you're using you may be able to add specific tags to the whitelist. Velden's idea of a plugin or UDT is probably a better one though.

Re: Products modules auto ignore video tag

Posted: Mon Jul 31, 2023 2:11 am
by duyquyen1710
Thanks for your help Velden and Dr.CSS and DIGI3!
I think this behavior is Products-module specific because when i turn off Micro Tiny (Select WYSIWYG to use to none), the video tags are still removed. Another pages video tags working ok.
In my case, i have about 1000 products. With each product i have 0, 1,2 or more videos to describe it and they can be inserted anywhere in product details.
I am currently using the method create there Fields youtube1, youtube2, youtube3 and make it conditionally to be appear
I'm not a coder so there something i don't understand, i make website for my own not for another to use. More than 10 years a go, i've choice cmsms because the text "made simple". And now, i still feel happy with that choice :) !

Re: Products modules auto ignore video tag

Posted: Tue Aug 01, 2023 8:49 am
by creopard
velden wrote: Fri Jul 28, 2023 2:49 pm Another option would be to create a UDT (user-defined tag) which provides an editor with a simple method to insert a Youtube video.
I followed that approach to lazy load YouTube videos (due to cookie law and GDPR).
Using the following JavaScript that does the HTML formatting: https://github.com/creopard/lazy-load-youtube-videos
and a new UDT like

Code: Select all

{youtube_link_lazy id='bDuXLQjaocE'}
UDT "youtube_link_lazy" source code:

Code: Select all

$id = isset($params['id']) ? $params['id'] : '';
if ( !empty($id) ) {
	echo '<div class="wrapper"><div class="llyv" data-id="'.$id.'"></div></div>';
}

Re: Products modules auto ignore video tag

Posted: Fri Aug 11, 2023 4:24 am
by duyquyen1710
I've found solution. I add a textarea field (custom field), and textarea field don't trip out video tag. It's so simple I didn't think. Thank you very much!