I am using Kohana 3 and a template controller. Currently, my main template template controller looks something like this:
<?php defined('SYSPATH') or die('No direct script access.');
abstract class Controller_SiteTemplate extends Controller_Template
{
public function before()
{
parent::before();
$this->template->styles = Kohana::config('site.styles');
$this->template->scripts = Kohana::config('site.scripts');
$this->template->title = '';
$this->template->content = '';
}
}
And then in my template view I do:
<?php
foreach($styles as $file => $media)
echo HTML::style($file, array('media' => $media)).PHP_EOL ?>
<?php
foreach($scripts as $file)
echo HTML::script($file).PHP_EOL ?>
It works well. The problem is that you do not have to worry about adding style files and a script to the controller. This also creates problems if the looks are done by someone other than me, as they will have to cheat the controller in order to add a new stylesheet or a new script file. How can this be done better?
, , . . , .