====== JView ====== {#JAPI Joomla.Framework Application JView #} JView is the base class for a Joomla! view. This class is designed to be used within the Joomla! MVC framework, although it can be used outside of it as well. It contains holding methods for displaying presentation data. ===== Methods ===== ^ Method ^ Description ^ | [[JView-__construct|{{references:Method.png?nolink}}]] [[JView-__construct|__construct]] | Constructor for the JView class. Setups up paths and configuration values. | | [[JView-addEscape|{{references:Method.png?nolink}}]] [[JView-addEscape|addEscape]] | Adds to the callbacks used when calling JView::escape(). | | [[JView-addHelperPath|{{references:Method.png?nolink}}]] [[JView-addHelperPath|addHelperPath]] | Adds to the stack of helper script paths in LIFO order. | | [[JView-addTemplatePath|{{references:Method.png?nolink}}]] [[JView-addTemplatePath|addTemplatePath]] | Adds to the stack of view script paths in LIFO order. | | [[JView-assign|{{references:Method.png?nolink}}]] [[JView-assign|assign]] | 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.
-
- // assign directly
- $view->var1 = 'something';
- $view->var2 = 'else';
-
- // assign by name and value
-
- // assign by assoc-array
- $ary = array('var1' => 'something', 'var2' => 'else');
-
- // assign by object
- $obj = new stdClass;
- $obj->var1 = 'something';
- $obj->var2 = 'else';
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.
-
- // assign by name and value
-
- // assign directly
- $view->ref =& $var1;
You can override the predefined escaping callbacks by passing added parameters as replacement callbacks.
- // use predefined callbacks
-
- // use replacement callbacks
- $value,
- 'stripslashes',
- 'htmlspecialchars',
- array('StaticClass', 'method'),
- array($object, $method)
- );
The model name by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor
| | [[JView-loadHelper|{{references:Method.png?nolink}}]] [[JView-loadHelper|loadHelper]] | Load a helper file | | [[JView-loadTemplate|{{references:Method.png?nolink}}]] [[JView-loadTemplate|loadTemplate]] | Load a template file -- first look in the templates folder for an override | | [[JView-setEscape|{{references:Method.png?nolink}}]] [[JView-setEscape|setEscape]] | Clears then sets the callbacks to use when calling JView::escape().Each parameter passed to this function is treated as a separate callback. For example:
- 'stripslashes',
- 'htmlspecialchars',
- array('StaticClass', 'method'),
- array($object, $method)
- );
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.
| | [[JView-_addPath|{{references:Method.png?nolink}}]] [[JView-_addPath|_addPath]] | Adds to the search path for templates and resources. | | [[JView-_setPath|{{references:Method.png?nolink}}]] [[JView-_setPath|_setPath]] | Sets an entire array of search paths for templates or resources. | ---- ~~DISCUSSION~~