Brainstorming: What do we "need" template-wise?

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

Post by Don Chambers »

I cannot endorse the background color through the transparent portion for reasons I already stated - does not work well on non-rectangular images, and seriously limits the color options. I envision scenarios where I might want to do some fairly substantial graphic swaps, and this method cannot accomplish that. That being said, the options, at present, are few. The idea of hiding the foreground image, and replacing it with a background image, look more promising, but not without challenges. I think it might be easier to get some TPL's working for the offending plugins even if that takes awhile.

Meanwhile, I've been working on the assignment of additional variables through the selection of another one. Garvin has been a huge help here with my ignorance. Here is where I am and is only v1.1>. The first code bit is for config.inc.php, the remaining is as noted:

First, I offer the colorset choice:

Code: Select all

array(
        'var'           => 'colorset',
        'title'         => 'Color Set',
        'description'   => 'Select the color set you want to use',
        'type'          => 'select',
        'default'       => 'ltgrey',
        'select_values' => array('ltgrey' => 'Light_Grey', 'blue' => 'Blue', 'brown' => 'Brown')
    ),
Then we set additional variables:

Code: Select all

$defaults = array();
$current_vars = serendipity_loadThemeOptions($defaults); 

switch ($current_vars['colorset']){
    case 'ltgrey':
        $serendipity['smarty']->assign(array(
            'template_stylesheet'     => 'ltgrey_style.css',
            'template_back_arrow'     => 'img/ltgrey_back.gif',
            'template_forward_arrow'  => 'img/ltgrey_forward.gif',
            'template_xml_icon'       => 'img/ltgrey_xml.gif'));
        break;

    case 'blue':
        $serendipity['smarty']->assign(array(
            'template_stylesheet'     => 'blue_style.css',
            'template_back_arrow'     => 'img/blue_back.gif',
            'template_forward_arrow'  => 'img/blue_forward.gif',
            'template_xml_icon'       => 'img/blue_xml.gif'));
        break;

    case 'brown':
        $serendipity['smarty']->assign(array(
            'template_stylesheet'     => 'brown_style.css',
            'template_back_arrow'     => 'img/brown_back.gif',
            'template_forward_arrow'  => 'img/brown_forward.gif',
            'template_xml_icon'       => 'img/brown_xml.gif'));
        break;

    default:
        $serendipity['smarty']->assign(array(
            'template_stylesheet'     => 'ltgrey_style.css',
            'template_back_arrow'     => 'img/ltgrey_back.gif',
            'template_forward_arrow'  => 'img/ltgrey_forward.gif',
            'template_xml_icon'       => 'img/ltgrey_xml.gif'));
}
I am not yet fully committed to my defaults. Color changes obviously necessary for a given purpose. Not sure whether to make a colorset default, or to have basic "back.gif, forward.gif, xml.gif", etc. One thing is certain - I intend to slice up my css file so that the colorset options are in their own css, and the core is in style.css. I had been mis-led by a few of the themes into how this was supposed to work, as well as how {TEMPLATE_PATH} does not work in a linked stylesheet, but now, thanks go Garvin, I understand it. Here is that conversation: http://board.s9y.org/viewtopic.php?t=9094 The xml issue is still an unknown even though I am setting a variable with a value and not really using it just yet. The rest is as follows. In Index.tpl, using Dave's coffe cup 3 theme as an example, this code:

Code: Select all

{if $template_option.colorset == 'blue'}
<link rel="stylesheet" type="text/css" href="{serendipity_getFile file="blue.css"}" />
{elseif $template_option.colorset == 'cappuccino'}
<link rel="stylesheet" type="text/css" href="{serendipity_getFile file="cappuccino.css"}" />
{elseif $template_option.colorset == 'espresso'}
<link rel="stylesheet" type="text/css" href="{serendipity_getFile file="espresso.css"}" />
{else}
<!-- ****** Change default Colorset here ****** --> 
<link rel="stylesheet" type="text/css" href="{serendipity_getFile file="blue.css"}" />
{/if}
should be completely replaceable by this:

Code: Select all

<link rel="stylesheet" type="text/css" href="{serendipity_getFile file=$template_stylesheet}" />
Using the arrows in plugin_calendar.tpl (note: I had already removed the style= stuff and am styling that directly in css):

This:

