ThemeView Class Info:

Class Declaration:

class ThemeView extends View

File name:
Cake/View/ThemeView.php
Description:

Theme view class

Stub class for 2.1 Compatibility

Class Inheritance

View Object

Package
Cake.View

Properties:

Show/Hide parent properties
  • autoLayout boolean

    Turns on or off Cake's conventional mode of applying layout files. On by default. Setting to off means that layouts will not be automatically applied to rendered views.

  • Blocks ViewBlock

    ViewBlock instance.

  • cacheAction mixed

    Used to define methods a controller that will be cached.

  • _current string

    The currently rendering view file. Used for resolving parent files.

  • _currentType string

    Currently rendering an element. Used for finding parent fragments for elements.

  • elementCache string

    The Cache configuration View will use to store cached elements. Changing this will change the default configuration elements are stored under. You can also choose a cache config per element.

  • _eventManager CakeEventManager

    Instance of the CakeEventManager this View object is using to dispatch inner events. Usually the manager is shared with the controller, so it it possible to register view events in the controller layer.

  • _eventManagerConfigured boolean

    Whether the event manager was already configured for this object

  • ext string

    File extension. Defaults to Cake's template ".ctp".

  • hasRendered boolean

    True when the view has been rendered.

  • helpers mixed A single name as a string or a list of names as an array.

    An array of names of built-in helpers to include.

  • Helpers HelperCollection

    Helpers collection

  • _helpersLoaded boolean

    Indicate that helpers have been loaded.

  • layout string

    Name of layout to use with this View.

  • layoutPath string Path to Layout

    Path to Layout.

  • name string Name of controller

    Name of the controller.

  • _parents array

    The names of views and their parents used with View::extend();

  • passedArgs mixed

    Current passed params

  • _passedVars array

    List of variables to collect from the associated controller.

  • _paths array

    Holds an array of paths.

  • plugin string

    Name of the plugin.

  • request CakeRequest

    An instance of a CakeRequest object that contains information about the current request. This object contains all the information about a request and several methods for reading additional information about the request.

  • response CakeResponse

    Reference to the Response object

  • _scripts array

    Scripts (and/or other <head /> tags) for the layout.

  • _stack array

    Content stack, used for nested templates that all use View::extend();

  • subDir string

    Sub-directory for this view file. This is often used for extension based routing. Eg. With an xml extension, $subDir would be xml/

  • theme string

    Theme name.

  • uuids array

    List of generated DOM UUIDs.

  • validationErrors array

    Holds current errors for the model validation.

  • view string

    Name of view to use with this View.

  • viewPath string Path to View

    Path to View.

  • viewVars array

    Variables for the view

addScript

top

Adds a script block or other element to be inserted in $scripts_for_layout in the <head /> of a document layout

Parameters:
  • string $name required

    Either the key name for the script, or the script content. Name can be used to update/replace a script element.

  • string $content optional NULL

    The content of the script being added, optional.

Method defined in:
Cake/View/View.php on line 726
Return

void

Deprecated

Will be removed in 3.0. Supersceeded by blocks functionality.

See

View::start()

append

top

Append to an existing or new block. Appending to a new block will create the block.

Parameters:
  • string $name required

    Name of the block

  • string $value optional NULL

    The content for the block.

Method defined in:
Cake/View/View.php on line 631
Return

void

Throws

CakeException when you use non-string values.

See

ViewBlock::append()

assign

top

Set the content for a block. This will overwrite any existing content.

Parameters:
  • string $name required

    Name of the block

  • string $value required

    The content for the block.

Method defined in:
Cake/View/View.php on line 645
Return

void

Throws

CakeException when you use non-string values.

See

ViewBlock::assign()

blocks

top

Get the names of all the existing blocks.

Method defined in:
Cake/View/View.php on line 606
Return

array An array containing the blocks.

See

ViewBlock::keys()

__construct

top

Constructor

Parameters:
  • Controller $controller optional NULL

    A controller object to pull View::_passedVars from.

Method defined in:
Cake/View/View.php on line 308

dispatchMethod

top

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array

Parameters:
  • string $method required

    Name of the method to call

  • array $params optional array ( )

    Parameter list to use when calling $method

Method defined in:
Cake/Core/Object.php on line 110
Return

mixed Returns the result of the method call

element

top

Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.

This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send data to be used in the element. Elements can be cached improving performance by using the cache option.

  • cache - Can either be true, to enable caching using the config in View::$elementCache. Or an array If an array, the following keys can be used:
    • <code>config</code> - Used to store the cached element in a custom cache configuration.
    • <code>key</code> - Used to define the key used in the <a href="/class/cache#method-Cachewrite">Cache::write()</a>. It will be prefixed with <code>element_</code>
  • plugin - Load an element from a specific plugin. This option is deprecated, see below.
  • callbacks - Set to true to fire beforeRender and afterRender helper callbacks for this element. Defaults to false.

Parameters:
  • string $name required

    Name of template file in the/app/View/Elements/ folder, or MyPlugin.template to use the template element from MyPlugin. If the element is not found in the plugin, the normal view path cascade will be searched.

  • array $data optional array ( )

    Array of data to be made available to the rendered view (i.e. the Element)

  • array $options optional array ( )

    Array of options. Possible keys are:

