public
|
#
__construct( array $config = array() )
Constructor
Parameters
- $config
array - $config A named configuration array for object construction. name: the name
(optional) of the view (defaults to the view class name suffix). charset: the
character set to use for display escape: the name (optional) of the function to
use for escaping strings base_path: the parent path (optional) of the views
directory (defaults to the component folder) template_plath: the path (optional)
of the layout directory (defaults to base_path + /views/ + view name
helper_path: the path (optional) of the helper files (defaults to base_path +
/helpers/) layout: the layout (optional) to use to display the view
Since
3.0
Overrides
|
public
mixed
|
#
display( string $tpl = null )
Execute and display a template script.
Execute and display a template script.
Parameters
- $tpl
string - $tpl The name of the template file to parse; automatically searches through the
template paths.
Returns
mixed - A string if successful, otherwise an Error object.
Since
3.0
See
|
public
boolean
|
#
assign( )
Assigns variables to the view script via differing strategies.
Assigns variables to the view script via differing strategies.
This method is overloaded; you can assign all the properties of an object, an
associative array, or a single value by name.
You are not allowed to set variables that begin with an underscore; these are
either private properties for JView or private variables within the template
script itself.
$view = new JView;
$view->var1 = 'something';
$view->var2 = 'else';
$view->assign('var1', 'something');
$view->assign('var2', 'else');
$ary = array('var1' => 'something', 'var2' => 'else');
$view->assign($obj);
$obj = new stdClass;
$obj->var1 = 'something';
$obj->var2 = 'else';
$view->assign($obj);
Deprecated
3.0 Use native PHP syntax.
Returns
boolean - True on success, false on failure.
Since
3.0
|
public
boolean
|
#
assignRef( string $key, mixed & $val )
Assign variable for the view (by reference).
Assign variable for the view (by reference).
You are not allowed to set variables that begin with an underscore; these are
either private properties for JView or private variables within the template
script itself.
$view = new JView;
$view->assignRef('var1', $ref);
$view->var1 = &$ref;
Deprecated
3.0 Use native PHP syntax.
Parameters
- $key
string - $key The name for the reference in the view.
- $val
mixed - &$val The referenced variable.
Returns
boolean - True on success, false on failure.
Since
3.0
|
public
mixed
|
#
escape( mixed $var )
Escapes a value for output in a view script.
Escapes a value for output in a view script.
If escaping mechanism is either htmlspecialchars or htmlentities, uses $_encoding setting.
Parameters
- $var
mixed - $var The output to escape.
Returns
mixed - The escaped value.
Since
3.0
|
public
mixed
|
#
get( string $property, string $default = null )
Method to get data from a registered model or a property of the view
Method to get data from a registered model or a property of the view
Parameters
- $property
string - $property The name of the method to call on the model or the property to get
- $default
string - $default The name of the model to reference or the default value [optional]
Returns
mixed - The return value of the method
Since
3.0
Overrides
|
public
mixed
|
#
getModel( string $name = null )
Method to get the model object
Method to get the model object
Parameters
- $name
string - $name The name of the model (optional)
Returns
mixed - JModelLegacy object
Since
3.0
|
public
string
|
#
getLayout( )
Get the layout.
Returns
string - The layout name
Since
3.0
|
public
string
|
#
getLayoutTemplate( )
Get the layout template.
Returns
string - The layout template name
Since
3.0
|
public
string
|
#
getName( )
Method to get the view name
Method to get the view name
The model name by default parsed using the classname, or it can be set by
passing a $config['name'] in the class constructor
Returns
string - The name of the model
Throws
Since
3.0
|
public
JModelLegacy
|
#
setModel( JModelLegacy $model, boolean $default = false )
Method to add a model to the view. We support a multiple model single view
system by which models are referenced by classname. A caveat to the classname
referencing is that any classname prepended by JModel will be referenced by the
name without JModel, eg. JModelCategory is just Category.
Method to add a model to the view. We support a multiple model single view
system by which models are referenced by classname. A caveat to the classname
referencing is that any classname prepended by JModel will be referenced by the
name without JModel, eg. JModelCategory is just Category.
Parameters
- $model
JModelLegacy - $model The model to add to the view.
- $default
boolean - $default Is this the default model?
Returns
Since
3.0
|
public
string
|
#
setLayout( string $layout )
Sets the layout name to use
Sets the layout name to use
Parameters
- $layout
string - $layout The layout name or a string in format <template>:<layout
file>
Returns
string - Previous value.
Since
3.0
|
public
string
|
#
setLayoutExt( string $value )
Allows a different extension for the layout files to be used
Allows a different extension for the layout files to be used
Parameters
- $value
string - $value The extension.
Returns
string - Previous value
Since
3.0
|
public
|
#
setEscape( mixed $spec )
Sets the _escape() callback.
Sets the _escape() callback.
Deprecated
3.0 Override JViewLegacy::escape() instead.
Parameters
- $spec
mixed - $spec The callback for _escape() to use.
Since
3.0
|
public
|
#
addTemplatePath( mixed $path )
Adds to the stack of view script paths in LIFO order.
Adds to the stack of view script paths in LIFO order.
Parameters
- $path
mixed - $path A directory path or an array of paths.
Since
3.0
|
public
|
#
addHelperPath( mixed $path )
Adds to the stack of helper script paths in LIFO order.
Adds to the stack of helper script paths in LIFO order.
Parameters
- $path
mixed - $path A directory path or an array of paths.
Since
3.0
|
public
string
|
#
loadTemplate( string $tpl = null )
Load a template file -- first look in the templates folder for an
override
Load a template file -- first look in the templates folder for an
override
Parameters
- $tpl
string - $tpl The name of the template source file; automatically searches the template
paths and compiles as needed.
Returns
string - The output of the the template script.
Throws
Since
3.0
|
public
|
#
loadHelper( string $hlp = null )
Load a helper file
Parameters
- $hlp
string - $hlp The name of the helper source file automatically searches the helper paths
and compiles as needed.
Since
3.0
|
protected
|
#
_setPath( string $type, mixed $path )
Sets an entire array of search paths for templates or resources.
Sets an entire array of search paths for templates or resources.
Parameters
- $type
string - $type The type of path to set, typically 'template'.
- $path
mixed - $path The new search path, or an array of search paths. If null or false, resets
to the current directory only.
Since
3.0
|
protected
|
#
_addPath( string $type, mixed $path )
Adds to the search path for templates and resources.
Adds to the search path for templates and resources.
Parameters
- $type
string - $type The type of path to add.
- $path
mixed - $path The directory or stream, or an array of either, to search.
Since
3.0
|
protected
string
|
#
_createFileName( string $type, array $parts = array() )
Create the filename for a resource
Create the filename for a resource
Parameters
- $type
string - $type The resource type to create the filename for
- $parts
array - $parts An associative array of filename information
Returns
string - The filename
Since
3.0
|
public
mixed
|
#
getForm( )
Returns the form object
Returns
mixed - A JForm object on success, false on failure
Since
3.2
|
public
|
#
setDocumentTitle( string $title )
Sets the document title according to Global Configuration options
Sets the document title according to Global Configuration options
Parameters
- $title
string - $title The page title
Since
3.6
|
public
JDocument
|
$document
|
#
The active document object
The active document object
Since
3.0
|
protected
array
|
$_name
|
#
The name of the view
Since
3.0
|
protected
array
|
$_models
|
#
Registered models
Since
3.0
|
protected
string
|
$_basePath
|
#
The base path of the view
The base path of the view
Since
3.0
|
protected
string
|
$_defaultModel
|
#
The default model
Since
3.0
|
protected
string
|
$_layout
|
|
protected
string
|
$_layoutExt
|
#
Layout extension
Since
3.0
|
protected
string
|
$_layoutTemplate
|
#
Layout template
Since
3.0
|
protected
array
|
$_path
|
#
The set of search directories for resources (templates)
The set of search directories for resources (templates)
Since
3.0
|
protected
string
|
$_template
|
#
The name of the default template source file.
The name of the default template source file.
Since
3.0
|
protected
string
|
$_output
|
#
The output of the template script.
The output of the template script.
Since
3.0
|
protected
string
|
$_escape
|
#
Callback for escaping.
Deprecated
3.0
Since
3.0
|
protected
string
|
$_charset
|
#
Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
Charset to use in escaping mechanisms; defaults to urf8 (UTF-8)
Since
3.0
|