Code: Select all

 <a title="{$CONST.BACK}" href="{$plugin_calendar_head.uri_previous}"><img alt="{$CONST.BACK}" src="{serendipity_getFile file="img/back.gif"}" /></a>
Becomes this:

Code: Select all

<a title="{$CONST.BACK}" href="{$plugin_calendar_head.uri_previous}"><img alt="{$CONST.BACK}" src="{serendipity_getFile file=$template_back_arrow}" /></a>
Same goes for the forward arrow. I am also using the arrow entries.tpl instead of "prev page" and "next page" - apparantly, I am the only one who thought that was a good idea so far! :P It works beautifully!!!

That is today's contribution.. works for me, if it can work for anyone else, great! I personally think BulletProof should include a colorset option just to demonstrate how it is done. Does not have to be anything fancy - perhaps just a background color or 2. Does not even have to include this latest code - just the initial array if necessary.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

I'm just thinking that even though Owen's code is proper, it might not be a good idea to include that in a template that might be used as a default theme.

The reason is that in the config.inc.php the call to loadThemeOpitons() is a call that will be performed twice then in the s9y API. That's a performance hit. For a custom, own template that's neglectible, but having it as a default / example theme, this might have an unnecessary hit.

I'm just thinking that these assignments could be made in the index.tpl smarty template instead of the config.inc.php. Because in index.tpl you already have the variables you need. Something like that in index.tpl:

Code: Select all

{if $template_option.colorset == 'grey'}
{assign name="xml_icon" value="icon_grey.gif}
...
{else}
...
{/if}
So we use the internal smarty 'assign' commands to put those variables. How about htat?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post by d_cee »

So anything is possible it seems!

Good work with your code Don - and of course Garvin !

I also think a couple of coloursets with the theme is a good idea - I said earlier in this thread I'll do a couple when I've got a minute :-)

Dave
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

garvinhicking wrote:Something like that in index.tpl:

Code: Select all

{if $template_option.colorset == 'grey'}
{assign name="xml_icon" value="icon_grey.gif}
...
{else}
...
{/if}
So we use the internal smarty 'assign' commands to put those variables. How about htat?
I tried your suggestion Garvin, and I want to get this matter put to bed once and for all. my observations and questions:

Code: Select all

<!-- set additional variables based on selected colorset -->
{if $template_option.colorset == 'grey'}
    {assign var="template_stylesheet"       value="ltgrey_style.css"}
    {assign var="template_back_arrow"       value="img/ltgrey_back.gif"}
    {assign var="template_forward_arrow"    value="img/ltgrey_forward.gif"}
    {assign var="template_xml_icon"         value="img/ltgrey_xml.gif} 
{elseif $template_option.colorset == 'blue'}
    {assign var="template_stylesheet"       value="blue_style.css"}
    {assign var="template_back_arrow"       value="img/blue_back.gif"}
    {assign var="template_forward_arrow"    value="img/blue_forward.gif"}
    {assign var="template_xml_icon"         value="img/blue_xml.gif} 
{elseif $template_option.colorset == 'brown'}
    {assign var="template_stylesheet"       value="brown_style.css"}
    {assign var="template_back_arrow"       value="img/brown_back.gif"}
    {assign var="template_forward_arrow"    value="img/brown_forward.gif"}
    {assign var="template_xml_icon"         value="img/brown_xml.gif} 
{else}
    {assign var="template_stylesheet"       value="ltgrey_style.css"}
    {assign var="template_back_arrow"       value="img/ltgrey_back.gif"}
    {assign var="template_forward_arrow"    value="img/ltgrey_forward.gif"}
    {assign var="template_xml_icon"         value="img/ltgrey_xml.gif} 
{/if}

<link rel="stylesheet" type="text/css" href="{serendipity_getFile file=$template_stylesheet}" />
1) {assign name="template_back_arrow" does not work, but {assign var="template_back_arrow" ... seems to, with a caveat.
2) caveat: this is NOT working on my entries.tpl, whereas it worked fine when set from config.inc.php. It DOES work in plugin_calendar.tpl. If I add {$template_back_arrow} somewhere in my index.tpl, I see it display the value of "img/ltgrey_back.gif", which is correct. However, if I place {$template_back_arrow} anywhere in my entries.tpl file, the result is blank. Why does it work in the plugin_calendar.tpl, but not in entries.tpl???
3) Observation/personal opinion: Having all this in index.tpl, to me personally, is inconsistent. Some variables are set in config.inc.php, and some in config.inc.php. Seems wierd. Seems to offer the possibilty of getting messed up by a user since anyone wanting to tweak a template will be editing the index.tpl file well before they would likely be editing config.inc.php.
4) One advantage of this method is that the defaults all get set for s9y<1.1, most importantly the default stylesheet. This is not overly important to me - as we discussed yesterday, there is little incentive at this point to be compatible with <1.1.
5) If performance impact is negligible, why bother moving it out of config.inc.php? Any future template can be someone's starting point for their own creation, so if this is not in BulletProof, but IS in config.inc.php for templates that might be based ON BulletProof, what was gained by not having it in BulletProof in the first place?
6) The dynamic links of BulletProof, and this "additional color set options" each require, respectively:

Code: Select all

if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
$vars = serendipity_loadThemeOptions($template_config);
-----------------------------------------
$defaults = array();
$current_vars = serendipity_loadThemeOptions($defaults);
Is their a third possible code variation that only requires a single loadThemeOptions??? (I have to admit, I only slightly understand what it is doing).

7) As a side question to the dynamic nav in BulletProof, is that "version_compare" really necessary? Nothing else in the template options is going to work <1.1 anyway.....

