dongwen1871 2010-05-11 06:42
浏览 26
已采纳

php编码中的问题

Hi there everyone im new to PHP and Joomla and I have developed a component in Joomla but my code is giving me errors. I have tried to solve the problem but I’am unable to solve it. So can anyone suggest me what is the problem with my code? Thanks in advance.

Here are my two files:

1st view.html.php

defined('_JEXEC') or die('=;)');

jimport('joomla.application.component.view');

class namnamViewlistrestaurant extends JView
{
    function display($tpl = null)
    {
        $item = 'item';
        RestUser::RestrictDirectAccess();
        //-- Custom css
        JHTML::stylesheet( 'style.css', 'components/com_namnam/assets/css/' );

        $cuisine=Lookups::getLookup('cuisine');
        $lists['cuisine'] = JHTML::_('select.genericlist', $cuisine, 'idcuisine[]', 'class="inputbox" size="7"', 'value', 'text', $item->idcuisine);

        $category=Lookups::getLookup('restcategory');
        $lists['category'] = JHTML::_('select.genericlist', $category, 'idcategory[]', 'class="inputbox" multiple="multiple" size="7"', 'value', 'text', $item->idcategory);

        $items  = & $this->get('Data');
        $pagination =& $this->get('Pagination');

        $lists = & $this->get('List');

        $this->assignRef('items', $items);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('lists', $lists);
        parent::display($tpl);

    }//function

}//class

And 2nd is listrestaurant.php

defined('_JEXEC') or die('=;)');

jimport('joomla.application.component.model');

class namnamModellistrestaurant extends JModel
{
    var $_data;
    var $_total = null;
    var $_pagination = null;

    function __construct()
    {
        parent::__construct();
        global $mainframe, $option;

        $limit      = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
        $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
        $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
        $this->setState('limit', $limit);
        $this->setState('limitstart', $limitstart);
    }

    function _buildQuery()
    {
        $where = array();
        $where[]=" idowner=".RestUser::getUserID()." ";
        if ($this->search)
        {
            $where[] = 'LOWER(name) LIKE \''. $this->search. '\'';
        }

        $where =( count($where) ) ? ' WHERE ' . implode( ' AND ', $where ) : '';
        $orderby = '';

        #_ECR_MAT_FILTER_MODEL1_

        if (($this->filter_order) && ($this->filter_order_Dir))
        {
            $orderby    = ' ORDER BY '. $this->filter_order .' '. $this->filter_order_Dir;
        }

        $this->_query = ' SELECT *'
        . ' FROM #__namnam_restaurants '
        . $where
        . $orderby
        ;

        return $this->_query;
    }


    function getData()
    {
        if (empty($this->_data))
        {
            $query = $this->_buildQuery();
            $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
        }
        return $this->_data;
    }

    function getList()
    {
        // table ordering
        $lists['order_Dir'] = $this->filter_order_Dir;
        $lists['order']     = $this->filter_order;

        // search filter
        $lists['search']= $this->search;

        return $lists;
    }

    function getTotal()
    {
        // Load the content if it doesn't already exist
        if (empty($this->_total))
        {
            $query = $this->_buildQuery();
            $this->_total = $this->_getListCount($query);
        }

        return $this->_total;
    }

    function getPagination()
    {
        // Load the content if it doesn't already exist
        if (empty($this->_pagination))
        {
            jimport('joomla.html.pagination');
            $this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
        }

        return $this->_pagination;
    }




}//class

And the errors are:

Notice: Trying to get property of non-object in C:\wamp\www amnam.com\components\com_namnam\views\listrestaurant\view.html.php on line 26

Notice: Trying to get property of non-object in C:\wamp\www amnam.com\components\com_namnam\views\listrestaurant\view.html.php on line 29

Notice: Undefined property: namnamModellistrestaurant::$search in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 38

Notice: Undefined property: namnamModellistrestaurant::$filter_order in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 48

Notice: Undefined property: namnamModellistrestaurant::$search in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 38

Notice: Undefined property: namnamModellistrestaurant::$filter_order in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 48

Notice: Undefined property: namnamModellistrestaurant::$filter_order_Dir in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 76

Notice: Undefined property: namnamModellistrestaurant::$filter_order in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 77

Notice: Undefined property: namnamModellistrestaurant::$search in C:\wamp\www amnam.com\components\com_namnam\models\listrestaurant.php on line 80

  • 写回答

2条回答 默认 最新

  • dongtiannai0654 2010-05-11 06:54
    关注

    I'd say the errors are pretty self explaining. What exactly is your problem?

    In view.html.php you have the variable $item and try to access the properties $item->idcuisine and $item->idcategory but actually, $item is just a string

     $item = 'item';
    

    and hence cannot have properties.


    In listrestaurant.php your class does not seem to have a property search or filter_order. You don't define them in your class, but I don't know about the parent class JModel.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题