1 (edited by Chymæra 2009-08-08 15:21:40)

Topic: HOW-TO: customize elements on sub-boards

Ever wanted to change the site appearance a wee bit for each of your sub-boards? A different colour for the headers maybe, or the background, or your standard font, or all of those? Here's a how-to for those who share my customization need:

It's really easy as pie, just add the following code to your page.php file:

        $path_to_color = array("/a" => "#abc",
                               "/b" => "#000",
                               "/c" => "#cab",
                               "/d" => "#fff"
        $path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
        //echo $path; //uncomment if the code fucks up
            $tmpl->setVariable("COLOR", $path_to_color[$path]);
            $tmpl->setVariable("COLOR", "#aaa");
        ///end colour-code

Naturally, you will need to specify your own sub-boards and colours in the first few lines.
Afterwards just add {COLOR} at any point you want in your templates (including - of course - css specifications _within_ the templates) The code will _NOT_ work if you add {COLOR} in your .css file.

For multiple colour changes just introduce more variables.

atm I've only just used/tested this for colours because they're the most handy way of customizing sub-boards whilst maintaining consistency. - But there's no reason why the code wouldn't work for other parameters: width, font-weight, font-family, even div id or class names. Maybe this could even serve as a starting point for some un-hackish way of stylizing sub-boards autonomously. Just take it from here and start experimenting.

Have phun kids.


Re: HOW-TO: customize elements on sub-boards

Hmm, that's pretty clean - nicely done. The next version of ochiba I'm working on is going to use a different template system (Smarty) so the implementation will be different but your code above has given me some ideas. Thanks!


Re: HOW-TO: customize elements on sub-boards

Actually, it's been discovered that the example code as given causes ochiba to malfunction for reasons that are not immediately obvious, so please do not use it.