Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 乔姆拉找不到我的模特了_Php_Joomla_Joomla1.5 - Fatal编程技术网

Php 乔姆拉找不到我的模特了

Php 乔姆拉找不到我的模特了,php,joomla,joomla1.5,Php,Joomla,Joomla1.5,由于某些原因,我无法在任何地方加载我的模型。不在我的控制器中,不在我的视图中。这是我的密码 <?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 compone

由于某些原因,我无法在任何地方加载我的模型。不在我的控制器中,不在我的视图中。这是我的密码

<?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/controller.php


视图的名称为
默认值
,因此Joomla将尝试从组件的
模型
目录加载名为
默认值
的模型。将
com\u-ad\u-maker/models/ad\u-maker.php
更改为
com\u-ad\u-maker/models/default.php
,并将
class-ad\u-makermodel-maker扩展到
class-ad\u-makermodel-default扩展了JModel
,它应该可以工作。

视图的名称是
default
,因此,Joomla将尝试从组件的
models
目录加载名为
default
的模型。将
com_ad_maker/models/ad_maker.php
更改为
com_ad_maker/models/default.php
,并将
class ad_makermodeld_maker扩展JModel
更改为
class ad_makermodel default扩展JModel
,它应该可以用于add()函数,但不在contstruct函数中工作。如果我的视图和模型必须是某个名称,那么为什么我必须将模型的名称放在getModel('name')参数中?您不必使用
$this->getModel('Ad_maker')
在view.html.php文件中,仅在controller.php文件中。在view.html.php中,您可以执行
$ad_list=$this->get('AdList')然后
$this->assign('AdList',$adu list)
在default.php文件中使用getAdList()的结果。感谢您的回答-它帮助我在昨晚晚些时候回到了精神障碍的轨道上。我发现的其他所有东西都是视图,或者完全不好(例如,在所有东西中都包含()模型的PHP文件!)它适用于add()函数,但不适用于contstruct函数。如果我的视图和模型必须是某个名称,那么为什么我必须将模型的名称放在getModel('name')参数中?您不必使用
$this->getModel('Ad_maker')
在view.html.php文件中,仅在controller.php文件中。在view.html.php中,您可以执行
$ad_list=$this->get('AdList')然后
$this->assign('AdList',$adu list)
在default.php文件中使用getAdList()的结果。感谢您的回答-它帮助我在昨晚晚些时候回到了精神障碍的轨道上。我发现的所有其他内容都没有看到,要么就是视图,要么就是非常糟糕(例如,在所有内容中都包含()模型的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
<?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();      
   }
}
?>