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
Usage Examples (aka Snippet Share)
  • It was a mistake on my part and I have fixed it.

    Thank You.
  • Posted By: The Pixel Developer

    The cleanest and easiest way to use pagination, the documentation should do it this way :)


    update the docs if your way is better =P
  • Posted By: Zeelot3k
    Posted By: The Pixel Developer

    The cleanest and easiest way to use pagination, the documentation should do it this way :)

    update the docs if your way is better =P



    And its advantage must be substantiated :)
  • Well, I was reading through the code (as you do) and saw that the class returned the sql offset and items_per_page. This meant I didn't have to handle it within the controller which makes it cleaner. I also have the advantage of setting the per item globally through the config.

    http://docs.kohanaphp.com/libraries/orm/examples

    Per page, Page num and Offset aren't need as these are worked out in the class although I admit some people will want to handle this calculation themselves.

    I might update the documentation, i'll see.
  • I find myself getting tons of use out of this little class. Great for people who like to organize .css and .js files into sort of a site-wide/section/page hierarchy, and flexible enough to override site-wide includes for a particular page.

    Thanks to Shadowhand for giving me the idea.

    Usage

    PHP Code
  • @benjamin: also see the "Javascript/CSS collector" helper in the kohana module repository. It supports on the fly JS minimify (and caching).
  • @Benjamin:
    nice. I just made something similar, but much simpler, although with one added feature:
    - Auto_render. That hooks into the system.display Event (where the data is flushed to the browser) and renders all the scripts just before the tag. That way, you don't have to call ::render in all your templates but can leave that to the auto_render.

    http://pastie.org/400205
  • @willemmulder:
    Using the Event to auto-render is really cool.
  • I've recently needed to check the existance and size of remote files and seeing as the current file helper seems to deal only with local files I thought these methods might be usefull additions to the kohana file helper class?

    Not 100% certain these are optimal but they seem to work reliably for me.


    /**
    * Attempt to determine whether or not a remote file exists.
    *
    * @param string file url
    * @return boolean
    */
    public static function exists_remote($url)
    {
    $headers = get_headers($url, 1);

    $exists = FALSE;

    foreach($headers as $h => $value)
    {
    if (is_string($value))
    {
    if (stripos($value, '200 OK') !== FALSE)
    {
    $exists = TRUE;
    break;
    }
    }
    }

    return $exists;
    }

    /**
    * Determine the size of a local or remote file.
    *
    * @param string file path
    * @param string 'b', 'k' or 'm' - return size as either bytes, kilobytes or megabytes
    * @return integer size of file
    */
    public static function size($path, $bytes_kilobytes_megabytes = 'b')
    {
    if (stripos($path, 'http://') === 0)
    {
    return file::size_remote($path, $bytes_kilobytes_megabytes);
    }
    else
    {
    $x = intval(@filesize($path));
    }

    if ($x > 0)
    {
    switch ($bytes_kilobytes_megabytes)
    {
    case 'k':
    $x = round($x / (1024), 2);
    break;
    case 'm':
    $x = round($x / (1024*1024), 2);
    break;
    }
    }

    return $x;
    }

    /**
    * Attempt to determine the size of a remote file.
    *
    * @param string file url
    * @param string 'b', 'k' or 'm' - return size as either bytes, kilobytes or megabytes
    * @return integer size of file
    */
    public static function size_remote($url, $bytes_kilobytes_megabytes = 'b')
    {
    $headers = @get_headers($url, 1);

    if (is_array($headers))
    {
    $x = array_change_key_case($headers, CASE_LOWER);

    // first try to get size from headers
    if (isset($x['content-length']))
    {
    $x = intval($x['content-length']);
    }
    else
    {
    // resort to loading file into string
    $contents = @file_get_contents($url);

    $x = strlen((string) $contents);
    }
    }
    else
    {
    $x = 0;
    }

    if ($x > 0)
    {
    switch ($bytes_kilobytes_megabytes)
    {
    case 'k':
    $x = round($x / (1024), 2);
    break;
    case 'm':
    $x = round($x / (1024*1024), 2);
    break;
    }
    }

    return $x;
    }
  • The FAIL "Shop" Helper

    I've little time to reinvent the wheel, and happily cut corners where necessary in my quest to get the job done so I've created a helper class and function below which links to a checkout of http://google-checkout-php-sample-code.googlecode.com/svn/trunk/library which lives in what I call my VENDORPATH (you will need to change the include_path line). WIth that I call my 'shop' helper with an array of the google library class names (from the filenames) I need for my cart:


    $google_cart = shop::get_google_cart(array('GoogleItem', 'GoogleShipping', 'GoogleTax'));


    Also to handle response from google, I wrote a counterpart function get_google_response() which can be used in the controller to handle incoming posts from google, something like this:


    public function google_response()
    {
    $response = shop::get_google_response();
    if (!is_array($response)) {
    exit;
    }

    $root =& $response['root'];
    $data =& $response['data'];
    $Gresponse =& $response['Gresponse'];
    $Grequest =& $response['Grequest'];

    switch ($root)
    {
    ...


    operating in much the same way as the response handler demo
  • For a site I'm working on, I needed to have unique "slugs" for each blog article, this is what I came up with in my Post_Model:

    public function save()
    {
    $this->slug = $this->_unique_slug(url::title(empty($this->slug) ? $this->title : $this->slug));
    return parent::save();
    }

    private function _unique_slug($str)
    {
    static $i;

    $original = $str;

    while ($post = ORM::factory('post', $str) AND $post->loaded AND $post->id !== $this->id)
    {
    $str = $original.$i;
    $i++;
    }

    return $str;
    }
  • Customize items count for per page (like delicious' page navigation), add this code to the pagination view where you'd like to show.
    $per_page_pos = strpos($url, '{page}') + 7;
    $per_page_len = strlen($items_per_page);
    $page_count_nav = '<span class="pcnt">';
    $current_max_offset = min($current_page*$items_per_page, $total_items);

    foreach(array(10,20,50) as $val)
    {
    $nav_page = ceil($current_max_offset / $val);

    $pgc_url = substr_replace($url, $val, $per_page_pos, $per_page_len);
    $pgc_url = str_replace('{page}', $nav_page, $pgc_url);

    $page_count_nav .= $items_per_page == $val
    ? '<strong class="curpcnt">'.$val.'</strong>'
    : '<a href="'.$pgc_url.'" title="'.$val.'">'.$val.'</a>';
    }
    echo $page_count_nav,'</span>';

    Edit : fix bug in previous version.
  • I was checking out schnoodles' Controllers. What is everyone's opinions on that way of doing things? I thought they were good ideas at first, but some of the guys at work are concerned that the Controllers inheriting from these base controllers are are not very cohesive because the methods in these controllers would not be related to each other in any way other than the fact that they are called via ajax or cron. Any thoughts?
  • IMO cron and ajax controllers are out of the classic workflow as they don't need any templating consideration, they just perform operations on data. Shnoodles controllers are some kind of "security" improvements to restrict the perimeter of cron and ajax requests. So when needed you just extend Ajax_Controller and transparently only ajax requests will be accepted.

    Though you can add custom methods for cron and ajax handling in the Base_Controller too. :)
  • Here is a more powerfull (as for me) version of Zeelot' notice helper (I found it in YurikoCMS): message helper.

    • Old data doesn't save in session again (but you can save it manually).
    • Added special methods for validation errors. For example, we can use message::add_validation($post->errors(), 'some_i18n_filename') and then on the form page show validation errors before every form element separately.
    • Also there are methods for custom data storing. When we got a validation errors we should save input data to show it in form again.


    This is a small example of my controller and view code:

    Auth_Controller, register method.

    $data = arr::overwrite($data, $_POST);
    $this->user = ORM::factory('user');
    $this->user->role = 'user';
    if (!$this->user->validate($data, TRUE)) {
    // save validation errors
    message::add_validation($data->errors(), "auth");
    // clear private data
    arr::remove('password', $_POST);
    arr::remove('password_confirm', $_POST);
    // save form fields
    message::add($_POST, 'custom');
    url::redirect(Router::uri('auth', array('method'=>'register')));
    }
    else {
    // save result. Also we can save username and show it in login form if needed
    message::add(Kohana::lang('auth.registration_ok'), 'success');
    url::redirect(Router::uri('auth', array('method'=>'login')));
    }


    View, registration form

    <form>
    <ol>
    <li>
    <?message::render('validation', 'email')?>
    <dl>
    <dt>
    <label for='email'>
    <?=Kohana::lang('auth.register_email')?> <em>*</em>
    <p class='rule'><?=Kohana::lang('auth.email_rule')?></p>
    </label>
    </dt>
    <dd>
    <input type='text' name='email' id='email' size="30" maxlength="32" value="<?=message::custom('email')?>" />
    </dd>
    </dl>
    </li>
    <li>
    <?message::render('validation', 'username')?>
    <dl>
    <dt>
    <label for='username'>
    <?=Kohana::lang('auth.register_username')?> <em>*</em>
    <p class='rule'><?=Kohana::lang('auth.username_rule')?></p>
    </label>
    </dt>
    <dd>
    <input type='text' name='username' id='username' size="30" maxlength="32" value="<?=message::custom('username')?>" />
    </dd>
    </dl>
    </li>
    // etc
    </ol>
    </form>


    We can show all messages (errors/warnings/success) before main content with message::render() without parameters. Before each field we show validation errors by message::render('validation', FIELDNAME), and message::custom(FIELDNAME) returns saved value for FIELDNAME if exists. Screenshot1, screenshot2, sorry for russian texts, I haven't yet make EN resources for i18n.

    Data saving and loading is similar to Zeelot' notice:

    Event::add('system.ready', array('message', 'init'));
    Event::add('system.send_headers', array('message', 'save'));
    Event::add('system.redirect', array('message', 'save'));

    Also, it uses message config file to store Session variable name. If you want to remove it, just change message::init() method.
  • I've noticed that some people want media (css,js,images) content to be placed in the web root and web root only while others want this content packaged with either an application or module so that things are a little more 'together' for a variety of reasons. I subscribe to the second way of doing things. Mostly because my main site will load a completely different application based on sub domain. The only thing I want in the web root is a modified frontloader/bootstrap which sets which app to load. Everything else should be neatly organized within the application.

    So long story short here is the Media Controller I put together last night.

    Short description and usage example on my blog

    Source Code

    [edit: spelling]

  • Hi all,

    I've been working on a business support system for a company, and one important part of this system is user tracking (some may refer to it as logging, though it's not really a logger but more of a tracker :)). I aim to track what the currently logged in user is doing in the system - which module (page) the user is accessing, who it is, what time it is and if there is data in POST/GET, log them as well. The system will have at least 10 users logged in at the same time, so this tracker DB table will grow big pretty soon, so an important goal for the tracker system is minimal footprint. Here's my code:

    module/tracker.php
    <?php defined('SYSPATH') OR die('No direct access allowed.');

    class Tracker_Model extends ORM {

    }


    /* EOF */

    controller/base.php (the base controller all other's extend)
    <?php defined('SYSPATH') or die('No direct script access.');
    abstract class Base_Controller extends Template_Controller {

    public function __construct()
    {
    parent:GDN__construct();
    //auth, db init and such go here as well...
    $this->track();
    }

    protected function track($msg=NULL)
    {
    $t = ORM::factory('tracker');
    $t->uid = $this->user->id;
    $t->mid = $_SESSION['mid'];

    if(!empty($_POST))
    $t->post = Kohana::debug($this->input->post());

    if(!empty($_GET))
    $t->get = Kohana::debug($this->input->get());
    if($msg)
    $t->msg = $msg;

    $t->save();
    }

    }

    /*** EOF ***/

    So track() is called by default every time a user accesses a page. Optionally, I can call $this->track("some message to save") anytime in my application to save some specific data.

    What would you say about this approach? Thankful for any input - I'm new to this.
  • Addons Tab next to "Helpers" so we can get quicker accessibility to those addon documentation without having to go back to the documentation home page to find them.
  • When making an administration system, I usually have a way for the user to filter and paginate the results.
    But if you apply a filter (like a search term) and then click on a link to say edit an item, then when you come back you'd normally have to re-filter the results.
    So I use this function in my base controller (basically Template_Controller) to save the filters to the session.


    protected static function input2session(array $vars, $prefix)
    {
    $session = Session::instance();
    $input = arr::merge($_GET, $_POST);
    $return = new stdClass;

    foreach ($vars as $var)
    {
    if (isset($input[$var]))
    {
    $session->set($prefix.$var, $input[$var]);
    $return->$var = $input[$var];
    }
    elseif ($v = $session->get($prefix.$var))
    {
    $return->$var = $v;
    }
    else
    {
    $return->$var = NULL;
    }
    }

    return $return;
    }


    You specify which form fields will be saved in the session, with the appropriate prefix so you can have seperate settings for each page of the admin.
    Since once you set a session variable it can't be used until the next page load, this function sets the session variable, and the also returns that value for immediate use.
    If there is no input ($_POST or $_GET) then it checks if that session variable already exists. If so, it will return that for use.
    If there is no input and it doesn't already exist then it just returns NULL, this makes it convenient for setting the values of form fields. ie: form::input('search', $filters->search);

    So later it can be used like this in your controllers:

    $view = View::factory('pagename')
    ->bind('filters', $filters);

    $filters = self::input2session(array('page', 'search', 'per_page'), 'pagename_');

    if (isset($filters->search))
    {
    // modify database query
    }
  • Returns time difference between two timestamps, in a short way. http://pastie.org/671085

  • Birthday helper :

    <?php defined('SYSPATH') OR die('No direct access allowed.');
    /**
    * Birthday helper class.
    *
    * @author Benoit Villière
    * @copyright (c) 2007-2008 Kohana Team
    * @license http://kohanaphp.com/license.html
    */
    class birthday_Core {

    /**
    * Converts a date to an age.
    *
    * @param string Date of birth
    * @return integer
    */
    public static function age($birthday)
    {
    return (int) ((time() - strtotime($birthday)) / 31536000);
    }

    } // End birthday

    Usage :
    echo 'Benoa is '.birthday::age('08/01/1986').' years old';

    http://pastie.org/848132
  • I'm doing a complete relaunch of my website with kohana 3. On the old site I used Zend_Translator with gettext and wanted to reuse my existing po files but not the Zend package. Kohana offers no port for po files but I think it's still a better way to do translations with POEdit than updating php files all the time. So I made a little helper class to convert an existing po file into a kohana language array:

    <?php defined('SYSPATH') or die('No direct script access.');
    
    /**
     * Internationalization (i18n) helper class for converting po files into kohana arrays.
     *
     * @package    I18n
     * @author     Carsten Henkelmann
     * @copyright  (c) 2010 Carsten Henkelmann
     * @license    http://kohanaphp.com/license.html
     */
    class I18n_Po extends Kohana_I18n
    {
        /**
        * Look for the po file and if it was changed.
        *
        */
        public static function check_po_change()
        {
            // This three lines were taken from /system/classes/kohana/i18n.php, function load()
            $lang = explode('-', self::$lang);
            array_pop($lang);
            $po_file = Kohana::find_file('i18n', implode(DIRECTORY_SEPARATOR, $lang), 'po');
    
            $mycache = Cache::instance('sqlite');               // Get Cache Instance
            $last_po_change = $mycache->get('last_po_change');  // Read cached timestamp of last change
    
            // If no cache available or po file newer...
            if ( ! $last_po_change || (filemtime($po_file[0]) > $last_po_change) )
            {
                I18n_Po::generate_lang_file($lang, $po_file[0]);            // convert po file into kohana array.
                $mycache->set('last_po_change', filemtime($po_file[0]));    // and // update cache
            }
        }
    
    
        /**
        * Convert a po file into a kohana array
        *
        * @param string $lang
        * @param string $po_file
        */
        public static function generate_lang_file($lang, $po_file)
        {
            $translations = array();
    
            $fp_po = fopen($po_file, 'r');  // Open po file
    
            while ( ! feof($fp_po) )
            {
                $row = fgets($fp_po, 4096);
    
                preg_match('/^msgid "(.+)"$/', $row, $matches); // Look for a translation msgid
                if ( !empty($matches[1]) )                      // Translator msgid found?
                {
                    $key = $matches[1];
    
                    // Get the translation in the next row
                    $row = fgets($fp_po, 4096);
                    preg_match('/^msgstr "(.+)"$/', $row, $matches);
                    if ( !empty($matches[1]) )
                    {
                        $translations[$key] = $matches[1];  // key = text to translate, value = translation
                    }
                }
            }
    
            // Write the updated array into file
            $php_content    = "<?php defined('SYSPATH') or die('No direct script access.');\n\n"
                            . "return ".var_export($translations, true)
                            . '; //End of application/i18n/'.implode(DIRECTORY_SEPARATOR, $lang).'.php'
                            . "\n";
            file_put_contents(str_replace('.po', '.php', $po_file), $php_content);
        }
    }
    

    Copy your po file into "/application/i18n/" and put this line in the in the "before()" function of your Controller_Website:

    I18n_Po::checkPoChange();
    

    For example a "en.po" is then converted into a "en.php" in the same directory.

  • I've built a modular CMS with Kohana 2.3.x that manages multiple sites. I want the URLs in the CMS to represent what site you're managing, so that you can bookmark and share them. I want the URLs to look like this:

    /cms/{sitename}/pages/edit/{pagename}
    /cms/{sitename}/templates/add
    i.e.
    /cms/{sitename}/controller/method/arguments


    The sites and their configurations are managed in a database. I don't want to worry about building a controller for each site. If you are authorized to manage the site, you can click those URLs and get to work. I achieve this using a pre_routing hook and relevant function. It sets a SITE constant and rebuilds the Routing::$current_uri without the {sitename} so that normal Kohana routing works. If you don't specify a {sitename} it tries to get the last site you worked on via sessions, or uses the default.


    Event::add_before('system.routing', array('Router', 'setup'), array('CMS_Controller', 'pre_routing'));



    <?php
    //manages the SITE constant and allows dynamic routing with it

    class CMS_Controller extends Controller {

    private static $default_site = 'corporate';

    public static function pre_routing() {

    //setup defaults - try and get SITE from session, or use $default_site
    $manage_site = Session::instance()->get('manage_site', self::$default_site);
    $controller = 'pages';
    $method = 'index';
    $arguments = NULL;

    if (!empty(Router::$current_uri)) {

    $uri = explode('/', Router::$current_uri);

    //check that the site name is valid and user is authorized
    if (Environment::get('CMS_MANAGED', $uri[0])) {
    $manage_site = $uri[0];
    $controller = (isset($uri[1]) ? $uri[1] : $controller);
    $method = (isset($uri[2]) ? $uri[2] : $method);
    $arguments = (isset($uri[3])) ? implode('/', array_slice($uri, 3)) : $arguments;
    }

    } else {
    //let's redirect for empty URI's so we know what site we're managing
    url::redirect($manage_site.'/'.$controller);
    }

    define('SITE', $manage_site);
    Session::instance()->set('manage_site', SITE);

    //just update the current_uri without SITE and continue normal routing
    Router::$current_uri = (!empty($arguments)) ? $controller.'/'.$method.'/'.$arguments : $controller.'/'.$method;

    }

    }
  • Here's just a couple of functions I've found extremely handy (inspired by MooTools):

    /**
     * Converts the argument passed in to an array if it not already an array.
     * @param mixed $param
     * @return array
     */
    public static function splat($param)
    {
        if (is_array($param))
        {
            return $param;
        }
        return array($param);
    }
    
    /**
     * Returns the first argument, that is not logically false
     * @return mixed
     */
    public static function pick()
    {
        foreach (func_get_args() as $argument)
        {
            if ($argument)
            {
                return $argument;
            }
        }
        return NULL;
    }
    

    The first one should probably go into Arr helper, not sure about second one though :)

  • Wow ,interesting!
  • My core controller: http://pastebin.com/sDkn8Shu
  • A functional 404 method inspired by an article I read on "ala"

    http://pastie.org/private/xdag5paasxm5w0pnjm6w

    This allows you to find broken pages on your website and track them.

  • @czukowski
    smth::splat($param) is the same as (array)$param, no?
    @Crystal
    Make it abstract (so no one can access your base controller).
  • @biakaveron good idea, thx
  • Kohana 3.x - Arr helper extension:
    http://pastie.org/1012138
  • Kohana 3.x - Date helper extension:
    Date::format($date[,$format[,$offset]]);
    http://gist.github.com/451267
  • This is very helpful if you need to copy an associative array's keys while setting their values to null (empty).

    For example:
    $post = array("id"=>"1223", "name"=>"John Smith", "phone"=>"123-123-1122", "title"=>"President");
    $errors = array_fill_keys(array_keys($post), NULL);


    $errors will now be:
    array("id"=>"null", "name"=>"null", "phone"=>"null", "title"=>"null";

    I used this in form submissions to setup error messages that related to form names passed by the $_POST.

    Maybe this can be added to the core KO3 arr class? Something like:

    class Kohana_Arr {...

    public static function copy_keys(array $array, $default = NULL)
    {
    return array_fill_keys(array_keys($post), $default);
    }


    // Example...
    $errors = arr::copy_keys($_POST);
  • Because the find_all() is used to get the data so he can work with it to output it.

    @Colonel-Rosa, thanks for the good explenation. I got stuck because in another tutorial the used the PHP function count() to calculate $total. But this always returned the number of objects limited by the ->limit. By using the ->count_all(); function I got it working like a charm
  • Extended Form helper, so you don't have to set the ID (which normally is the same as the name) for use with labels...
    http://kohana.pastebin.com/d7LCV53X
  • Use multiple files/folders per language to keep i18n files small

    http://pastie.org/1338861
  • Kostache variant which lets you use before and after methods in the view class and allows templates to be inserted into other templates rather than use partials.

    https://github.com/malkintower/handlebar

    Kohana V3 demo application using handlebar also available on github:

    https://github.com/malkintower/handlebar-demo-application

  • Are there new examples of the Kohana 3.1 sites for learning?

    What is them links on GitHub?

    Thanks.

  • A small helper-class for the (inofficial) Google Weather API.
    Uses Kohana::cache for caching results.

    Source: http://pastie.org/1776195
    Example-View: http://pastie.org/1776211

  • I made little change in my debug::vars(), so now i can see filename and line number, where vars() was executed. example output: string(4) "test" (auth/mobile.php:159). It's useful when you forgot where you put your debug line. http://pastebin.com/AWXCjETN

  • @ez8377

    Here is my modification. It uses original Kohana_Debug::vars() call. Also, backtrace info it the same for dumping vars, so you can show it on the top, just before <pre> tag.

    https://gist.github.com/980356

  • I think password validation is a business logic, and belongs to our Model (User), so this is my modification to Model_User (ORM) for validating passwords inside the model:

    first, define a new var for saving the plain password:

    protected $_password_plain;
    

    // fill that var when the user sets a password:

    public function set($column, $value)
    {
        if($column == 'password')
        {
            $this->_password_plain = $value;
        }
        return parent::set($column, $value);
    }
    

    add the rule for you password validation:

    public function rules()
    {
        return array(
                'password' => array(
                    array(array($this, 'valid_password')),
                ),
                           more rules here
            );
    }
    

    define the valid_password

    public function valid_password()
    {
        $plain = $this->_password_plain;
        // if $plain is NULL => is valid because the $hash was loaded from DB
        return (bool) ( ($plain === NULL) OR ( Valid::min_length($plain, 5) AND Valid::max_length($plain, 32) ) );
    }
    
  • I am sharing a site template that use authentication & internationalization for Kohana 3.2

    Github (any pull request will be more than welcome!) https://github.com/patricksebastien/kohana-3.2-example

    The website is online here: http://www.workinprogress.ca/ko32example/site/

    An article / tutorial on Kohana 3.2: http://www.workinprogress.ca/kohana32/

  • If you have a NULL database field and want to save NULL values, you need to set your value to be NULL before saving the model data. (Obviously). This is a bit of a problem when saving data from $_POST as the field value might be an empty string. This short snippet show how you can use a db filter to handle converting an empty string to a NULL value before saving data.

    public function filters()
    {
        return array(
            'field_name' => array(
                // Return a NULL value if empty string.
                array(function($value){
                    return ($value === '') ? NULL : $value;
                }, array(':value')),
            )
        );
    }
    
  • @badsyntax

    My approach:

    function save(Validation $validation = null) {
    
        if (empty($this->description)) { // `description` is just an example.
    
            unset($this->description);
    
        }
    
        parent::save($validation);
    
    }
    
  • This is what I almost always use in my projects:
    http://pastie.org/3200229 - extended HTML class, that shows post result message (error or success). Sample usage - <?php echo HTML::post_result($errors, isset($post['save'])) ?>
    http://pastie.org/3200238 - This is the object version of Arr::get function (suprised I couldn't find in the core)

  • My KOstache Dynamic templates from Database

    • is the best way I found, I know no other
    • template "View_Body" in this case is empty
    // Controller
    $view = new View_Body;            
    $template = $view->render( $model->emt_body );
    

    In class Kostache

    // from
    public funtion render()
    // to
    public function render($template_db = FALSE)
    
    // Dynamic templane
    if ($template_db === FALSE)
    {
         $partials[self::CONTENT_PARTIAL] = $this->_template;
    }
    else
    {           
        $partials[self::CONTENT_PARTIAL] = $template_db;
    } 
    
  • My Base Kohana Application which iam using on new Projects

    https://github.com/BlackScorp/application

    it includes HTML5 Boilerplate Twitter Bootstrap + Less jQuery/jQuery UI Modernizr

    and my best practice folder structure

  • I began writing a series of articles on creating CMS based on Kohana. Unfortunately unable to provide the English version is not, but you can use the Google translator. http://forum.kohanaframework.su/viewtopic.php?f=38&t=657

Howdy, Stranger!

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

In this Discussion