views:

556

answers:

2

Hello,

I was looking on many template libraries, som I have fair mess in general idea what is out there ready to download/use and what I want to use, so maybe you could help me with this.

I'm currently learning CodeIgniter, thinking about moving to Kohana later. I would like to include controllers/modules(/module function maybe?) based on needs of template/site.

Example, so you would understand: I have xml-defined page saved in mysql, which states, that in
<div id="sidebar">, i want to use news panel/widget - something like:
<div id="sidebar">{widget:news;3;60}</div>.

I'm looking for template parser and/or way to do it, so in main application I load page, then template. then I look up what modules/widgets page/template use and load them dynamically, pass them parameters (in example news;3;60 - module news, 3 last, 60 characters limit each), and echo their result in place of where i called them.

The usage for this should be understandable - if I use news module on 27 pages, just somewhere with last 3 news, somewhere last month, etc., i want to include it simply and edit it on one place.

Other problems in my mind are: I'm thinking that it would be best to have all modules at one time (not load them one there, one here), so I can access database on one place, etc.

I'm kind of lost and maybe someone will have some idea for me :)

+2  A: 

The two best ways to do this are:

  1. Use my CodeIgniter Dwoo implementation and build plugins
  2. Use wiredesignz' Widget plugin

You could of course use Smarty plugins but yuck, who still uses Smarty?

Remember when creating Dwoo plugins that the CodeIgniter instance is available to any PHP loaded in on that request, so wether its Dwoo plugins, modifiers, blocks, etc you can always use:

$CI =& get_instance();
$CI->load->model('something');
//etc
Phil Sturgeon
Thank you Phil, will look into that (later... :D) - Are both implementable in Kohana?
Adam Kiss
Sadly not, as Kohana is no longer simply a fork of CodeIgniter. It would be like expecting CodeIgniter code to work in CakePHP without tweaking anything - impossible. It shouldn't require much tweaking though.
Phil Sturgeon
That said, going with the Dwoo option means you can build most of your code as Dwoo plugins/blocks which will be much easier if you switch frameworks down the line.
Phil Sturgeon
Adam Kiss
Cool. Remember that Dwoo and Widgets were two separate suggestions that approach this in two very different ways. Dwoo functions and blocks should be able to do everything you want and getting Dwoo implemented is drag and drop 2 files. Here is the syntax: http://wiki.dwoo.org/index.php/Functions:gravatar
Phil Sturgeon
Then why I thought I need to implement both? You got me confused - I should probably NOT think about 25 different things all day long...
Adam Kiss
A: 

If you're using Kohana3, you could use the HMVC-capabilities. A quick way would be to create a helper-class that you can use in your views. In your view you then make a call to this helper. This helper would start a new request that would trigger the correct controller/action.

There is some kind of widget-class in the Kohana-forums, but that requires a class for the widget instead of utilizing the (already existing?) controllers via the HMVC-capabilities of Kohana3.

Caspar
Hmm... the CodeIgniter widget implementation could be easily be implemented in Kohana too.
Thorpe Obazee
I'll have to check it out sometime then. I've never really used CodeIgniter, besides checking it out for a day or so.
Caspar