Components
Search
- Version 4
- by (unknown)
- Version 5
- by (unknown)
Deletions or items before changed
Additions or items after changed
1 | === What Are Components? === | |||
---|---|---|---|---|
2 | ||||
3 | 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. | |||
4 | ||||
5 | === Structure === | |||
6 | ||||
7 | Components can be structured in a couple ways. Technically all that is '''needed''' for a component to work is the following: | |||
8 | ||||
9 | {{{ | |||
10 | /{your hub install} | |||
11 | /components | |||
12 | /com_{your component} | |||
13 | {your component}.php | |||
14 | }}} | |||
15 | ||||
16 | 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: | |||
17 | ||||
18 | {{{ | |||
19 | /{your hub install} | |||
20 | /components | |||
21 | /com_blog | |||
22 | blog.php | |||
23 | }}} | |||
24 | ||||
25 | A more typical Joomla! component structure is presented below. Here, it follows a stricter convention of keeping the models, views, and controller separate. | |||
26 | ||||
27 | {{{ | |||
28 | /{your hub install} | |||
29 | /components | |||
30 | /com_{your component} | |||
31 | /helpers | |||
32 | /models | |||
33 | /views | |||
34 | index.html | |||
35 | controller.php | |||
36 | router.php | |||
37 | {your component}.php | |||
38 | }}} | |||
39 | ||||
40 | === Examples === | |||
41 | ||||
42 | ==== A basic component (no MVC) ==== | |||
43 | ||||
44 | ''To be written'' | |||
45 | ||||
46 | ==== A basic component (MVC) ==== | |||
47 | Model-view-controller is a design pattern for software development. Typically, the model | |||
48 | - | is data in a database. |
+ | is data in a database. There may be multiple views of the model. The controller
|
49 | sets up the work flow for interacting with the views. | |||
50 | ||||
51 | A excellent tutorial: | |||
52 | [http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1#Articles_in_this_Series Joomla component with a model-view-controller design] | |||
53 | ||||
54 | - | It includes simple, clear examples.
|
+ | It includes simple, clear examples that you can download.
|
55 | ==== A component with tabs representing views ==== | |||
56 | ||||
57 | 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. | |||
58 | ||||
59 | 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. | |||
60 | ||||
61 | * Download: [[File(com_example.zip)]] | |||
62 | ||||
63 | {{{#!wiki note | |||
64 | '''Note''' | |||
65 | ||||
66 | 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. | |||
67 | }}} | |||
68 | ||||
69 | ==== A component with tabs representing plugin views ==== | |||
70 | ||||
71 | ''To be written'' |