Skip to content
This repository has been archived by the owner on Nov 24, 2019. It is now read-only.

v1 Front controller

vee w, edited this page May 1, 2014 · 5 revisions

Fuel Start use 2 level template layout. First one is 'the page template' and second is 'the content template'.

The blue area is 'the page template' which is whole page template. It is start from doctype until </html>

'The content template' will be put into webpage layout (the page template) with generatePage() method.

To do this, you must extend frontend controller to \Controller_BaseController.

Example:

class Controller_Homepage extends \Controller_BaseController 
{
    public function action_index() 
    {
        // set head output here (title, meta, link, js)
        $output['page_title'] = $this->generateTitle('Home page');

        return $this->generatePage('front/templates/home/home_v', $output, false);
    }
}

From the example above. the view of this controller->method is in public/themes/<theme_name>/front/templates/home/home_v.php

The $output variable is for easily to understand that it will be work with views, or theme and $data will be use with data base actions (insert/update/delete/select).

generateTitle method is for generate that page name with site name

generateTitle($title, $name_position = 'last');

$title is title name of current page

$name_position can be 'first' or 'last'

Example:

$this->generateTitle('page name', 'first'); // return "site name | page name"
$this->generateTitle('page name', 'last'); // return "page name | site name"