Sorry for the long message - I just want to get this one concept wrapped up today and move onto something else.
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

d_cee wrote:if you add this to the css it will get rid of the 'powered by' problem.

Code: Select all

div.serendipityPlug img {
background-color: inherit;
}
and I'll send an xml icon to you from home this evening :-)
I'm sorry, maybe it's just too late on a long day, but this doesn't seem to do anything ... plus, I've never encountered .serendipityPlug ..? Anyway, it's not only the 'powered by' img, it's every image in the sidebars, so this needs something more.

I see you guys have provided quite some weekend reading material for me :) As far as I can see from skimming the last posts, Don and Garvin seem to have figured out a solution, which is amazing! However, I'm out for the weekend, so we'll see if this is "it" on monday.

In terms of using this code for a default theme (I didn't even know we were going for that :)) - we could still do a default theme based on bulletproof which doesn't use this code. Right now, the default theme doesn't have colorsets, right? So let's just keep it that way, build a default based on the bulletproof framework and ship it without this code and the standard orange feed icon. Or am I missing something?

Anyway, I'm beat. Have a good weekend, guys.

YL
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post by d_cee »

Hmmm

Code: Select all

<div class="serendipityPlug">
<a href="http://www.s9y.org/" title="Powered by Serendipity">
<img style="border: 0px none ;" alt="Serendipity PHP Weblog" src="/templates/square/img/s9y_banner_small.png"/>
</a>
</div>
This seems to be how the code appears in my blog. But, as Garvin and Don have done such great things, it doesn't matter now. :-D


I still think a couple of coloursets and the framework - all as different style sheets - would be a good thing to offer as part of the template. By adding a couple of coloursets, it should be easier for any user to see how to edit the template and turn it into their own theme. As it is now, because it's a framework, a lot of classes and ids are not included in the stylesheet.

However...

...I also think it's fine to release without any additions. :-)

Dave
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

d_cee wrote:But, as Garvin and Don have done such great things, it doesn't matter now. :-D
It does still matter - I do not have a resolution for the feed icon yet.... merely setting a variable in the HOPE that I can find a solution. One other variable I forgot to set up there in my example is the graphbar icon, which is something I might also want to change appearances of depending on the chosen colorset. Meanwhile, I am still awaiting a response from Garvin regarding the setting of these variable via config.inc.php vs. index.tpl.
By adding a couple of coloursets, it should be easier for any user to see how to edit the template and turn it into their own theme. As it is now, because it's a framework, a lot of classes and ids are not included in the stylesheet.
Agreed on the colorsets. Also agreed on the missing classes. That threw me off when I first started with s9y... then Carl put together a default, commented stylesheet that contained all the classes. The number of classes being emitted has increased quite a bit, plus BulletProof has likewise added more. However, using varions FF tools, it is pretty easy to determine what classes are available to be styled.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Owen!
1) {assign name="template_back_arrow" does not work, but {assign var="template_back_arrow" ... seems to, with a caveat.
True. I didn't look up the docs on {assign} :)
2) caveat: this is NOT working on my entries.tpl, whereas it worked fine when set from config.inc.php. It DOES work in plugin_calendar.tpl. If I add {$template_back_arrow} somewhere in my index.tpl, I see it display the value of "img/ltgrey_back.gif", which is correct. However, if I place {$template_back_arrow} anywhere in my entries.tpl file, the result is blank. Why does it work in the plugin_calendar.tpl, but not in entries.tpl???
Hm. It might be that {assign} only works on the local scope of the .tpl file where it's called from. Don't know if Smarty has a way to set a global scope variable.

It might work in the plugin_calendar.tpl file because it's included after index.tpl, but entries.tpl is included before index.tpl. All {$MAJOR} variables are included from 'bottom to top'...
3) Observation/personal opinion: Having all this in index.tpl, to me personally, is inconsistent. Some variables are set in config.inc.php, and some in config.inc.php. Seems wierd. Seems to offer the possibilty of getting messed up by a user since anyone wanting to tweak a template will be editing the index.tpl file well before they would likely be editing config.inc.php.
Performance optimizations sometimes require obstruse things. *g* :)
5) If performance impact is negligible, why bother moving it out of config.inc.php? Any future template can be someone's starting point for their own creation, so if this is not in BulletProof, but IS in config.inc.php for templates that might be based ON BulletProof, what was gained by not having it in BulletProof in the first place?
Well, the impact is neglibible if you do it on your own blog where you have control, but it's not negigible (is that even the right word, it's so hard to type... ;-) ) if every blog would do it even though most users might use the default colorset only and don't benefit of that template option fetching.

