I was trying to call jquery.scrollTo.js which I know is in the core c5 installation and I tried following 2 methods (adding a controller.php file and adding my code to header_required.php) without sucess. Eventually I got it working by putting scrollTo in 'mythemeroot'/js/jquery.scrollTo.js and adding this to the header.php
It would also be really handy to know how to do this so if you could provide a quick example that would be great. I'm schooled in html/css but am not very up on php so please give full syntax if possible.
for that code to work, the file has to be in
if you are pulling from a package,
yo do the code like this:
and it pulls from /packages/pkghandle/js or /css
for blocks if there is a css or js folder it will be auto included
I'm having a little trouble getting this to work. Where would I place this code in the header.php file, before or after
Also what is the syntax that wraps either side of your script, just a simple php tag or a <script> tag?
c5installdir/concrete/js (the file is here by default)
but no success. Here's my full code, any idea where I've gone wrong?
I think you can just do this, though:
(make sure that's after Loader::element('header_required') though -- because it relies on jquery already being loaded)
If that doesn't work, just use your original method -- nothing wrong with that (plus, it lets you keep your js file in c5installdir/themes/mytheme/js instead of c5installdir/js, which means all of your theme files are kept in one place).
The reason I'm trying to use c5's scrollTo.js is that its in the core installation so any updates will be installed automatically when I update c5.
I have a small problem with using my original code
<?php echo $this->getThemePath()?>/js/jquery.scrollTo.js">
as it appears to remove the # links on the page (Its a one page website which uses scrollTo for navigating to the relevant areas eg mythemedir/#page1, mythemedir/#page2 etc.
I think this has something to do with the php bringing in the theme path so maybe an alternative would be to pull in scrollTo from an outside url. Any thoughts on this?
Unfortunately I've never used scrollTo so I'm not sure why it would or wouldn't be working properly.
As an alternative to the above it would be also possible to bring the latest version of the plugin in from an external url eghttp://code.google.com. As I'm fairly new to c5 I'm not sure which method is best to use.
1) The Loader::helper() and addHeaderItem() PHP code is not wrapped in PHP tags.
2) There is no need to put the addHeaderItem() code inside a <script> tag. The addHeaderItem() method itlself adds to the document head a script tag that references an external JS file.
I appreciate any help!