|
|
| (6 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| − | '''JController''' is an abstract class which provides the basic functionality for your own Controller classes which your create for your components. The Controller is part of Joomla's MVC Pattern. [[Developing_a_Model-View-Controller_Component_-_Part_1|Learn how to develop a component using MVC]]
| + | This class is available in the following Joomla versions:- |
| − | | + | <splist showpath=notparent /> |
| − | ===Availability===
| + | <noinclude>[[Category:Platform JClasses]][[Category:JController]]</noinclude> |
| − | {{JVer|1.5|From Joomla 1.5}} {{JVer|1.6|Joomla 1.6}}
| + | |
| − | | + | |
| − | ===Defined in===
| + | |
| − | /joomla/application/component/controller.php
| + | |
| − | | + | |
| − | ===Extends===
| + | |
| − | * [[JObject]]
| + | |
| − | | + | |
| − | | + | |
| − | ===Methods===
| + | |
| − | {| class="wikitable"
| + | |
| − | |-
| + | |
| − | !Method name
| + | |
| − | !Description
| + | |
| − | |-
| + | |
| − | |[[JController/__construct|__construct]]
| + | |
| − | |Constructor
| + | |
| − | |-
| + | |
| − | |[[JController/addModelPath|addModelPath]]
| + | |
| − | |Add a path to the stack of model paths in LIFO order. Used in the [[JController/getModel|getModel]] method.
| + | |
| − | |-
| + | |
| − | |[[JController/addViewPath|addViewPath]]
| + | |
| − | |Add one or more view paths to the stack of view paths, in LIFO order. Used in the [[JController/getView|getView]] method.
| + | |
| − | |-
| + | |
| − | |[[JController/authorize|authorize]]
| + | |
| − | |Checks if the user is authorized.
| + | |
| − | |-
| + | |
| − | |[[JController/display|display]]
| + | |
| − | |Creates the default view, if possible created the default model and pushes it into the view, sets the view-layout and finally displays the view. This method is often overwritten in the concrete Controller.
| + | |
| − | |-
| + | |
| − | |[[JController/execute|execute]]
| + | |
| − | |Searches for the method that is mapped to the task and executes it. Public methods of controller are automatically mapped to the task of the same name.
| + | |
| − | |-
| + | |
| − | |[[JController/getModel|getModel]]
| + | |
| − | |Method to get a model object, loading it if required.
| + | |
| − | |-
| + | |
| − | |[[JController/getName|getName]]
| + | |
| − | |Method to get the controller name
| + | |
| − | |-
| + | |
| − | |[[JController/getTask|getTask]]
| + | |
| − | |Get the last task that is or was to be performed
| + | |
| − | |-
| + | |
| − | |[[JController/getTasks|getTasks]]
| + | |
| − | |Gets the availbable tasks in the controller.
| + | |
| − | |-
| + | |
| − | |[[JController/getView|getView]]
| + | |
| − | |Method to get a reference to the current view and load it if necessary.
| + | |
| − | |-
| + | |
| − | |[[JController/redirect|redirect]]
| + | |
| − | |Redirects the browser or returns false if no redirect is set.
| + | |
| − | |-
| + | |
| − | |[[JControlelr/registerDefaultTask|registerDefaultTask]]
| + | |
| − | |Register the default task to perform if a mapping is not found. See [[JController/execute|execute]]
| + | |
| − | |-
| + | |
| − | |[[JController/registerTask|registerTask]]
| + | |
| − | |Register (map) a task to a method in the class.
| + | |
| − | |-
| + | |
| − | |[[JController/setAccessControll|setAccessControll]]
| + | |
| − | |Sets the access controll levels
| + | |
| − | |-
| + | |
| − | |[[JController/setMessage|setMessage]]
| + | |
| − | |Sets the internal message that is passed with a redirect. See the [[JController/redirect|redirect]] and the [[JController/setRedirect|setRedirect]] methods.
| + | |
| − | |-
| + | |
| − | |[[JController/setRedirect|setRedirect]]
| + | |
| − | |Set a URL (and optionally a message) for browser redirection.
| + | |
| − | |}
| + | |
| − | ===Importing===
| + | |
| − | <source lang="php">jimport( 'joomla.application.component.controller' );</source> | + | |
| − | | + | |
| − | ===Adding support for new document types===
| + | |
| − | New document types are added by creating a new sub-directory under the /libraries/joomla/document/ directory with the same name as the type. For example, to add a document type called "mytype", you would create the directory /libraries/joomla/document/mytype. In this directory you must then create a file called mytype.php which will contain the class definition for JDocumentMytype which extends JDocument. Look at the code for existing document types to see what needs to be done.
| + | |
| − | ===See also===
| + | |
| − | * [http://api.joomla.org/Joomla-Framework/Application/JController.html JController on api.joomla.org]
| + | |
| − | <noinclude>[[Category:Development]][[Category:Framework]][[Category:JController]]</noinclude> | + | |