Maybe someone with PHP skills could think about a method that in config.inc.php the code can be performance optimized. I can't offer to do that, and I honestly think that having it available is somewhat "cream on the top" and I'd have to focus on other things first before giving attention to this optimization. I just feel that use of the feature does not merrit the performance impact, currently. But that might be just me, and others might be thrilled to have the features available.
6) The dynamic links of BulletProof, and this "additional color set options" each require, respectively:

Code: Select all

if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
$vars = serendipity_loadThemeOptions($template_config);
-----------------------------------------
$defaults = array();
$current_vars = serendipity_loadThemeOptions($defaults);
Is their a third possible code variation that only requires a single loadThemeOptions??? (I have to admit, I only slightly understand what it is doing).
Why is that version_comapre used? What is that "-----------"?

IMHO version_compare checking for beta versions is just very harsh on performance and not needed, like you say.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

d_cee wrote:I still think a couple of coloursets and the framework - all as different style sheets - would be a good thing to offer as part of the template. By adding a couple of coloursets, it should be easier for any user to see how to edit the template and turn it into their own theme. As it is now, because it's a framework, a lot of classes and ids are not included in the stylesheet.
Right, because a) I am a lazy old fart and b) I didn't want to blow up the stylesheets. That's what the commented stylesheet is for.

For a default template we could use the orange feed icon, not use the code for switching it to save grandma's performance pennies and still do some decent colorsets which fit nicely with the orange feed icon ...

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

garvinhicking wrote:
6) The dynamic links of BulletProof, and this "additional color set options" each require, respectively:

Code: Select all

if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
$vars = serendipity_loadThemeOptions($template_config);
-----------------------------------------
$defaults = array();
$current_vars = serendipity_loadThemeOptions($defaults);
Is their a third possible code variation that only requires a single loadThemeOptions??? (I have to admit, I only slightly understand what it is doing).
Why is that version_comapre used? What is that "-----------"?

IMHO version_compare checking for beta versions is just very harsh on performance and not needed, like you say.
Hohum. Dude, that's your code (the version_compare), so you tell us :)

I'm pretty sure that this part of the config.inc.php is from that thread we had about creating a dynamic navbar, remember? I have no idea why we/you put in that version_compare, maybe it was because back then we were still trying to make this as backwards compatible as possible. The template I was using it for originally did have alternative hard coded navbar links for s9y < 1.1.

However, Don/Owen is right: bulletproof won't work with anything below 1.1 (or was it 1.0 when the theme options were introduced?), so there's no need for this. So I'm gonna strip it from the config.inc.php.

Now, regarding the possible performance issues with loadThemeOpitons() - we had that in the config.inc.php before Don/Owen introduced his code, it's needed for the dynamic navbar. So where/why would it be called twice in the s9y api? Twice from the (same) config.inc.php? Maybe I'm misunderstanding the whole discussion ..?

