GetSimple Support Forum
GS functions inside a js file? - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11)
+--- Thread: GS functions inside a js file? (/showthread.php?tid=4454)



GS functions inside a js file? - kennylovesyou - 2013-03-13

Apologies if I've posted this in the wrong board.

I'm looking for some information on how I can use GSCMS functions inside a js file.

My js file is located within mytheme:

gscms
-theme
--mytheme
--myfile.js
---assets
----images
-----picture.jpg

Currently I'm trying to load an image inside my js file which references the image as "/assets/images/picture.jpg"

The problem is that the paths inside js aren't relative to the file location but the page loaded.
ie. GSCMS tries to load "siteurl/assets/images/picture.jpg" instead of "siteurl/theme/themefolder/assets/images/picture.jpg"

My question is, is it possible to include the <?php get_theme_url(); ?> function inside a js file?

Has anyone every tried this?


RE: GS functions inside a js file? - shawn_a - 2013-03-13

It would probably be better to define a js variable in your theme head.

<script>...

var theme_root = '<?php get_theme_url(); ?>';

</script>