+ Reply to Thread
Results 1 to 5 of 5

Thread: Adding Custom Javascript...

  1. #1

    Adding Custom Javascript...

    Hello,

    Happy Holidays To Everyone!

    Hope everyone had a great holiday!

    I have achieved a lot of progress, figured out the header issue I was having -- now I have another question regarding javascript. How do I put javascript into the templates? Meaning, I have tried putting some js code into the head.tpl, but if I put it as is (with <script> </script> tags, I get errors. If I put {literal} {/literal} tags around the code, I get no errors, but I don't get the code functioning. I also wouldn't mind if you could tell me about external css, I don't *think* that is the issue, but it might be...I am guessing it is js issue only. Meaning, I created a folder inside my general_wide folder called 'slider' put all my css and js code there and the path from my content.tpl file is: ../slider/css/ or ../slider/js/ -- Please help me with this. I am pretty sure the paths are correct, but maybe wrong?

    Thank you
    Brian
    Last edited by Brian Jester; December 27, 2017 at 09:06 PM.

  2. #2
    Guru
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    2,028
    Quote Originally Posted by Brian Jester View Post
    How do I put javascript into the templates? Meaning, I have tried putting some js code into the head.tpl,
    https://www.flynax.com/plugins/verification-code.html ? will this work for you ?

  3. #3
    Pete,

    Pete, I contacted support to ask them if I need to add a script tag for the code I used in the verification plugin. Ex: I called the code in the verification plugin slider, so do I need to add a <script> tag to the head.tpl for it to take affect?

    I just looked into their reply email, and they mentioned to add the {literal} {/literal} tags before the <script> </script> tags. I already tried that prior to installing the verification code plugin, and like I said, it did get rid of the js errors, but still no good when actually executing the js code. Maybe a different script? Or is this something else (internal with flynax - path issues) causing do you think?


    I am going to download that and try it...I will post back once I try it.

    Tried it but it does not work: (

    Here's the website of the script I am trying to add:

    Code:
    Only registered members can view the code.
    I've added the js and css files to the following path:
    Code:
    Only registered members can view the code.
    Code:
    Only registered members can view the code.
    I have added the relative paths to the associated css and js files using relative paths like:
    Code:
    Only registered members can view the code.
    and
    Code:
    Only registered members can view the code.
    One last thing I am going to try is using absolute paths instead of relative paths such as: http://localhost/flynax/etc../etc..

    Edit: Still not working after changing to absolute paths, however, I did make one change and I now know that the css path is correct because for the div that outputs the slider, I have changed the background to black and it comes out on the page as a black backgroud, that much I know, but now the javascript.

    Thank you!
    Brian
    Last edited by Brian Jester; December 28, 2017 at 04:31 AM.

  4. #4
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,138
    Quote Originally Posted by Brian Jester View Post

    I have achieved a lot of progress, figured out the header issue I was having -- now I have another question regarding javascript. How do I put javascript into the templates? Meaning, I have tried putting some js code into the head.tpl, but if I put it as is (with <script> </script> tags, I get errors. If I put {literal} {/literal} tags around the code, I get no errors, but I don't get the code functioning. I also wouldn't mind if you could tell me about external css, I don't *think* that is the issue, but it might be...I am guessing it is js issue only. Meaning, I created a folder inside my general_wide folder called 'slider' put all my css and js code there and the path from my content.tpl file is: ../slider/css/ or ../slider/js/ -- Please help me with this. I am pretty sure the paths are correct, but maybe wrong?

    Brian
    Hello,

    - you should use {literal} {/literal} tags inside the script tags like this:

    Code:
    Only registered members can view the code.

    - if you need to attach some css file in your tpl you should use <link> tag specifying absolute path to your css file,
    you can use a smarty variable {$rlTplBase} which contains a path to your template folder + path to your css file:

    Code:
    Only registered members can view the code.
    the same for js files:

    Code:
    Only registered members can view the code.

  5. #5
    Quote Originally Posted by Rudi View Post
    Hello,

    - you should use {literal} {/literal} tags inside the script tags like this:

    Code:
    Only registered members can view the code.

    - if you need to attach some css file in your tpl you should use <link> tag specifying absolute path to your css file,
    you can use a smarty variable {$rlTplBase} which contains a path to your template folder + path to your css file:

    Code:
    Only registered members can view the code.
    the same for js files:

    Code:
    Only registered members can view the code.
    Rudi,

    Thank you very much for your help! Even though the problem was my lack of reading, I appreciate your code above, as I am sure it will help me and others down the line...

    In case you would like to know, it was in the script itself, the js code that goes directly in the webpage, I had to comment out the second part:

    Code:
    Only registered members can view the code.
    Thank you again Rudi!
    Brian

+ Reply to Thread