Handles loading theme views and assets.

 Methods

Sets up the theme object.

__construct(array $config) 

If a config is given, it will not use the config file.

Parameters

$config

array

Optional config override

Magic method, returns the output of [static::render].

__toString() : string

uses \Fuel\Core\Theme::render

Returns

string

Sets the currently active theme.

active(string $theme) : array

Will return the currently active theme. It will throw a \ThemeException if it cannot locate the theme.

Parameters

$theme

string

Theme name to set active

Exceptions

\ThemeException

Returns

arrayThe theme array

Adds the given path to the theme search path.

add_path(string $path) : void

Parameters

$path

string

Path to add

Adds the given paths to the theme search path.

add_paths(array $paths) : void

Parameters

$paths

array

Paths to add

Gets an array of all themes in all theme paths, sorted alphabetically.

all() : array

Returns

array

Loads an asset from the currently loaded theme.

asset_path(string $path) : string

Parameters

$path

string

Relative path to the asset

Exceptions

\ThemeException

Returns

stringFull asset URL or path if outside docroot

Sets the fallback theme.

fallback(string $theme) : array

This theme will be used if a view or asset cannot be found in the active theme. Will return the fallback theme. It will throw a \ThemeException if it cannot locate the theme.

Parameters

$theme

string

Theme name to set active

Exceptions

\ThemeException

Returns

arrayThe theme array

Finds the given theme by searching through all of the theme paths.

find(string $theme) : string | false

If found it will return the path, else it will return false.

Parameters

$theme

string

Theme to find

Returns

stringfalsePath or false if not found

Gets a new instance of the Theme class.

forge(array $config) : \Fuel\Core\Theme

Parameters

$config

array

Optional config override

Returns

Get a set chrome view

get_chrome(string $section) : mixed

Parameters

$section

string

Name of the partial section in the template

Exceptions

\ThemeException

Returns

mixed

Get a value from the info array

get_info(mixed $var, mixed $default, mixed $theme) : mixed

Parameters

$var

mixed

$default

mixed

$theme

mixed

Exceptions

\ThemeException

Returns

mixed

Get a partial so it can be manipulated

get_partial(string $section, string $view) : \Fuel\Core\View

Parameters

$section

string

Name of the partial section in the template

$view

string

name of the view

Exceptions

\ThemeException

Returns

Get the template view so it can be manipulated

get_template() : string | \Fuel\Core\View

Exceptions

\ThemeException

Returns

Returns whether or not a section has partials defined

has_partials(string $section) : bool

Parameters

$section

string

Name of the partial section in the template

Returns

bool

Acts as a Multiton.

instance(string $name, array $config) : \Fuel\Core\Theme

Will return the requested instance, or will create a new named one if it does not exist.

Parameters

$name

string

The instance name

$config

array

Returns

Load in the theme.info file for the given (or active) theme.

load_info(string $theme) : array

Parameters

$theme

string

Name of the theme (null for active)

Exceptions

\ThemeException

Returns

arrayTheme info array

Returns the number of partials defined for a section

partial_count(string $section) : int

Parameters

$section

string

Name of the partial section in the template

Returns

int

Loads a presenter, and have it use the view from the currently active theme, the fallback theme, or the standard FuelPHP cascading file system

presenter(string $presenter, string $method, bool $auto_filter, string $view) : \Fuel\Core\Presenter

Parameters

$presenter

string

Presenter classname without View_ prefix or full classname

$method

string

Method to execute

$auto_filter

bool

Auto filter the view data

$view

string

Custom View to associate with this persenter

Returns

Render the partials and the theme template

render() : string | \Fuel\Core\View

Exceptions

\ThemeException

Returns

Save the theme.info file for the active (or fallback) theme.

save_info(string $type) : array

Parameters

$type

string

Name of the theme (null for active)

Exceptions

\ThemeException

Returns

arrayTheme info array

Sets a chrome for a partial

