PHPEveryday.com PHP and Web Development Tutorial
What are you looking for?


Joomla - MVC: Creating Controller and Model for Back End


Joomla Back End MVC Step By Step Tutorial - Part 2: At previous post, we have talked about enter point use MVC. Now, we will create a controller and model (for retrieve data). What task this controller? You can read here. Create a file named "controller.php" within Joomla\administrator\components\com_hello. Enter following code:

joomla mvc back end controller

<?
defined('_JEXEC') or die('Restricted Access');
jimport('joomla.application.component.controller');

class HelloController extends JController
{
  function __construct ($default = array())
  {
  	parent::__construct( $default );
  }
  function showHellos()
  {
  	global $options;
	$db =& JFactory::getDBO();
	$query = "SELECT * FROM #__hello";
	$db->setQuery ( $query);
	$rows = $db->loadObjectList();
	if ($db->getErrorNum())
	{
	  echo $db->stderr();
	  return false;
	}
  	HTML_hellos::showHellos( $option, $rows );
  }
}
?>


Series this article:
Joomla - MVC: Reorganizing Back End Code
Joomla - MVC: Creating Controller and Model for Back End
Joomla - MVC: Creating View for Back End
Joomla - MVC: Adding Pagination for Back End
Joomla - MVC: Adding Element Paginating for Back End
Joomla - MVC: Creating Form Input Data for Back-End
Joomla - MVC: Saving Data for Back End
Joomla - MVC: Editing Data for Back-End
Joomla - MVC: Adding Delete Function at Back-End
Joomla - MVC: Controlling Publish State for Back-End


Tag: joomla, MVC, component, pattern, controller, model Category: PHP Framework Post : February 06th 2008 Read: 3,898 Bookmark and Share

blog comments powered by Disqus


Database Tutorial
  • Learn PHP MySQL
  • Learn PHP ADOdb
  • Learn PHP Data Object/PDO
  • Learn PHP XML
  • Learn PHP SimpleXML
Security Tutorial
  • Learn PHP Security
  • Learn HTTP Authentication
  • Learn PHPSecureSite
Framework Tutorial
  • Learn CodeIgniter
  • Learn Joomla
  • Learn Smarty
  • Learn Zend Framework
Template Tutorial
  • Learn Joomla Template
  • Learn WordPress Template
API Tutorial
  • Learn Facebook
JS Framework Tutorial
  • Learn MooTools
  • Learn JQuery
AJAX Tutorial
  • Learn AJAX in 10 Minutes
  • Learn AJAX Client Side
  • Learn AJAX PHP
  • Learn AJAX Remote Server
  • Learn AJAX Repetitive
  • Learn AJAX MySQL
  • Learn AJAX Grid
Web Services Tutorial
  • Learn Web Services NuSOAP
  • Learn Web Services WSDL
  • Learn Web Services WSDL Array
  • Learn Web Services .NET Grid
  • Learn Web Services WDDX
Package Post
  • Joomla Intro
  • Joomla Component
  • Joomla Module
  • Joomla MVC
  • Joomla MVC Backend
  • PostNuke Intro
  • Zend Framework Intro
  • Zend Framework Action
  • Zend Framework Database
  • Zend Framework Registry
  • Zend Framework Config
  • Zend Framework Login
  • Zend Framework Session
  • PHP Array Tips
  • PHP File Tips
  • PHP Email
  • PHP Ms Excel
  • PHP Pattern
  • PHP SMS
  • Flash Database
  • PHP Multitier
  • jQuery Introduction
  • jQuery Selectors
  • Portable Web Server
  • Web Mobile Intro
  • Drupal Installation
  • Drupal Configuration