You are here:  » how to load external script inside pt

Support Forum



how to load external script inside pt

Submitted by tisbris on Wed, 2011-02-02 22:12 in

Hi David

I'm trying to implement a simple 5 rating ajax driven php script inside the product page.

This external script is working in a simple html demo page, but got into trouble when i place the code on the html/product.php.

I have spoked with the vendor of the rating script and he stated this:

"I'm not entirely sure how your script works, so i can't give you an exact solution, because I don't have it. Basically, I think the problem might be having to declare $SimpleRatings as global. It's not normally needed, unless you're trying to do something like this. So what you want to try is putting it somewhere BEFORE the create code for SimpleRatings. This is what the global statement should look like:

<?php
global $SimpleRatings;
?>

The proper place to place it might depend because of how the script might work. It will probably be inside a function though."

I have tryed to place the code in the products.php and html/product.php - but this isn't working.

I'm not asking for your help getting this script to work, but do I need to place this code elsewhere to make a external script working on the product page inside pt?

thank you

//Brian

Submitted by support on Thu, 2011-02-03 09:25

Hi Brian,

The code in html/product.php isn't within a function at all so the global statement shouldn't be required; but it may be the same thing I just mentioned to Paul regarding lightbox JavaScript.

If there is a .js file associated with your simple ratings script, make sure that it is included with a full path, e.g.

<script type='text/JavaScript' src='/ratingscript/myratingsscript.js'>

(where /ratingscript/ is the folder where you saved the JavaScript file on your website)

Otherwise, if your product pages are re-written as /product/Product-Name.html unless the src attribute of the script tag begins / the browser won't know where to find the file...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com