Page 3 of 3

Re: user stylesheets and colorset stylesheets

Posted: Sat Feb 27, 2016 7:30 pm
by Don Chambers
yellowled wrote:I did not follow all your code, but that might mean that the colorset stylesheet is not included using serendipity_printStylesheet because that is the function in serendipity.css.php which replaces {TEMPLATE_PATH} with the actual path.
You are correct.
Timbalu wrote:Right. Since outside the normal routine, you need to do this on your own in this case...
Yep. Works. Didn't realize this would be a simple str_replace - thought {TEMPLATE_PATH} was some kind of constant or variable....
Timbalu wrote:[...] and set it like this

Code: Select all

$template_global_config = array('navigation' => true);
$template_loaded_config = serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option'], true);
$serendipity['template_loaded_config'][$serendipity['template']] = $template_loaded_config; // copy into global scope for extended plugin API usage
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
Then one theme config could not accidently overwrite another.
Is the accidental overwrite really a risk?

Additionally - that code didn't work, but this earlier suggestion does work (notwithstanding any risk to overwriting another theme):

Code: Select all

$template_global_config = array('navigation' => true);
$serendipity['template_loaded_config'] = $template_loaded_config = serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option'], true);
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
All other themes that load stylesheets other than style.css use syntax url ('img/file.jpg') instead of url ('{TEMPLATE_PATH}'/img/file.jpg'). Keeping in mind that this code is contained exclusively within this theme, and is not part of s9y, I decided it would be more consistent to replace img/:

Code: Select all

$tfilecontent = str_replace('img/', 'templates/' . $serendipity['template'] . '/img/', @file_get_contents($tfile));
....rather than replacing {TEMPLATE_PATH} as suggested:

Code: Select all

        $tfilecontent = str_replace('{TEMPLATE_PATH}', 'templates/' . $serendipity['template'] . '/', @file_get_contents($tfile));
This would allow the colorset stylesheets to be used in a more traditional manner via <link...> should there be a need to do so. I may change my opinion on this prior to releasing the theme, so I would appreciate any opinions.

Re: user stylesheets and colorset stylesheets

Posted: Sat Feb 27, 2016 8:33 pm
by Timbalu
Don Chambers wrote:thought {TEMPLATE_PATH} was some kind of constant or variable....
never...
Don Chambers wrote:Is the accidental overwrite really a risk?
Can't really say .. but it is definitely better to make it an inner array by template name. You'll also never know if $serendipity['template_loaded_config'] wont be used for something (in future).
Don Chambers wrote:that code didn't work
I assume you did not replace the others to $serendipity['template_loaded_config'][$serendipity['template']]... else nothing essential has changed with it.

Re: user stylesheets and colorset stylesheets

Posted: Sat Feb 27, 2016 8:49 pm
by Don Chambers
Timbalu wrote:I assume you did not replace the others to $serendipity['template_loaded_config'][$serendipity['template']]... else nothing essential has changed with it.
Which others? There was only one instance of that in the theme's config.inc.php...

Re: user stylesheets and colorset stylesheets

Posted: Sun Feb 28, 2016 10:35 am
by Timbalu
In set

Code: Select all

$serendipity['template_loaded_config'][$serendipity['template']] = $template_loaded_config; // copy into global scope...
and get.

Code: Select all

$colorset_file = dirname(__FILE__) . '/' . $serendipity['template_loaded_config'][$serendipity['template']]['colorset'] . '_style.css';

Re: user stylesheets and colorset stylesheets

Posted: Sun Feb 28, 2016 4:56 pm
by Don Chambers
That seems to work now! Thanks! I am still playing around with it a little but will post the final code segments soon.