User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Start building simple component

 

-create a folder com_helloworld in the Administrator/Components

-create a folder and files by topic.Chapter 6 - Introduction Component Development

-open the helloworld.php file and code this

com_helloworld/helloworld.php

 

<?php
defined('_JEXEC') or die('Restricted access'); 


if(!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
}


$c = JRequest::getVar('c');
if($c == '') {
        $c = 'hello'; 
}


$path = JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.$c.'.php';
if (file_exists($path)) {
        require_once $path;
} else {
      
        JError::raiseError('500',JText::_('JTUNKNOW_COMPONENT').' '.$c.' '.$path);
}

$classname = 'HelloworldController'.$c; 
$controller = new $classname(); 
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
?>

 

-Create a file in a folder named hellp.php controllers class name must be specified in the form of posts. Chapter 7 - Structure for building class Component Development.

Then enter the code com_helloworld/controllers/hellp.php

<?php
defined('_JEXEC') or die('Restricted access'); 

class HelloworldControllerHello extends JControllerLegacy 
{
        
     
        function display($cachable = false, $urlparams = array()) 
        {
      
                JRequest::setVar('view','hello');
                parent::display($cachable, $urlparams); 
        }
    
}
?>

 To create a display in the View by to create folders as we set the set the view controller in the controller will create a folder named hello hello and interior will create a file named. view.html.php And create a folder for files tmpl default.php layout to create a basic layout files first. 

com_helloworld /views/hello/view.html.php

<?php
defined('_JEXEC') or die('Restricted access');

class HelloworldViewHello extends JViewLegacy 
{

        function display($tpl = null)
        {
                parent::display($tpl);
        }
    
}
?>

 

com_helloworld/views/hello/tmpl/default.php

<?php 

defined('_JEXEC') or die('Restricted access');

?>

Hello world

 

Summary File

com_helloworld/helloworld.php

com_helloworld/controllers/hello.php

com_helloworld/views/hello/view.html.php

com_helloworld/views/hello/tmpl/default.php

 

 

Chapter 9 - Creating XML Form Component Development