Method defined in:
Cake/View/View.php on line 365
Return

string Rendered Element

Deprecated

The $options['plugin'] is deprecated and will be removed in CakePHP 3.0. Use Plugin.element_name instead.

end

top

End a capturing block. The compliment to View::start()

Method defined in:
Cake/View/View.php on line 667
Return

void

See

ViewBlock::start()

_evaluate

top

Sandbox method to evaluate a template / view script in.

Parameters:
  • string $___viewFn required

    Filename of the view

  • array $___dataForView required

    Data to include in rendered view. If empty the current View::$viewVars will be used.

Method defined in:
Cake/View/View.php on line 904
Return

string Rendered output

extend

top

Provides view or element extension/inheritance. Views can extends a parent view and populate blocks in the parent template.

Parameters:
  • string $name required

    The view or element to 'extend' the current one with.

Method defined in:
Cake/View/View.php on line 680
Return

void

Throws

LogicException when you extend a view with itself or make extend loops.

LogicException when you extend an element which doesn't exist

fetch

top

Fetch the content for a block. If a block is empty or undefined '' will be returned.

Parameters:
  • string $name required

    Name of the block

Method defined in:
Cake/View/View.php on line 657
Return

The block content or '' if the block does not exist.

See

ViewBlock::fetch()

__get

top

Magic accessor for helpers. Provides access to attributes that were deprecated.

Parameters:
  • string $name required

    Name of the attribute to get.

Method defined in:
Cake/View/View.php on line 787
Return

mixed

get

top

Returns the contents of the given View variable or a block. Blocks are checked before view variables.

Parameters:
  • string $var required

    The view var you want the contents of.

Method defined in:
Cake/View/View.php on line 593
Return

mixed The content of the named var if its set, otherwise null.

_getElementFileName

top

Finds an element filename, returns false on failure.

Parameters:
  • string $name required

    The name of the element to find.

Method defined in:
Cake/View/View.php on line 1056
Return

mixed Either a string to the element filename or false when one can't be found.

getEventManager

top

Returns the CakeEventManager manager instance that is handling any callbacks. You can use this instance to register any new listeners or callbacks to the controller events, or create your own events and trigger them at will.

Method defined in:
Cake/View/View.php on line 334
Return

CakeEventManager

_getExtensions

top

Get the extensions that view files can use.

Method defined in:
Cake/View/View.php on line 1042
Return

array Array of extensions view files use.

_getLayoutFileName

top

Returns layout filename for this template as a string.

Parameters:
  • string $name optional NULL

    The name of the layout to find.

Method defined in:
Cake/View/View.php on line 1013
Return

string Filename for layout file (.ctp).

Throws

MissingLayoutException when a layout cannot be located

getVar

top

Returns the contents of the given View variable(s)

Parameters:
  • string $var required

    The view var you want the contents of.

Method defined in:
Cake/View/View.php on line 582
Return

mixed The content of the named var if its set, otherwise null.

Deprecated

Will be removed in 3.0 Use View::get() instead.

getVars

top

Returns a list of variables available in the current View context

Method defined in:
Cake/View/View.php on line 571
Return

array Array of the set view variable names.

_getViewFileName

top

Returns filename of given action's template file (.ctp) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.ctp views.

Parameters:
  • string $name optional NULL

    Controller action to find template filename for

Method defined in:
Cake/View/View.php on line 934
Return

string Template filename

Throws

MissingViewException when a view file could not be found.

__isset

top

Magic isset check for deprecated attributes.

Parameters:
  • string $name required

    Name of the attribute to check.

Method defined in:
Cake/View/View.php on line 830
Return

boolean

loadHelper

top

Loads a helper. Delegates to the HelperCollection::load() to load the helper

Parameters:
  • string $helperName required

    Name of the helper to load.

  • array $settings optional array ( )

    Settings for the helper

Method defined in:
Cake/View/View.php on line 921
Return

Helper a constructed helper object.

See

HelperCollection::load()

loadHelpers

top

Interact with the HelperCollection to load all the helpers.

Method defined in:
Cake/View/View.php on line 846
Return

void

log

top

Convenience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.

Parameters:
  • string $msg required

    Log message

  • integer $type optional 2

    Error type constant. Defined in app/Config/core.php.

Method defined in:
Cake/Core/Object.php on line 149
Return

boolean Success of log write

_mergeVars

top

Merges this objects $property with the property in $class' definition. This classes value for the property will be merged on top of $class'

This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine this method as an empty function.

Parameters:
  • array $properties required

    The name of the properties to merge.

  • string $class required

    The class to merge the property with.

  • boolean $normalize optional true

    Set to true to run the properties through Set::normalize() before merging.

Method defined in:
Cake/Core/Object.php on line 187
Return

void

_paths

top

Return all possible paths to find view files in order

Parameters:
  • string $plugin optional NULL

    Optional plugin name to scan for view files.

  • boolean $cached optional true

    Set to true to force a refresh of view paths.

Method defined in:
Cake/View/View.php on line 1078
Return

array paths