set_chrome(string $section, string | \Fuel\Core\View | \Fuel\Core\ViewModel | \Fuel\Core\Presenter $view, string $var) : \Fuel\Core\View | \Fuel\Core\ViewModel | \Fuel\Core\Presenter,

Parameters

$section

string

Name of the partial section in the template

$view

string\Fuel\Core\View\Fuel\Core\ViewModel\Fuel\Core\Presenter

chrome View, or name of the view

$var

string

Name of the variable in the chrome that will output the partial

Returns

\Fuel\Core\View\Fuel\Core\ViewModel\Fuel\Core\Presenter,the view partial

Set a value in the info array

set_info($var, $value, $type) : \Fuel\Core\Theme

Parameters

$var

$value

$type

Returns

Define a custom order for a partial section

set_order(string $section, mixed $order) 

Parameters

$section

string

name of the partial section

$order

mixed

Exceptions

\ThemeException

Sets a partial for the current template

set_partial(string $section, string | \Fuel\Core\View | \Fuel\Core\ViewModel | \Fuel\Core\Presenter $view, bool $overwrite) : \Fuel\Core\View

Parameters

$section

string

Name of the partial section in the template

$view

string\Fuel\Core\View\Fuel\Core\ViewModel\Fuel\Core\Presenter

View, or name of the view

$overwrite

bool

If true overwrite any already defined partials for this section

Returns

Sets a template for a theme

set_template(string $template) : \Fuel\Core\View

Parameters

$template

string

Name of the template view

Returns

Enable or disable the use of modules.

use_modules(bool | string $enable) : \Fuel\Core\Theme

If enabled, every theme view loaded will be prefixed with the module name, so you don't have to hardcode the module name as a view file prefix

Parameters

$enable

boolstring

enable if true or string, disable if false

Returns

Loads a view from the currently active theme, the fallback theme, or via the standard FuelPHP cascading file system for views

view(string $view, array $data, bool $auto_filter) : \Fuel\Core\View

Parameters

$view

string

View name

$data

array

View data

$auto_filter

bool

Auto filter the view data

Exceptions

\ThemeException

Returns

\Fuel\Core\ViewNew View object

Loads a viewmodel, and have it use the view from the currently active theme, the fallback theme, or the standard FuelPHP cascading file system

viewmodel(string $view, string $method, bool $auto_filter) : \Fuel\Core\View

deprecated 1.8

Parameters

$view

string

ViewModel classname without View_ prefix or full classname

$method

string

Method to execute

$auto_filter

bool

Auto filter the view data

Returns

\Fuel\Core\ViewNew View object

Creates a theme array by locating the given theme and setting all of the option.

create_theme_array(string $theme) : array

It will throw a \ThemeException if it cannot locate the theme.

Parameters

$theme

string

Theme name to set active

Exceptions

\ThemeException

Returns

arrayThe theme array

Find the absolute path to a file in a set of Themes.

find_file(string $view, array $themes) : string

You can optionally send an array of themes to search. If you do not, it will search active then fallback (in that order).

Parameters

$view

string

name of the view to find

$themes

array

optional array of themes to search

Exceptions

\ThemeException when not found

Returns

stringabsolute path to the view

Sets a theme.

set_theme(string $theme, string $type) : array

Parameters

$theme

string

Theme name to set active

$type

string

name of the internal theme array to set

Exceptions

\ThemeException

Returns

arrayThe theme array

 Properties

 

<p>Asset instance for this theme instance</p>

$asset : \Fuel\Core\Asset_Instance

 

<p>View instance for this theme instance template</p>

$template : \Fuel\Core\View

 

<p>Currently active theme</p>

$active : array

 

<p>Storage for defined partial chrome</p>

$chrome : array

 

<p>Theme config</p>

$config : array

 

<p>Fallback theme</p>

$fallback : array

 

All the Theme instances

$instances : array

 

<p>Order in which partial sections should be rendered</p>

$order : array

 

<p>Storage for defined template partials</p>

$partials : array

 

<p>Possible locations for themes</p>

$paths : array