user stylesheets and colorset stylesheets

Skinning and designing Serendipity (CSS, HTML, Smarty)
User avatar
Don Chambers
Regular
Posts: 3614
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: user stylesheets and colorset stylesheets

Post by Don Chambers » Sat Feb 27, 2016 8:30 pm

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.

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: user stylesheets and colorset stylesheets

Post by Timbalu » Sat Feb 27, 2016 9:33 pm

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.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
Don Chambers
Regular
Posts: 3614
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: user stylesheets and colorset stylesheets

Post by Don Chambers » Sat Feb 27, 2016 9:49 pm

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...

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: user stylesheets and colorset stylesheets

Post by Timbalu » Sun Feb 28, 2016 11:35 am

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';
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
Don Chambers
Regular
Posts: 3614
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA
Contact:

Re: user stylesheets and colorset stylesheets

Post by Don Chambers » Sun Feb 28, 2016 5:56 pm

That seems to work now! Thanks! I am still playing around with it a little but will post the final code segments soon.

Post Reply