почему-то нигде не могу загрузить свою модель.не в моем контроллере, не в моем представлении.вот мой код
<?php
/**
* Joomla! 1.5 component ad_maker
*
* @version $Id: view.html.php 2011-06-16 12:55:02 svn $
* @author
* @package Joomla
* @subpackage ad_maker
* @license GNU/GPL
*
* makes ads
*
* This component file was created using the Joomla Component Creator by Not Web Design
* http://www.notwebdesign.com/joomla_component_creator/
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// Import Joomla! libraries
jimport( 'joomla.application.component.view');
class Ad_makerViewDefault extends JView {
function display($tpl = null) {
$model =& $this->getModel('Ad_maker');
$model->get('AdList');
parent::display($tpl);
}
}
?>
Моя модель находится в
com_ad_maker / models / ad_maker.php
<?php
/**
* Joomla! 1.5 component ad_maker
*
* @version $Id: ad_maker.php 2011-06-16 12:55:02 svn $
* @author
* @package Joomla
* @subpackage ad_maker
* @license GNU/GPL
*
* makes ads
*
* This component file was created using the Joomla Component Creator by Not Web Design
* http://www.notwebdesign.com/joomla_component_creator/
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// Import Joomla! libraries
jimport('joomla.application.component.model');
jimport('joomla.application.component.controller' );
jimport('joomla.database.table');
class Ad_makerModelAd_maker extends JModel {
function __construct() {
parent::__construct();
}
public function getTest()
{
echo "this is a test";
}
public function store()
{
$post = $this->_state->get('request');
$db =& JFactory::getDBO();
$url = "images/ads/" . $_FILES["file"]["name"];
$durl = $_SERVER['DOCUMENT_ROOT']."/images/ads/" . $_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"],$durl);
$query = "INSERT INTO #__ad_maker (ad_name, image_url, tags) VALUES ('$post[ad_name]', '$url', '$post[tags]')";
$db->setQuery($query);
$result = $db->query();
}
public function getAdList()
{
$query = "SELECT * FROM #__ad_maker";
$db->setQuery($query);
$result = $db->query();
return $result;
}
public function deleteAd($id)
{
$query = "DELETE * FROM #__ad_maker WHERE id = $id";
$db->setQuery($query);
$result = $db->query();
}
}
?>
Я получаю следующую ошибку
Fatal error: Call to a member function get() on a non-object in /home/website/public_html/administrator/components/com_ad_maker/views/default/view.html.php on line 26
вот мой контроллер
com_ad_maker / controller.php
<?php
/**
* Joomla! 1.5 component ad_maker
*
* @version $Id: controller.php 2011-06-16 12:55:02 svn $
* @author
* @package Joomla
* @subpackage ad_maker
* @license GNU/GPL
*
* makes ads
*
* This component file was created using the Joomla Component Creator by Not Web Design
* http://www.notwebdesign.com/joomla_component_creator/
*
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.controller' );
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'helper.php' );
/**
* ad_maker Controller
*
* @package Joomla
* @subpackage ad_maker
*/
class Ad_makerController extends JController {
/**
* Constructor
* @access private
* @subpackage ad_maker
*/
function __construct() {
//Get View
if(JRequest::getCmd('view') == '') {
JRequest::setVar('view', 'default');
JRequest::setVar('view', 'default');
}
$this->item_type = 'Default';
parent::__construct();
}
function add()
{
$post = JRequest::get('post');
$model =& $this->getModel('Ad_maker');
$model->setState('request', $post);
$model->store();
}
}
?>