Home

Ksmarty

Ksmarty is a view replacement for Kohana3. It works with either Smarty2 or Smarty3 (currently in alpha)

Installation

  • Clone the repository and copy the 'smarty' directory to the 'modules' directory of your Kohana3 project.
  • Download Smarty and put the contents of the 'libs' folder to 'smarty/vendor/smarty'

Usage

Ksmarty mimics the usage of Kohana::View. Please note that, unlike the Kohana::View, template variables are global to all nested views.

Example controller:

<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Welcome extends Controller_Template
{
	public $template = 'welcome';

	public function action_index()
	{
                // Assign a value to the variable 'intro'
		$this->template->intro = 'Hello world!';

                // Create a nested view by loading a different template
		$this->template->content = View::factory('content');
	}
}
// End Welcome

Template: welcome.tpl

<html>
  <body>
    <h1>{$intro}</h1>
    <p>
      {$content}
    </p>
  </body>
</html>

Template: content.tpl

Yes, this works!

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.