Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5. Some parts of this website may be subject to other licenses.

Abstract Class JView

Description

Base class for a Joomla View

Class holding methods for displaying presentation data.

Located in /joomla/application/component/view.php (line 31)

Class JObject   (Subpackage Base)

Abstract class JView   (Subpackage Application)
Variable Summary
Variable string $_basePath
Variable string $_layout
Variable string $_layoutExt
Variable array $_models
Variable array $_name
Variable array $_path
Method Summary
Constructor JView __construct ([ $config = array()])
Method void addHelperPath (string|array $path)
Method void addTemplatePath (string|array $path)
Method bool assign ()
Method bool assignRef (string $key, mixed &$val)
Method void display ([string $tpl = null])
Method mixed escape (mixed $var)
Method mixed &get (string $method, [string $model = null])
Method string getLayout ()
Method mixed &getModel ([string $name = null])
Method string getName ()
Method boolean loadHelper ([ $hlp = null], string $tpl)
Method string loadTemplate ([string $tpl = null])
Method void setEscape (mixed $spec)
Method string setLayout ( $layout, string $template)
Method string setLayoutExt (string $value)
Method object The &setModel ( &$model, [boolean $default = false], object $model)
Method void _addPath ( $type, string|array $path)
Method void _setPath (string $type, string|array $path)
Variables
string $_basePath = null (line 55)

The base path of the view

  • access: protected
string $_defaultModel = null (line 63)

The default model

  • access: protected
string $_layout = 'default' (line 71)

Layout name

  • access: protected
string $_layoutExt = 'php' (line 79)

Layout extension

  • access: protected
array $_models = array() (line 47)

Registered models

  • access: protected
array $_name = null (line 39)

The name of the view

  • access: protected
array $_path = array(
'template' => array(),'helper'=>array())
(line 87)

The set of search directories for resources (templates)

  • access: protected

Inherited Variables

Inherited from JObject

Variable JObject::$_errors
Methods
Constructor __construct (line 129)

Constructor

  • access: protected
JView __construct ([ $config = array()])
  • $config

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.
addHelperPath (line 528)

Adds to the stack of helper script paths in LIFO order.

void addHelperPath (string|array $path)
  • string|array $path: The directory (-ies) to add.
addTemplatePath (line 517)

Adds to the stack of view script paths in LIFO order.

void addTemplatePath (string|array $path)
  • string|array $path: The directory (-ies) to add.
assign (line 239)

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.

  1.  $view new JView();
  2.  
  3.  // assign directly
  4.   $view->var1 'something';
  5.  $view->var2 'else';
  6.  
  7.  // assign by name and value
  8.   $view->assign('var1''something');
  9.  $view->assign('var2''else');
  10.  
  11.  // assign by assoc-array
  12.   $ary array('var1' => 'something''var2' => 'else');
  13.  $view->assign($obj);
  14.  
  15.  // assign by object
  16.   $obj new stdClass;
  17.  $obj->var1 'something';
  18.  $obj->var2 'else';
  19.  $view->assign($obj);

  • return: True on success, false on failure.
  • access: public
bool assign ()
assignRef (line 310)

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.

  1.  $view new JView();
  2.  
  3.  // assign by name and value
  4.   $view->assignRef('var1'$ref);
  5.  
  6.  // assign directly
  7.   $view->ref =$var1;

  • return: True on success, false on failure.
  • access: public
bool assignRef (string $key, mixed &$val)
  • string $key: The name for the reference in the view.
  • mixed &$val: The referenced variable.
display (line 193)

Execute and display a template script.

  • see: fetch()
  • throws: object An JError object.
void display ([string $tpl = null])
  • string $tpl: The name of the template file to parse; automatically searches through the template paths.
escape (line 330)

Escapes a value for output in a view script.

If escaping mechanism is one of htmlspecialchars or htmlentities, uses $_encoding setting.

  • return: The escaped value.
mixed escape (mixed $var)
  • mixed $var: The output to escape.
get (line 347)

Method to get data from a registered model

  • return: The return value of the method
  • access: public
mixed &get (string $method, [string $model = null])
  • string $method: The name of the method to call on the model
  • string $model: The name of the model to reference [optional]

Redefinition of:
JObject::get()
Returns a property of the object or the default value if the property is not set.
getLayout (line 408)

Get the layout.

  • return: The layout name
  • access: public
string getLayout ()
getModel (line 393)

Method to get the model object

  • return: JModel object
  • access: public
mixed &getModel ([string $name = null])
  • string $name: The name of the model (optional)
getName (line 423)

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

  • return: The name of the model
  • since: 1.5
  • access: public
string getName ()
loadHelper (line 596)

Load a helper file

  • return: Returns true if the file was loaded
  • access: public
boolean loadHelper ([ $hlp = null], string $tpl)
  • string $tpl: The name of the helper source file ... automatically searches the helper paths and compiles as needed.
  • $hlp
loadTemplate (line 541)

Load a template file -- first look in the templates folder for an override

  • return: The output of the the template script.
  • access: public
string loadTemplate ([string $tpl = null])
  • string $tpl: The name of the template source file ... automatically searches the template paths and compiles as needed.
setEscape (line 506)

Sets the _escape() callback.

void setEscape (mixed $spec)
  • mixed $spec: The callback for _escape() to use.
setLayout (line 477)

Sets the layout name to use

  • return: Previous value
  • since: 1.5
  • access: public
string setLayout ( $layout, string $template)
  • string $template: The template name.
  • $layout
setLayoutExt (line 492)

Allows a different extension for the layout files to be used

  • return: Previous value
  • since: 1.5
  • access: public
string setLayoutExt (string $value)
  • string $value: The extension
setModel (line 457)

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.

  • return: added model
  • access: public
object The &setModel ( &$model, [boolean $default = false], object $model)
  • object $model: The model to add to the view.
  • boolean $default: Is this the default model?
  • &$model
_addPath (line 652)

Adds to the search path for templates and resources.

  • access: protected
void _addPath ( $type, string|array $path)
  • string|array $path: The directory or stream to search.
  • $type
_setPath (line 620)

Sets an entire array of search paths for templates or resources.

  • access: protected
void _setPath (string $type, string|array $path)
  • string $type: The type of path to set, typically 'template'.
  • string|array $path: The new set of search paths. If null or false, resets to the current directory only.

Inherited Methods

Inherited From JObject

 JObject::JObject()
 JObject::__construct()
 JObject::get()
 JObject::getError()
 JObject::getErrors()
 JObject::getProperties()
 JObject::getPublicProperties()
 JObject::set()
 JObject::setError()
 JObject::setProperties()
 JObject::toString()

Documentation generated on Tue, 29 Jan 2008 18:52:37 +0000 by phpDocumentor 1.3.1