Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GS functions inside a js file?
#1
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?
Reply
#2
It would probably be better to define a js variable in your theme head.

<script>...

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

</script>
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)