Anyway, I'm going to do some testing tonight.

Edit: BTW, this

Code: Select all

{if $template_option.colorset == 'grey'}
{assign name="xml_icon" value="icon_grey.gif}
...
{else}
...
{/if}
doesn't do anything right now, right? It's just a preliminary, right? Because I've just tried it, and it doesn't change the feed icon at all (I have also tried template_xml_icon from Don's code example, doesn't do anything either.)

Bah, maybe I should simply get some sleep and see what you code wizards have done by tomorrow. Nighty-night.

YL
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

garvinhicking wrote:What is that "-----------"?
That was just supposed to be a line differentiating the serendipity_loadThemeOptions called by Bulletproof, and the one that I was using, after which I asked
Is their a third possible code variation that only requires a single loadThemeOptions???
This question was not answered, so I can only assume the answer, for now, is "no".

YellowLed wrote:Now, regarding the possible performance issues with loadThemeOpitons() - we had that in the config.inc.php before Don/Owen introduced his code, it's needed for the dynamic navbar. So where/why would it be called twice in the s9y api? Twice from the (same) config.inc.php? Maybe I'm misunderstanding the whole discussion ..?
Because if Bulletproof (or any other theme) had BOTH the dynamic nav bar, AND this code to set additional variables, barring any discovery of a single serendipity_loadThemeOptions that serves both purposes, it would be called twice - once for the dynamic navbar, and once for the additional variables.

YL - in my original post, I mentioned that I am just setting the feed icon variable, I have not yet figured out if/how I can actually get that particular one to work. Everything else works (stylesheet, back arrow, forward arrow, and graphbar).

EDIT: Also, it is {assign var="..." value="..."}..
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

Owen Stubbs wrote:Because if Bulletproof (or any other theme) had BOTH the dynamic nav bar, AND this code to set additional variables, barring any discovery of a single serendipity_loadThemeOptions that serves both purposes, it would be called twice - once for the dynamic navbar, and once for the additional variables.
Hm, I just tried something which seems to work and needs only one serendipity_loadThemeOptions ... (beware, looong config.inc.php post coming up!):

Code: Select all

<?php
// Be nice to the frontend users. They don't need the additional constants
// and file lookups. Only load them when in Admin mode.
if ($serendipity['GET']['adminModule'] == 'templates' || $serendipity['POST']['adminModule'] != 'templates') {
    // Probe for a language include with constants. Still include defines 
    // later on, if some constants were missing
    $probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
    if (file_exists($probelang)) {
        include $probelang;
    } 
    
    include dirname(__FILE__) . '/lang_en.inc.php';
}

$serendipity['smarty']->assign(array('currpage'=> "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));

$template_config = array(
    array(
        'var'           => 'colorset',
        'name'          => THEME_COLORSET,
        'description'   => THEME_COLORSET_DESC,
        'type'          => 'select',
        'default'       => 'red',
        'select_values' => array('red' => 'Red',
				 'blue' => 'Blue')
    ),
    array(
        'var'           => 'layouttype',
        'name'          => LAYOUT_TYPE,
        'description'   => LAYOUT_TYPE_DESC,
        'type'          => 'select',
        'default'       => '3col',
        'select_values' => array('3col' => LAYOUT_THREE,
                                 '2coll' => LAYOUT_TWOLEFT,
                                 '2colr' => LAYOUT_TWORIGHT)
    ),
    array(
        'var'           => 'firbtitle',
        'name'          => FIR_BTITLE,
        'description'   => FIR_BTITLE_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'firbdescr',
        'name'          => FIR_BDESCR,
        'description'   => FIR_BDESCR_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'entryfooterpos',
        'name'          => ENTRY_FOOTER_POS,
        'description'   => ENTRY_FOOTER_POS_DESC,
        'type'          => 'select',
        'default'       => 'belowentry',
        'select_values' => array('belowentry' => BELOW_ENTRY,
                                 'belowtitle' => BELOW_TITLE,
                                 'splitfoot' => SPLIT_FOOTER)
    ),
    array(
        'var'           => 'footerauthor',
        'name'          => FOOTER_AUTHOR,
        'description'   => FOOTER_AUTHOR_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'footercategories',
        'name'          => FOOTER_CATEGORIES,
        'description'   => FOOTER_CATEGORIES_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'footertimestamp',
        'name'          => FOOTER_TIMESTAMP,
        'description'   => FOOTER_TIMESTAMP_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'footercomments',
        'name'          => FOOTER_COMMENTS,
        'description'   => FOOTER_COMMENTS_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'footertrackbacks',
        'name'          => FOOTER_TRACKBACKS,
        'description'   => FOOTER_TRACKBACKS_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'true',
    ),
    array(
        'var'           => 'sitenavpos',
        'name'          => SITENAV_POSITION,
        'description'   => SITENAV_POSITION_DESC,
        'type'          => 'select',
        'default'       => 'none',
        'select_values' => array('none' => SITENAV_NONE,
                                 'above' => SITENAV_ABOVE,
                                 'below' => SITENAV_BELOW,
				 'left' => SITENAV_LEFT,
				 'right' => SITENAV_RIGHT)
    ),
    array(
        'var'           => 'cocommentactive',
        'name'          => COCOMMENT_ACTIVE,
        'description'   => COCOMMENT_ACTIVE_DESC,
        'type'          => 'select',
        'default'       => 'inactive',
        'select_values' => array('active' => USE_COCOMMENT,
                                 'inactive' => NO_COCOMMENT)
    ),
    array(
        'var'           => 'counter_code',
        'name'          => COUNTER_CODE,
        'description'   => COUNTER_CODE_DESC,
        'type'          => 'text',
        'default'       => '',
    ),
    array(
        'var'           => 'counter_code_toggle',
        'name'          => USE_COUNTER,
        'description'   => USE_COUNTER_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'false'
    ),
    array(
        'var'           => 'footer_text',
        'name'          => FOOTER_TEXT,
        'description'   => FOOTER_TEXT_DESC,
        'type'          => 'text',
        'default'       => '',
    ),
    array(
        'var'           => 'footer_text_toggle',
        'name'          => USE_FOOTER_TEXT,
        'description'   => USE_FOOTER_TEXT_DESC,
        'type'          => 'radio',
        'radio'         => array('value' => array('true', 'false'),
                                 'desc'  => array(BP_YES, BP_NO)),
        'default'       => 'false'
    ),
    array(
        'var'           => 'amount',
        'name'          => NAVLINK_AMOUNT,
        'description'   => NAVLINK_AMOUNT_DESC,
        'type'          => 'string',
        'default'       => '5',
    )
);

$vars = serendipity_loadThemeOptions($template_config);

$navlinks = array();

for ($i = 0; $i < $vars['amount']; $i++) {
    $navlinks[] = array(
        'title' => $vars['navlink' . $i . 'text'],
        'href'  => $vars['navlink' . $i . 'url']
    );
    $template_config[] = array(
        'var'           => 'navlink' . $i . 'text',
        'name'          => NAV_LINK_TEXT . ' #' . $i,
        'description'   => NAV_LINK_DESC . ' #' .$i,
        'type'          => 'string',
        'default'       => constant('NAV_DEFAULT_' . $i),
	);
    $template_config[] = array(
        'var'           => 'navlink' . $i . 'url',
        'name'          => NAV_LINK_URL . ' #' . $i,
        'description'   => NAV_LINK_URL_DESC . ' #' . $i,
        'type'          => 'string',
        'default'       => '#',
    );
}

switch ($vars['colorset']) {
    case 'red':
        $serendipity['smarty']->assign(array
         ('template_stylesheet' => 'red.css'));
        break;

    case 'blue':
        $serendipity['smarty']->assign(array
         ('template_stylesheet' => 'blue.css'));
        break;
   
    default:
        $serendipity['smarty']->assign(array
         ('template_stylesheet' => 'red.css'));
}

$serendipity['smarty']->assign_by_ref('navlinks', $navlinks);
?>
This is the config.inc.php I'm using for my local copy of bulletproof right now. Seems to work perfectly fine, although I have only tested it with the rather simple option to switch stylesheets.

So, am I smarty code hero of the day? :wink:

BTW, there's one thing I don't like about your code: it switches stylesheets according to the selected colorset, which means you have to have a full stylesheet for every colorset. I think it would be better to have a 'master stylesheet' (style.css comes to mind) plus an additional individual stylesheet (blue.css, red.css, and the likes) for each colorset. These individual stylesheets need to have only those css statements which actually change in a colorset. I have already changed that in the example code.

Usually, the only things that change from colorset to colorset are the colors - hence the name 'colorsets' :) So you'd include margins, paddings, and stuff like that in style.css, and put only things that are different to that stylesheet into blue.css, red.css etc., 'overwriting' the statements in style.css due to the css cascade. Saves a lot of double code. I'm going to upload a new version of bulletproof tomorrow which demonstrates this in a very simple way.

Here's a question for the php experts: Do we actually need the default: in the switch statement? Or is that mandatory in a switch statement?
Owen Stubbs wrote:EDIT: Also, it is {assign var="..." value="..."}..
Yeah, I was aware of that, I was just too lazy to edit the quoted part :)

YL
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

YellowLed wrote:Theme options now include cocomment support, counter code, and additional text in the footer. YL
What, exactly, is "cocomment"???? I'm a bit confused (which does not take much). :P

For someone who has (correctly) proclaimed how "bare bones" bulletproof should be, this concept seems to be pushing the envelope a bit! :wink:

Also - since you now seem to be stripping < 1.1 code in config.inc.php (and possibly index.tpl), you might as well strip the {if $head_version < 1.1} section from Bulletproof's commentform.tpl IMHO.
=Don=
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Wow - you do good work after a nice long weekend!!!
YellowLed wrote:BTW, there's one thing I don't like about your code: it switches stylesheets according to the selected colorset, which means you have to have a full stylesheet for every colorset. I think it would be better to have a 'master stylesheet' (style.css comes to mind) plus an additional individual stylesheet (blue.css, red.css, and the likes) for each colorset. These individual stylesheets need to have only those css statements which actually change in a colorset. I have already changed that in the example code.

Usually, the only things that change from colorset to colorset are the colors - hence the name 'colorsets' :) So you'd include margins, paddings, and stuff like that in style.css, and put only things that are different to that stylesheet into blue.css, red.css etc., 'overwriting' the statements in style.css due to the css cascade. Saves a lot of double code. I'm going to upload a new version of bulletproof tomorrow which demonstrates this in a very simple way.
No it doesn't - it works exactly as you describe, provided the template author writes their CSS in the manner in which you describe. That was my entire confusion based upon looking at Dave's coffee bar theme - he does, in fact, load an entirely duplicate stylesheet instead of just a "difference" stylesheet. The global style.css is loaded no matter what. This setting merely appends the "colorset" css, provided the template author codes these colorset stylesheets appropriately (only changed tags, not the entire default stylesheet PLUS changes)
Here's a question for the php experts: Do we actually need the default: in the switch statement? Or is that mandatory in a switch statement?
This is not mandatory at all... I threw it in to cover my @$$. The condition should never be met due to the fact that the colorset has its own default setting, just thought it seemed the right thing to do.

