How To Create A Joomla Component

Table of contents:

How To Create A Joomla Component
How To Create A Joomla Component

Video: How To Create A Joomla Component

Video: How To Create A Joomla Component
Video: Joomla Tutorial MVC Component step 1 basic component 2024, May
Anonim

Each component in the Joomla system has its own name. Each script code is located in two folders with the “com” prefix. As an example, let's create a component that reviews city entertainment establishments called "com_fun". To do this, you need to create folders with appropriate names in the "components" and "administratorcomponents" directories. Then in the "componentscom_fun" folder make the "fun.php" file, and in the administrator folder - "admin.fun.php".

How to create a joomla component
How to create a joomla component

Instructions

Step 1

In order for the component to display the welcome page, you need to open the "fun.php" file and write the required code: <? Php

defined (‘_ JEXEC’) or die (‘Denied’);

echo ‘Entertainment establishments’;

?> With the help of defined () we prohibit script execution from outside the Joomla environment. In the file "admin.fun.php" write a similar code. Now type in your browser https://site/index.php? Option = com_fun and you will see the component you just created.

Step 2

For a convenient transition to the component by the users of your site, you need to register it in the database. Using phpMyAdmin or its analogues used to execute MySQL queries on your hosting, execute the appropriate code: INSERT INTO 'jos_components' ('name', 'link', 'admin_menu_link', 'admin_menu_alt', 'option', 'admin_menu_img', 'params') VALUES (' Fun ',' option = com_fun ',' option = 'com_fun', 'Fun', 'com_fun', 'js / ThemeOffice / component.png', '');

Step 3

Go to your Joomla admin panel and create a link to the component in the main menu of your site. Go to "All menus" - "Main menu" - "Create" button. Select the created component, write the link name and alias.

Step 4

To create the toolbar, create a file “toolbar.fun.html.php” in “administrator / components / com_fun /”. Enter the appropriate JS code into it: <? Php

defined (‘_ JEXEC’) or die (‘Access denied’);

class TOOLBAR_fun {

function _NEW () {

JToolBarHelper:: save ();

JToolBarHelper:: apply ();

JToolBarHelper:: cancel (); }

function _DEFAULT () {

JToolBarHelper:: title (JText:: _ (‘Entertainment’), ‘generic.png’);

JToolBarHelper:: publishList ();

JToolBarHelper:: unpublishList ();

JToolBarHelper:: editList ();

JToolBarHelper:: deleteList ();

JToolBarHelper:: addNew (); }}

?>

Step 5

In the same folder create a file toolbar.fun.php and add to it: <? Php defined (‘_ JEXEC’) or die (‘Access is restricted’);

require_once (JApplicationHelper:: getPath (‘toolbar_html’));

switch ($ task) {

case ‘edit’:

case ‘add’:

TOOLBAR_fun:: _ NEW (); break;

default: TOOLBAR_fun:: _ DEFAULT ();

break; }

?>

Recommended: