X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   JavaScript in Category/Product Description? (https://forum.x-cart.com/showthread.php?t=11633)

1day2004 01-21-2005 06:42 PM

JavaScript in Category/Product Description?
 
The Category Description and Product Descriptions are not allowing me to add JavaScript. Everytime I add JS and save it, the screen refreshes with an empty description box. I've tried it with and without literal tags.

Anyone got any ideas what I'm doing wrong?

Version 4.0.8

Ginestra 01-26-2005 05:02 AM

Ah hah, might be able to help. Spent a long time on an identical problem, and, if this is documented then it's very, very well hidden.

Sure, the Trusted variables fix ( http://forum.x-cart.com/viewtopic.php?t=13682&sid=773e50d2983433efb0fd8d0c 38af9ea3 ) works for html code, but X-Cart is still ripping out other stuff, <Script> included.

Adding this:

define('USE_TRUSTED_SCRIPT_VARS',1);

to the two files mentioned in the above post will have you smiling. Sure, there are security issues if you don't entirely trust any providers who might have access, but, as far as I can see, there are no issues otherwise.

Hope this helps

1day2004 01-26-2005 05:08 PM

Thanks for the response.

This is what I have right now:

Code:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng_descr","product_lng_full_descr","product_new_descr","product_new_full_descr","descr","fulldescr","posted_data","js_code","javascript_code");


Should I change it to this?:

Code:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng_descr","product_lng_full_descr","product_new_descr","product_new_full_descr","descr","fulldescr","posted_data","js_code","javascript_code");

define('USE_TRUSTED_SCRIPT_VARS',1);
$trusted_script_variables = array("descr","fulldescr");


I'm new to x-cart so I just want to make sure I'm inputting the code correctly.

Ginestra 01-26-2005 10:53 PM

No, you don't need that second line, just:


define('USE_TRUSTED_SCRIPT_VARS',1);

So, you'll end up with:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng_descr","product_lng_full_descr" ,"product_new_descr","product_new_full_descr","des cr","fulldescr","posted_data","js_code","javascrip t_code");
define('USE_TRUSTED_SCRIPT_VARS',1);

X-Cart is just looking for the variable to be defined, so it would seem, you don't have to then specify the string.

1day2004 01-27-2005 12:47 AM

I just applied the changes...it's working perfect! :D

Thanks for your help.

Ginestra 01-27-2005 12:58 AM

Glad to be able to help for once. This really should be documented, IMO. Cheers.

Debra 05-20-2006 02:21 PM

I know this is an old post, so I hope that someone will reply! I want to be able to put this in the product description:
Code:

{if $active_modules.Extra_Fields ne ""}
{include file="modules/Extra_Fields/product.tpl"}
{/if}

I tried the fix for the html and it works great but I am still having problems. Here is what I have changed for

provider/product_modify.php
Code:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng","product_new_descr","product_new_full_descr","descr","fulldescr","posted_data","js_code","javascript_code", "param00");
define('USE_TRUSTED_SCRIPT_VARS',1);


admin/product_modify.php
Code:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng","product_new_descr","product_new_full_descr","descr","fulldescr","posted_data","js_code","javascript_code", "param00");
define('USE_TRUSTED_SCRIPT_VARS',1);


So basically all I added was param00 and define('USE_TRUSTED_SCRIPT_VARS',1);. Is there something I am missing?

firelight 05-24-2006 02:08 PM

Javascript in Category Description
 
Hi,
I tried to modify the two files: admin/product_modify.php and provider/product_modify.php with the following code:
Code:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng_descr","product_lng_full_descr","product_new_descr",
"product_new_full_descr","descr","fulldescr","posted_data","js_code",
"javascript_code");
define('USE_TRUSTED_SCRIPT_VARS',1);

The description/code still dissapears when I save the changes in my category description.

Am I doing something wrong here? :?
Thanks in advance for the help.

Xcart 4.0.18

firelight 05-24-2006 02:28 PM

Ok, I think I found it.
I changed the admin/category_modify.php by adding the following:
Code:

define('USE_TRUSTED_SCRIPT_VARS',1);
to have this as result:
Quote:

define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("category_lng_description","category_new_des cription","description");
define('USE_TRUSTED_SCRIPT_VARS',1);

This definately allowed me to insert javascript in the category description.

Any input is still very welcome because I'm not a programmer.

Thanks.

rapsearch 10-05-2009 01:20 AM

Re: JavaScript in Category/Product Description?
 
Hi,

I'm also upping this old thread as i could not find a newer version.

I have the same issue, i wish to embed audio previews in the detailer description field.

I've modified admin and provider/product_modify.php with the code
so i have:

PROVIDER
define("NUMBER_VARS", "shipping_freight,price,list_price,weight");
define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng","product_new_descr","product_n ew_full_descr","descr","fulldescr","posted_data"," js_code","efields","javascript_code","param00");
define('USE_TRUSTED_SCRIPT_VARS',1);

&
ADMIN
define("NUMBER_VARS", "shipping_freight,price,list_price,weight");
define('USE_TRUSTED_POST_VARIABLES',1);
$trusted_post_variables = array("product_lng","product_new_descr","product_n ew_full_descr","descr","fulldescr","posted_data"," js_code","efields","javascript_code","param00");
define('USE_TRUSTED_SCRIPT_VARS',1);

But after saving it still ends up blank.. ideas?


All times are GMT -8. The time now is 11:20 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.