Adding Javascript to a Product Description

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi,

we are trying to add a javascript block inte the description of an product (like <script src=...></script>).

The script block will not be saved. Is this a feature or a bog and are there any options to insert a scriptblock in the product description?

Thanks for any idea...

Mario Stuck
7 years ago
TinyMCE in nopCommerce doesn't allow scripts tag.

Is it a universal script that should be shown in all product page? If so then your best bet is to insert it directly in VIEW.
7 years ago
Hi wooncherk,

no, this script block should only be inserted on some product pages in the description section.

So the solution with the view might not work.

Any other ideas?

Mario
7 years ago
You need to change the source. Try this: http://stackoverflow.com/questions/24614301/tinymce-inserting-script-tags
7 years ago
Hi,

I hoped to avoid editing the source code...

Good link - many thanks - I'll give it a try.

Best regards

Mario
7 years ago
Hi Mario,

You may have multiple problems in the future if you hard-coded JavaScript code in product description. For example, you need to change all the codes for all products at once. I'd suggest to modify your theme's product template and add generic JavaScript code there. You have all product information in that template and you can customize your script for a particular product using Razor syntax.
7 years ago
Why don`t you use templates as suggest @ilich_x86?
At your admin panel System >> Templates >> Product templates add new (for example ProductTemplate.SimpleScript), then at your theme made copy of the ProductTemplate.Simple.cshtml and save it with ProductTemplate.SimpleScript.cshtml, add required script to the code of new file.

Next, to each product which should have that script, just assign new template. If you would like to remove script from specific product, just apply default template at your admin panel. If you would like to change script, just open file and change it directly. Clean and easy way, without modify any source code. And to edit code, you need only open one file.

Regards,
Tomasz
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.