JController

From Joomla! Documentation
Revision as of 10:29, 8 August 2009 by Batch1211 (Talk | contribs)

Jump to: navigation, search

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. Learn how to develop a component using MVC

Contents

Availability

From Joomla 1.5 Joomla 1.6

Defined in

/joomla/application/component/controller.php

Extends


Methods

Method name Description
__construct Constructor
addModelPath Add a path to the stack of model paths in LIFO order. Used in the getModel method.
addViewPath Add one or more view paths to the stack of view paths, in LIFO order. Used in the getView method.
authorize Checks if the user is authorized.
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.
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.
getModel Method to get a model object, loading it if required.
getName Method to get the controller name
getTask Get the last task that is or was to be performed
getTasks Gets the availbable tasks in the controller.
getView Method to get a reference to the current view and load it if necessary.
redirect Redirects the browser or returns false if no redirect is set.
registerDefaultTask Register the default task to perform if a mapping is not found. See execute
registerTask Register (map) a task to a method in the class.
setAccessControll Sets the access controll levels
setMessage Sets the internal message that is passed with a redirect. See the redirect and the setRedirect methods.
setRedirect Set a URL (and optionally a message) for browser redirection.

Importing

jimport( 'joomla.application.component.controller' );

The Joomla MVC Design Pattern

Model-View-Controller (MVC) is a set of design patterns, that are used to separate the different layers of your application.

  • The View displays the data of the model by passing it to a template. The view object can therefore access the data of the model. Joomla implements the basic functionality in the abstract JView class.
  • The Model stores the data of the application, and contains the business logic. Joomla implements the basic functionality in the abstract JModel class.
  • The Controller handles the user requests and evokes the model and the views to change it's state. Joomla implements the basic functionality in the JController class.

Learn more

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox