TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Theming Module For Kohana 3.3+
  • Kohana has become a newfound obsession for me, so much so, I've created yet another module. This time around a theming module that allows you to have theming functionality in your Kohana projects. At present it is super simple, and the documentation is still being worked on, but it works in its simplest form.

    Depending on my interest levels, I have some cool ideas for this module to come at a later date. Being new to Kohana, some might cringe at some of my code decisions and there are no doubt errors throughout the code that have yet to rear their heads and some things could be written better, so feel free to fork and pull. Unit tests are coming, I'm not much into TDD, so I tend to balance between a little Test Driven Development and a little write tests after something is done type of development.

    Just keep in mind this thing might not work all too great at the moment. I have done a little bit of testing and it seems to work, but there could be issues as mentioned.

    Check it out here: https://github.com/Vheissu/Kohana-Theming-Module

  • "Your requested theme default, could not be found in any of the supplied theme directories." I got confused and called it themes. Fixed that, and all looks good. Maybe a note in the readme? :-)

    Oh, and don't forget the userguide config file. Something like

    <?php
    
    return array
    (
        'modules' => array(
            'theme' => array(
                'enabled' => TRUE,
                'name' => 'Theme',
                'description' => 'Themes for Kohana',
                'copyright' => '© 2013 Dwayne Charrington + Contributors',
            )
        )
    );

    But what are the benefits of doing this over just using the standard views system? It's already possible to specify different bits of views in different modules (so that new themes can just be simple modules themselves). I'm probably missing something! :-)

  • @samwilson — Oops yeah, forgot to make a note of the fact you need to call the module, "theme" and not "themes" — haha yeah, the userguide stuff isn't something I've really thought of just yet, I put a folder in there just so there was something when I committed.

    You make a very valid point, in its current version it really is an over-glorified views wrapper that doesn't really offer much added benefit (yet). I do have other ideas for making it a bit more unique, but still easy to use like ability to use the templating controller, automatically selecting view files based on the current request, etc. I think the only benefit of this library is that you can keep your themes separate from your code (even though from a code-level, themes are considered modules), it's all about appearances. If you were building a CMS you wouldn't want themes being added into your modules folder and having the user potentially mess with other modules like the ORM or Database modules.

    When I get the time, I'll spruce it up a lil' for sure.

  • @Vheissu here's a theme module: https://github.com/ibidem/mjolnir-theme it's not for kohana, but very similar, so it will hopefully help you get inspired (the only difference is that it's namespaced and files are in an +App folder, and classes are on the root; so backwards how kohana does it).

    A theme would look like this: https://github.com/ibidem/mjolnir-template-app/tree/mj/2.x/demo/themes/the-demo

  • @Akki - Very interesting, thank you. Was that particular theme module built for a framework or just standalone? Maybe I'm one of few, but I can't stand namespaces in PHP. Seeing things like extends \Some\File\Slashes\Nonsense just feels silly to me, definitely love the way Kohana extends and uses other classes. Funny you post that though, I was actually going to take a look at the theme class that ships with FuelPHP (FuelPHP shares a very similar structure, except use of namespaces instead). The asset management from the FuelPHP library might be a nice addition to my library I could learn from.

  • @Vheissu

    Was that particular theme module built for a framework or just standalone?

    It's for a library. So framework if you're lazy, stand alone if you're not lazy.

    Seeing things like extends \Some\File\Slashes\Nonsense just feels silly to me

    It's 90% of the time just extends \app\Something, 9% of the time class User extends next\User (ie. dynamically find the next module that has a class User that's after this module) and 1% of the time extends Vendor_Stuff_I_Want_Nice_API_For. Since all calls are \app\ I can just do namespace app; in a file and just call things with out any namespace (ie. they will be namespace it will just look exactly as they do in Kohana).

  • deleted

  • Where's the delete button? Server crapped out on me

  • @Vheissu I'd send a pull request for this, but I reckon you're still working on it, so:

    The LoadTheme test uses the Keys class. No worries, but I loaded this module into a dev project, and it made my test runs die. :-( Maybe just add a @group annotation to the class, so it can be excluded from test runs? :-)

    Keep up the good work!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion