大家好我有新的PHP和Joomla,我已经在Joomla开发了一个组件,但是我的代码给了我错误。我试图解决这个问题,但我无法解决它。所以任何人都可以告诉我我的代码有什么问题?提前致谢。php编码中的问题
这里是我的两个文件:
1 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
和2是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
,并且错误是:
注意:试图在C中获取非对象的属性: \ wamp \ www \ namnam.com \ components \ com_namnam \ views \ listrestaurant \ view.html.php on line 26
注意:试图获取C:\ wamp \ www \ namnam.com中非对象的属性\ components \ com_namnam \ views \ listrestaurant \ view.html.php on line 29
注意:未定义的属性:namnamModellistrestaurant :: $搜索C:\ wamp \ www \ namnam.com \ components \ com_namnam \ models \ listrestaurant .PHP在线38
公告:未定义的属性:用C namnamModellistrestaurant :: $ filter_order:\ WAMP \ WWW \ namnam.com \分量\ com_namnam \型号\ listrestaurant.php上线48
注意:Undefined属性:namnamModellistrestaurant :: $在C:\ wamp \ www \ namnam.com \ components \ com_namnam \ models \ listrestaurant.php中搜索38行
注意:未定义的属性:namnamModellistrestaurant :: $ filter_order in在线48上的C:\ wamp \ www \ namnam.com \ components \ com_namnam \ models \ listrestaurant.php
注意:未定义的属性:namnamModellistrestaurant :: $ filter_order_Dir在C:\ wamp \ www \ namnam.com \ components \ com_namnam \ models \ listrestaurant.php on line 76
注意:未定义的属性:namnamModellistrestaurant :: $ filter_order在C:\ wamp \ www \ namnam.com \ components \ com_namnam \ models \ listrestaurant.php on line 77
公告:未定义的属性:namnamModellistrestaurant ::在C $搜索:\ WAMP \ WWW \ namnam.com \分量\ com_namnam \型号\上线listrestaurant.php 80
如果你是PHP的新手,你不应该使用Joomla。 – 2010-05-11 06:46:36