Components

What Are Components?

A component is in fact a seperate application. You can think of a component as something that has its own functionality, its own database tables and its own presentation. So if you install a component, you add an application to your website. Examples of components are a forum, a newsletter, a community system, a photo gallery, etc. You could think of all of these as being a seperate application. Everyone of these would make perfectly sense as a stand-alone system. A component will be shown in the main part of your website and only one component will be shown. A menu is then in fact nothing more then a switch between different components.

Structure

Components can be structured in a couple ways. Technically all that is needed for a component to work is the following:

/{your hub install}
  /components
     /com_{your component}
       {your component}.php

Note that the PHP file must be named the same as your component. So, if you had a blog component, the setup would look as follows:

/{your hub install}
  /components
     /com_blog
       blog.php

A more typical Joomla! component structure is presented below. Here, it follows a stricter convention of keeping the models, views, and controller separate.

/{your hub install}
  /components
     /com_{your component}
       /helpers
       /models
       /views
       index.html
       controller.php
       router.php
       {your component}.php

Examples

A basic component (no MVC)

To be written

A basic component (MVC)

Model-view-controller is a design pattern for software development. Typically, the model is data in a database. There may be multiple views of the model. The controller sets up the work flow for interacting with the views.

A excellent tutorial: Joomla component with a model-view-controller design

It includes simple, clear examples that you can download.

A component with tabs representing views

This example shows how to build a very basic component with tabbed sub-navigation. Each tab links to a different method and associated view in the controller.

The following component uses a very basic separation of logic from views. It does not follow the Joomla! 1.5 preferred MVC structure for components. The following component does not include administration code — It is a front-end component only.

Note

This is not a complete installer package. Do not use Joomla’s administrative installer. To install, simply extract the file into your hub’s components directory.

A component with tabs representing plugin views

To be written

Created on , Last modified on

  • Copyright © 2022 Hubzero
  • Powered by Hubzero®