FUEL CMS User Guide : Version 1.5.2


Fuel Layouts Class

This class extends the Fuel_base_library class.

Properties Reference

Property Default Value Description
public
default_layout main Default layout folder
layouts_folder _layouts Layout folder
layouts
array('main' => array
(
    [fields] => array
        (
            [Header] => array
                (
                    [type] => fieldset
                    [label] => Header
                    [class] => tab
                )

            [page_title] => array
                (
                    [label] => Page title
                )

            [meta_description] => array
                (
                    [label] => Meta description
                )

            [meta_keywords] => array
                (
                    [label] => Meta keywords
                )

            [Body] => array
                (
                    [type] => fieldset
                    [label] => Body
                    [class] => tab
                )

            [heading] => array
                (
                    [label] => Heading
                )

            [body] => array
                (
                    [label] => Body
                    [type] => textarea
                    [description] => Main content of the page
                )

            [body_class] => array
                (
                    [label] => Body class
                )

        )

)
, '301_redirect' => array
(
    [label] => 301 Redirect
    [fields] => array
        (
            [copy] => array
                (
                    [type] => copy
                    [label] => This layout will do a 301 redirect to another page.
                )

            [redirect_to] => array
                (
                    [label] => Redirect to
                )

        )

)
, 'alias' => array
(
    [label] => Alias
    [fields] => array
        (
            [copy] => array
                (
                    [type] => copy
                    [label] => This layout is similar to a 301 redirect but the location of the page does not change and 
the page content from the specifiec location is used to render the page. ) [alias] => array ( [label] => ) ) ) , '404_error' => array ( [label] => 404 Error [fields] => array ( [heading] => array ( [label] => Heading ) [body] => array ( [label] => Body ) ) ) , 'sitemap_xml' => array ( [label] => sitemap.xml [fields] => array ( [copy] => array ( [type] => copy [label] => This layout is used to generate a sitemap. For this page to appear, a sitemap.xml must not exist on the server. ) [frequency] => array ( [type] => select [options] => array ( [always] => always [hourly] => hourly [daily] => daily [weekly] => weekly [monthly] => monthly [yearly] => yearly [never] => never ) [value] => always [label] => Frequency ) ) ) , 'robots_txt' => array ( [label] => robots.txt [fields] => array ( [copy] => array ( [type] => copy [label] => This layout is used to generate a robots.txt file. For this page to appear, a robots.txt must not exist on the server. ) [body] => array ( [type] => textarea [label] => Body [value] => User-agent: * Disallow: /fuel/ [class] => no_editor ) ) ) , 'none' => array ( [label] => None [fields] => array ( [copy] => array ( [type] => copy [label] => This layout is the equivalent of having no layout assigned. ) [body] => array ( [type] => textarea [label] => Body ) ) ) , )
Layout object initialization parameters
blocks
array('text' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'email' => array
(
    [group] => Forms
    [class] => Email_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'textarea' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'select' => array
(
    [group] => Forms
    [class] => Select_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'checkbox' => array
(
    [group] => Forms
    [class] => Checkbox_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'enum' => array
(
    [group] => Forms
    [class] => Enum_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

    [label] => enum
)
, 'multi' => array
(
    [group] => Forms
    [class] => Multi_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'number' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'password' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'phone' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'date' => array
(
    [group] => Forms
    [class] => Date_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'antispam' => array
(
    [group] => Forms
    [class] => Antispam_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'hidden' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'file' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'section' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'fieldset' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'copy' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, 'radio' => array
(
    [group] => Forms
    [class] => Base_field_layout
    [filepath] => libraries/layouts
    [module] => forms
    [model] => array
        (
            [forms] => forms_model
        )

)
, )
Block object initialization parameters
hidden
array()
An array of layouts to not display in the CMS dropdown
protected
_layouts N/A Layout objects

Function Reference [+]

$this->fuel->layouts->initialize([$config=array()])

Initialize the user preferences. Accepts an associative array as input, containing display preferences.

Returns

void

Parameters

(array) $config config preferences

$this->fuel->layouts->add('$name', '$layout', ['$type'=NULL])

Adds a layout object.

Returns

mixed  Returns the Fuel_layouts object instance for method chaining

Parameters

(string) $name The name of the layout
(object) $layout A layout object or an array of initialization parameters

$this->fuel->layouts->remove('$name')

Removes a layout object.

Returns

void

Parameters

(string) $name The name of the layout

$this->fuel->layouts->get(['$layout'=NULL], ['$type'='page'])

Returns a layout object.

Returns

mixed  Returns either an array of Fuel_Layout objects or a single Fuel_layout object

Parameters

(string) $layout The name of the layout
(string) $type The type of layout to return. Options are "page" or "block"

$this->fuel->layouts->options_list(['$blocks'=FALSE], ['$group'=''])

Returns a key/value array good for creating form select options.

Returns

array

Parameters

(boolean) $blocks use block layouts or page (optional)
(string) $group the name of the group to filter the options by (optional)

$this->fuel->layouts->create('$name', [$init=array()])

Creates a new layout object.

Returns

object

Parameters

(string) $name The name of the layout
(array) $init Layout object initialization parameters (optional)


Fuel Layout Class

Can be retrieved by $this->fuel->layouts->get('{location}').

This class extends the Fuel_base_library class.

Properties Reference

Property Default Value Description
public
name none The name of the layout
label none The label to display with the layout in the select list as seen in the CMS
description none A description of the layout which will be rendered as a copy field in the form
file none The layout view file name
module app The module that the layout's view file belongs to
hooks
array()
Hooks to run before and after the rendering of a page. Options are "pre_render" and "post_render"
fields
array()
The fields to associate with the layout. Must be in the Form_builder array format
field_values
array()
The values to assign to the fields
folder _layouts The folder to look in for the layout view files
group none The group name to associate with the layout
import_field body The field to be used when importing a view file
include_pagevar_object none Determines whether to include a single variable of object of $pagevar that includes all the pages variables
preview_image none An image for previewing the layout
double_parse none Double parse pages created in the CMS to allow for variables set in the CMS to cascade up to the layout. Valid options are TRUE/FALSE (AUTO only applies to the global FUEL configuration)
hidden none Determines if the layout should be hidden from the layout dropdown select in the CMS
parser none The parsing engine to use

Function Reference [+]

$layout->initialize([$params=array()])

Initialize the user preferences. Accepts an associative array as input, containing display preferences.

Returns

void

Parameters

(array) $params config preferences

$layout->set_file('$layout')

Sets the layout view file. Do not include the '_layout' folder with the name.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $layout The name of the layout view file

$layout->view_path()

Returns the view file path to the layout.

Returns

string

$layout->set_name('$name')

Sets the layout name. Usually the same as the layout view file.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $name The name of the layout.

$layout->name()

Returns the layout name.

Returns

string

$layout->set_label('$label')

Sets the layout label which is usually a friendlier version of the name (e.g. if the layout's name is "main", the layout may be "Main").

Returns

void

Parameters

(string) $label The name of the layout.

$layout->label()

Returns the layout label.

Returns

string

$layout->set_description('$description')

Sets the layouts description which will be displayed when editing a page in the CMS.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $description The layout's description

$layout->description()

Returns the layouts description.

Returns

string

$layout->set_fields('$fields')

Sets the layout's fields.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $fields The name of the layout

$layout->fields()

Returns the layout's fields.

Returns

array

$layout->process_fields([$fields=array()])

Processes the layout's fields.

Returns

array

Parameters

(array) $fields The new fields to process

$layout->set_folder('$folder')

Sets the views folder the layout exists in. Default is the views/_layouts folder.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $folder The name of the folder

$layout->folder()

Returns the views folder the layout exists in.

Returns

string

$layout->set_module('$module')

Sets the module the layout belongs to.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $module The name of the folder

$layout->module()

Returns the module the layout belongs to.

Returns

string

$layout->set_group('$group')

Sets the group the layout belongs to.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $group The name of the folder

$layout->group()

Returns the group the layout is associated with.

Returns

string

$layout->import_field()

Returns the field to import the main content of the page into.

Returns

string

$layout->set_import_field('$key')

Sets the field to import the main content of the page into.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $key The name of the field to use

$layout->include_pagevar_object()

Returns a boolean value as to whether to include the $pagevar object when rendering a page.

Returns

boolean

$layout->set_include_pagevar_object('$bool')

Sets a boolean value as to whether to include the $pagevar object when rendering a page.

Returns

object  reference to this Fuel_layout object

Parameters

(boolean) $bool Determines whether to include the pagevar object or not

$layout->add_field('$key', '$val')

Adds a single field to the layout (See the Form_builder) class for more info.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $key The name of the layout field
(string) $val The array of field configuration values

$layout->add_fields('$fields')

Adds multiple form fields to the layout (See the Form_builder) class for more info.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $fields The name of the layout field

$layout->set_field_values($values)

Sets the field values for the fields.

Returns

object  reference to this Fuel_layout object

Parameters

(array) $values A key/value array of field values

$layout->set_field_value('$key', $value)

Sets a field value.

Returns

object  reference to this Fuel_layout object

Parameters

(key) $key The name of the field
(array) $value The value of the field

$layout->field_values()

Returns layout's field values.

Returns

array

$layout->field_value('$key')

Returns a single field value.

Returns

void

Parameters

(key) $key The name of the field

$layout->set_hook('$type', $hook)

Sets a callback hook to be run via "pre" or "post" rendering of the page.

Returns

object  reference to this Fuel_layout object

Parameters

(key) $type The type of hook (e.g. "pre_render" or "post_render")
(array) $hook An array of hook information including the class/callback function. More here

$layout->call_hook(['$hook'='pre_render'], [$params=array()])

Calls a specified hook to be run.

Returns

void

Parameters

(hook) $hook The type of hook (e.g. "pre_render" or "post_render")
(array) $params An array of additional parameters to pass to the hook method/function

$layout->pre_process($vars)

Placeholder hook - used for processing variables specific to a layout.

Returns

array

Parameters

(array) $vars variables for the view

$layout->post_process('$output')

Placeholder hook - used for processing the final output one last time.

Returns

string

Parameters

(string) $output final processed output

$layout->process_saved_values($values)

Placeholder hook - used for processing the saved values of the layout.

Returns

array

Parameters

(array) $values process values array

$layout->post_process_saved_values($values)

Placeholder hook - used for processing the saved values of the layout after the page has been saved and has an ID.

Returns

array

Parameters

(array) $values process values array

$layout->validate($vars)

Placeholder - used for validating layout variables.

Returns

boolean

Parameters

(array) $vars variables to validate

$layout->preview_image()

Returns the image for the layout.

Returns

string

$layout->set_preview_image('$image')

Sets the preview image for the layout.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $image the preview image

$layout->is_double_parse()

Returns the double parse values.

Returns

boolean

$layout->set_double_parse('$parse')

Sets whether CMS pages should be double parsed to allow for variables set in the CMS fields to bubble up to the layout.

Returns

object  reference to this Fuel_layout object

Parameters

(boolean) $parse 

$layout->is_hidden()

Returns whether this layout should be hidden from the layout dropdown select.

Returns

boolean

$layout->set_hidden('$hidden')

Sets whether this layout should be hidden from the layout dropdown select.

Returns

object  reference to this Fuel_layout object

Parameters

(boolean) $hidden 

$layout->parser()

Returns the parsing engine name (not the object).

Returns

string

$layout->set_parser(['$parser'=NULL])

Sets the parsing engine.

Returns

object  reference to this Fuel_layout object

Parameters

(string) $parser the parser type of either "dwoo" or "twig"

$layout->parse('$str', [$vars=array()])

Parses the template based on the parsing engine.

Returns

void

Parameters

(string) $str the string to parse


Fuel Module Layout Class

Can be retrieved by $this->fuel->layouts->get('{location}').

This class extends the Fuel_layout class.

Properties Reference

Property Default Value Description
public
model none The model to use for retrieving data
list_block none The block name to use for the list view
item_block none The block name for the detailed item view
key_field slug The key field to use for querying a single record
segment 3 The segment to use as the parameter to query
item_where
array()
Additional item query where parameters
list_where
array()
Additional list query where parameters

Function Reference [+]

$layout->set_model('$model')

Sets a model value.

Returns

object  reference to this Fuel_block_layout object

Parameters

(string) $model The model

$layout->set_list_block('$block')

Sets the list block.

Returns

object  reference to this Fuel_block_layout object

Parameters

(string) $block The list block

$layout->set_item_block('$block')

Sets the item block.

Returns

object  reference to this Fuel_block_layout object

Parameters

(string) $block The item block

$layout->set_key_field('$field')

Sets the key field for querying.

Returns

object  reference to this Fuel_block_layout object

Parameters

(string) $field The key field for querying (e.g. 'slug')

$layout->set_segment('$segment')

Sets the segment index that will contain the URI slug value.

Returns

object  reference to this Fuel_block_layout object

Parameters

(int) $segment The index that will contain the slug value

$layout->set_item_where('$where')

Sets additional item query where parameters.

Returns

object  reference to this Fuel_block_layout object

Parameters

(int) $where The index that will contain the slug value

$layout->set_list_where('$where')

Sets additional list query where parameters.

Returns

object  reference to this Fuel_module_layout object

Parameters

(int) $where The index that will contain the slug value

$layout->pre_process($vars)

Placeholder hook - used for processing variables specific to a layout.

Returns

array

Parameters

(array) $vars variables for the view


Fuel Block Layout Class

Can be retrieved by $this->fuel->layouts->get('{location}', TRUE).

This class extends the Fuel_layout class.

Properties Reference

Property Default Value Description
public
context none
model none
method none
field none

Function Reference [+]

$layout->set_context('$context')

Sets the context of the form fields (e.g. $block[0]).

Returns

object  reference to this Fuel_block_layout object

$layout->context()

Returns the context of the form fields (e.g. $block[0]).

Returns

array

$layout->set_model('$model')

Sets the model o retrieve the value data.

Returns

object  reference to this Fuel_block_layout object

$layout->model()

Returns the model used to retrieve the value data.

Returns

mixed

$layout->set_method('$method')

Sets the method used retrieve the data from the model.

Returns

object  reference to this Fuel_block_layout object

$layout->method()

Returns the method used to retrieve the data from the model.

Returns

array

$layout->fields()

Returns the layout's fields.

Returns

array

$layout->process_fields([$fields=array()])

Processes the layout's fields.

Returns

array

Parameters

(array) $fields The new fields to process