This is great that you have merged my original stuff with the dynamic navbar, essentially providing that "3rd" option I mentioned earlier. I'm going to give your config.inc.php revisions a real-time shot, and will report back. We need something to work here in config.inc.php, because setting this stuff in TPLs is a PITA due to the fact that simply setting them in index.tpl does not proliferate the variable setting to most of the tpls.

However, be forewarned that what I am currently trying to do is not setting a variable, but storing these values to the options table, which I think is the best possible solution. I think the model is already right in front of us - that being the setting of URL's & link names. Problem is, I am having a great deal of difficulty fully comprehending this particular aspect.
=Don=
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post by yellowled »

Owen Stubbs wrote:What, exactly, is "cocomment"???? I'm a bit confused (which does not take much). :P
See http://www.cocomment.com/learnmore :)
Owen Stubbs wrote:For someone who has (correctly) proclaimed how "bare bones" bulletproof should be, this concept seems to be pushing the envelope a bit! :wink:
Well, the original intent was to create a framework which makes it as easy as possible for both template authors and users to work with. If you look at the theme options bulletproof has right now, and compare them to the most frequently asked questions in this forum, I think you'll agree that we'll now be able to cover most of them with a theme option in bulletproof-based templates.
Owen Stubbs wrote:Also - since you now seem to be stripping < 1.1 code in config.inc.php (and possibly index.tpl), you might as well strip the {if $head_version < 1.1} section from Bulletproof's commentform.tpl IMHO.
Already done. Also, I'm going to take a look at all the other .tpl files, since a lot of them come from other template, so there might be more < 1.1 code.

YL
Post Reply