Re: jQuery & js on Home Page
Quote:
Originally Posted by
3DPeruna
Using 1.3g, I'm trying to get some jQuery modules (Novis slider). loaded on the HOME page. They're working just fine on other pages, but the home page seems to be difficult.
I've tried the template/override method unsuccessfully. jQuery loads just fine, but using Firebug and clicking on the jquery.module.js brings up the root site's home page--that is I see the HTML for the root index.php page (Zen Cart is installed at
http://www.example.com/store).
So, I've tried hard coding, using relative paths, etc. Just wondering if there's something terribly obvious I'm missing with regard to getting these things to work on the HOME page.
Any suggestions?
If you add jscript_ to the front and place the script file in your template script folder it will load and run on every page...site wide. includes\templates\YOUR_TEMPLATE\jscript\jscript_jquery.module.js
If you called to it differently on other pages, be sure to remove the calls or it will load a second time.
Re: jQuery & js on Home Page
Dave,
Yes... I know that. I don't want it on every page, just the front page. Like I said, I've got other javascript loading on the other pages as it's supposed to. It's getting something to load ONLY on the home page that I'm struggling with.
Re: jQuery & js on Home Page
How about being a LOT more specific about what EXACTLY you're trying to do?
Re: jQuery & js on Home Page
It's not too complicated. I'd like to get the Nivo jQuery slider working on the FRONT page only (but I'm open to other sliders, too).
I've got the script showing up in the header - that part is working just fine. View page source and the script shows as loaded. Sort of.
In the includes/modules/pages/index/jscript_index.php file I have the following:
Code:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="jquery.nivo.slider.pack.js"></script>
.
jquery-1.5-min.js loads just fine. But the slider doesn't work - I get a javascript error, the kind you get when your .js file isn't working. Clearly the script isn't working, and it doesn't appear to be loading. The weird part is that it shows up in both IE and Firebug under scripts, but when I click to look at it (like I can with the main jQuery .js file), it shows a page with the following tag in the title:
Code:
<title>Nothing found for Store Jquery Nivo Slider Pack Js</title>
So, how do I get the Nivo slider script to actually load?
Re: jQuery & js on Home Page
New Info:
Just to make sure I knew it was a path/loading issue, I pasted the script into my html_header.php file with some PHP wrapped around it make sure it only loads on the home page. The script works just fine. It's a path/loading issue.
Re: jQuery & js on Home Page
Well, you're not specifying a path to your nivo.slider.pack.js file. That could explain why it's not getting loaded.
As for loading *only* on the home page, wrap some PHP code around those 2 lines to check whether $is_home_page is true or not, and only load if it's true.
Re: jQuery & js on Home Page
Yep... that was it. I changed it to the following:
PHP Code:
<script type="text/javascript" src="includes/modules/pages/index/jquery.nivo.slider.pack.js"></script>
and all is happy! Thank you!