pluginSplit

top

Splits a dot syntax plugin name into its plugin and filename. If $name does not have a dot, then index 0 will be null. It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot

Parameters:
  • string $name required

    The name you want to plugin split.

  • boolean $fallback optional true

    If true uses the plugin set in the current CakeRequest when parsed plugin is not loaded

Method defined in:
Cake/View/View.php on line 993
Return

array Array with 2 indexes. 0 => plugin name, 1 => filename

render

top

Renders view for given view file and layout.

Render triggers helper callbacks, which are fired before and after the view are rendered, as well as before and after the layout. The helper callbacks are called:

  • beforeRender
  • afterRender
  • beforeLayout
  • afterLayout

If View::$autoRender is false and no $layout is provided, the view will be returned bare.

View and layout names can point to plugin views/layouts. Using the Plugin.view syntax a plugin view/layout can be used instead of the app ones. If the chosen plugin is not found the view will be located along the regular view path cascade.

Parameters:
  • string $view optional NULL

    Name of view file to use

  • string $layout optional NULL

    Layout to use.

Method defined in:
Cake/View/View.php on line 451
Return

string Rendered Element

Throws

CakeException if there is an error in the view.

_render

top

Renders and returns output for given view filename with its array of data. Handles parent/extended views.

Parameters:
  • string $viewFile required

    Filename of the view

  • array $data optional array ( )

    Data to include in rendered view. If empty the current View::$viewVars will be used.

Method defined in:
Cake/View/View.php on line 864
Return

string Rendered output

Throws

CakeException when a block is left open.

renderCache

top

Render cached view. Works in concert with CacheHelper and Dispatcher to render cached view files.

Parameters:
  • string $filename required

    the cache file to include

  • string $timeStart required

    the page render start time

Method defined in:
Cake/View/View.php on line 541
Return

boolean Success of rendering the cached file.

renderLayout

top

Renders a layout. Returns output from _render(). Returns false on error. Several variables are created for use in layout.

  • title_for_layout - A backwards compatible place holder, you should set this value if you want more control.
  • content_for_layout - contains rendered view file
  • scripts_for_layout - Contains content added with addScript() as well as any content in the 'meta', 'css', and 'script' blocks. They are appended in that order.

Deprecated features:

  • $scripts_for_layout is deprecated and will be removed in CakePHP 3.0. Use the block features instead. meta, css and script will be populated by the matching methods on HtmlHelper.
  • $title_for_layout is deprecated and will be removed in CakePHP 3.0
  • $content_for_layout is deprecated and will be removed in CakePHP 3.0. Use the content block instead.

Parameters:
  • string $content required

    Content to render in a view, wrapped by the surrounding layout.

  • string $layout optional NULL

    Layout name

Method defined in:
Cake/View/View.php on line 500
Return

mixed Rendered output, or false on error

Throws

CakeException if there is an error in the view.

requestAction

top

Calls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.

Under the hood this method uses Router::reverse() to convert the $url parameter into a string URL. You should use URL formats that are compatible with Router::reverse()

Passing POST and GET data

POST and GET data can be simulated in requestAction. Use $extra['url'] for GET data. The $extra['data'] parameter allows POST data simulation.

Parameters:
  • mixed $url required

    String or array-based url. Unlike other url arrays in CakePHP, this url will not automatically handle passed and named arguments in the $url parameter.

  • array $extra optional array ( )

    if array includes the key "return" it sets the AutoRender to true. Can also be used to submit GET/POST data, and named/passed arguments.

Method defined in:
Cake/Core/Object.php on line 66
Return

mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.

_set

top

Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.

Parameters:
  • array $properties optional array ( )

    An associative array containing properties and corresponding values.

Method defined in:
Cake/Core/Object.php on line 164
Return

void

set

top

Allows a template or element to set a variable that will be available in a layout or other element. Analogous to Controller::set().

Parameters:
  • mixed $one required

    A string or an array of data.

  • mixed $two optional NULL

    Value in case $one is a string (which then works as the key). Unused if $one is an associative array, otherwise serves as the values to $one's keys.

Method defined in:
Cake/View/View.php on line 764
Return

void

__set

top

Magic accessor for deprecated attributes.

Parameters:
  • string $name required

    Name of the attribute to set.

  • string $value required

    Value of the attribute to set.

Method defined in:
Cake/View/View.php on line 815
Return

mixed

start

top

Start capturing output for a 'block'

Parameters:
  • string $name required

    The name of the block to capture for.

Method defined in:
Cake/View/View.php on line 617
Return

void

See

ViewBlock::start()

_stop

top

Stop execution of the current script. Wraps exit() making testing easier.

Parameters:
Method defined in:
Cake/Core/Object.php on line 137
Return

void

toString

top

Object-to-string conversion. Each class can override this method as necessary.

Method defined in:
Cake/Core/Object.php on line 41
Return

string The name of this class

uuid

top

Generates a unique, non-random DOM ID for an object, based on the object type and the target URL.

Parameters:
  • string $object required

    Type of object, i.e. 'form' or 'link'

  • string $url required

    The object's target URL

Method defined in:
Cake/View/View.php on line 743
Return

string