Jump to content

Script Not Running In .tpl File


seancss

Recommended Posts

Hi,

I have tried using a simple script using JQuery that acts as a crossfade image changer i have tested it

in a standard html and it work fine, i'm relatively new to prestashop and have used the search to do some digging but still can't find a solution im sure its a simple fix for someone in the know,

 

Script below is in the header of header.tpl

 

I have checked the file permissions and set them all to 777 to eliminate that problem, I have checked the paths to the following files and all are correct and bring up the script or image, i have also tried

{literal} and {/literal} before and after the script below is there something im missing? as I said it works outside of presta.

 

 

All I get is the page displaying the DIV cross-fade which is just and empty space but not animation or images.

 

Thanks.

 

 

 

 

 

 

 

<head>

 

 

 

 

{if $page_name == 'index'}

 

 

<script src="{$content_dir}themes/mysite/js/slideshow/jquery-1.7.1.min.js"></script>

<script src="{$content_dir}themes/mysite/js/slideshow/jquery.cross-slide.min.js"></script>

 

 

{literal}

<script>

$(function() {

$('#cross-fade').crossSlide({

sleep: 3,

fade: 1

}, [

{ src: '{$content_dir}themes/mysite/img/crossfade/one.jpg' },

{ src: '{$content_dir}themes/mysite/img/crossfade/two.jpg' },

{ src: '{$content_dir}themes/mysite/crossfade/three.jpg' },

 

])

});

</script>

 

{/literal}

 

 

{/if}

 

 

 

</head>

 

 

In the body

 

 

{if $page_name == 'index'}

 

<div id="cross-fade"></div>

{/if}

Link to comment
Share on other sites

Can anyone at least tell me if this "should" work, as I said i'm new to prestashop and have done some digging the only thing I can see myself doing wrong is not adding {literal} which I have done, again all the file locations are correct is there a security feature of sorts in Prestashop that i'm missing that does not allow certain scripts to run, anyhelp would be great.

Link to comment
Share on other sites

Solved, still not 100% which problem it was but I got the correct combination now, with {literal} tags around my script it will not work, also {$content_dir} where I defined the images stupidly this had not been defined yet, at the beginning I had the full path hardcoded which would have worked so overlooked this when I added these variables in again and used proper form to call my image paths, also I changed some options in the backend regarding java this again may have added to the number of reasons the script would not run.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...