Kohana: Buffering output on view and rendering it before in the source code

Sometimes you need to hack the order the source code is going to be rendered in a view: – You want an extra piece of CSS that only aplies to that view, so you think it's not worth creating a single CSS file and including in your mashed file –… Continue reading

Kohana 3.2.x: How to install taking advantage of submodules

I have improved my Kohana 3.2.x installation steps. This new way takes advantages of submodules with Git thus making your life easier when upgrading to a new version, assuming it's backwards compatible. This guide will assume you have the following structure for your website:   root/html   <!– public html folder… Continue reading

Kohana 3.2.6: Change Default Route

Let’s define a redirect module that will handle all requests that were not handled by any other controller. It will also be a good place to include a 404 page. modules/application/bootstrap.php Kohana::modules(array( . . ‘redirect’ => MODPATH . ‘redirect’, //Redirect module . . )); Route::set(‘default’, ‘(<request>)’, array( ‘request’ => ‘(.*)’,… Continue reading

Kohana 3: Default Template [step 3]

Create the view for the default template: /modules/common/views/template/default/default.php   <!DOCTYPE html> <head> <title>Default template</title> </head> <body> <?php echo $content; ?> </body> </html>      

Kohana 3.1.x: Common controller [step 2]

Define parent controller:     <?php defined(‘SYSPATH’) or die(‘No direct script access.’); class Controller_Common_Content extends Controller_Template { public $template                = ”; public $template_name           = ‘default’; public $layout                  = ‘default’; public $save_auto_render        = null; public $content                 = ‘{Do something to generate content}’; public function __construct(Request $request, Response $response) { parent::__construct($request, $response);… Continue reading

Kohana 3.2.x: Master Template Controller [step 1]

Let's create a content module that will handle both static and dynamic content: First enable the module: modules/application/bootstrap.php Kohana::modules(array( . . 'content' => MODPATH . 'content', // Content module . . ));   Second, create the master template controller: modules/content/classes/controller/base/template.php template_name = Kohana::$config->load('content.template.name'); $this->template = 'template/'.$this->template_name.'/index'; parent::before(); if ($this->auto_render) {… Continue reading

Kohana 3.2 tutorial : 2 – Setting up and basic Redirect controller

1. Edit bootstrap.php under “application”: —————————— date_default_timezone_set(‘America/Los_Angeles’); Kohana::init(array( ‘base_url’ => ‘/’, ‘index_file’ => ”, )); ——————– 2. Change the default route to a redirect controller (so we can deal with redirections for misplaced content/old content): Route::set(‘default’, ‘(<request>)’, array( ‘request’ => ‘(.*)’, )) ->defaults(array( ‘controller’ => ‘redirect’, ‘action’ => ‘index’, ));… Continue reading

Kohana 3.2 tutorial : 1 – Installation

1. Go to kohana’s website   http://kohanaframework.org/   2. Download latest stable   $ wget http://dev.kohanaframework.org/attachments/download/1670/kohana-3.2.0.zip –11:08:44– http://dev.kohanaframework.org/attachments/download/1670/kohana-3.2.0.zip => `kohana-3.2.0.zip’ Resolving dev.kohanaframework.org… 173.245.60.22, 173.245.61.87 Connecting to dev.kohanaframework.org[173.245.60.22]:80… connected. HTTP request sent, awaiting response… 200 OK Length: 1,043,281 [application/zip] 100%[==============================================================================================================================================================>] 1,043,281 1.53M/s 11:08:45 (1.53 MB/s) – `kohana-3.2.0.zip’ saved [1043281/1043281] 3. Uncompress… Continue reading

NGINX with Kohana 3.x friendly URLs

I really enjoy working with Kohana and since I got a server from one of the hosting companies listed at LowEndBox, I decided to ditch Apache and go with Nginx, thing is… I also like pretty URLs 🙂 As a backup from the comment located here: http://forum.kohanaframework.org/discussion/comment/11553/#Comment_11553 I’m copying and… Continue reading

My current methods while using Kohana 3.0.8 – part 1

I’ve finally decided to get started on documenting how I’ve been using this wonderful framework. So if you’re patient enough to deal with my crazy schedule (meaning this series may take a while to be finish), fasten your seatbelt: First of all: Know your environment (your public html folder, a… Continue reading