Posts: 29
Threads: 5
Joined: May 2012
2013-08-18, 07:43:47
(This post was last modified: 2013-08-18, 16:31:25 by rpetges.)
Hi,
My HTML5 theme is based on the SkelJS frontend framework and basic configuration is done in an external Javascript file.
Example for static HTML:
window._skel_config = {
preset: 'standard',
prefix: 'css/style',
resetCSS: true
};
Within GetSimpleCMS, I need however to put the full path from the root of the hosting space for the prefix variable :
window._skel_config = {
preset: 'standard',
prefix: '/cms/theme/mytheme/css/style', ( or
http://www.mydomain.com/cms/theme/mytheme/css/style )
resetCSS: true
};
I don't understand why I do need to put the complete path when code is served by GetSimple.
I would prefer relative paths, but all my tests so far failed.
Many thanks for your help,
Romain
Posts: 3,491
Threads: 106
Joined: Mar 2010
Maybe this?
prefix: '<?php get_theme_url(); ?>/css/style',
Posts: 29
Threads: 5
Joined: May 2012
Thanks for the suggestion.
Javascript files are read on the client side and PHP code is server based ... this won't work.
Romain
Posts: 3,491
Threads: 106
Joined: Mar 2010
2013-08-18, 18:17:24
(This post was last modified: 2013-08-18, 18:56:55 by Carlos.)
Where is that js file located?
If it's in another theme subfolder (e.g. /cms/theme/mytheme/js/), could this work?
prefix: '../css/style',
Posts: 29
Threads: 5
Joined: May 2012
The filesystem structure is the following one :
/cms/theme/mytheme/js <-- config.js is located here
/cms/theme/mytheme/css <--- styles inside this folder cannot be loaded
I also tried the ../ option and it does not work.
Romain
Posts: 104
Threads: 6
Joined: Aug 2013
Maybe not the best solution but you could try to declare a javascript variable just before loading the config.js and then pass that variable to prefix.
PHP Code:
#Set variable before loading the config.js (inside your template file)
var ThemeStyleAbsPath = '<?php get_theme_url(); ?>';
#Pass variable to config.js
window._skel_config = {
preset: 'standard',
prefix: ThemeStyleAbsPath + '/css/style',
resetCSS: true
};
Posts: 3,491
Threads: 106
Joined: Mar 2010
2013-08-19, 16:39:43
(This post was last modified: 2013-08-19, 23:09:01 by Carlos.)
(2013-08-19, 14:03:41)rpetges Wrote: The filesystem structure is the following one :
/cms/theme/mytheme/js <-- config.js is located here
/cms/theme/mytheme/css <--- styles inside this folder cannot be loaded
I also tried the ../ option and it does not work.
If Kolyok's solution doesn't work, you could put your styles and config.js file in the same folder (
js or
cs, or a new one, e.g.
assets), and then just use:
prefix: 'style',
[edit] fixed typo.
Posts: 6,266
Threads: 181
Joined: Sep 2011
Are you using relative to your source document, not your js file ?
Relative urls should work.
Like kolyok said, you have to define inline somewhere before your config inits.
Posts: 29
Threads: 5
Joined: May 2012
Sorry for the late reply.
The solution from Kolyok works great !
Many thanks for your help, it's much appreciated.
Romain