未定义的属性:第92行的C:\ .. \ .. \ Joomla \ administrator \ components \ com_helloworld \ views \ helloworlds \ tmpl \ default.php中的stdClass :: $ contactno

时间:2018-05-17 10:11:23

标签: joomla3.0 joomla-component

  

我在helloworld组件后端添加了一个contactno字段。我加了一个。行代码与添加类别相同。

     

文件loactions:

     
      
  1. admin / sql / install.mysql.utf8.sql ...我添加 contactno字段

  2.   
  3. admin / models / forms / helloworld.xml ...我在问候语字段下面添加一个contactno字段

  4.   
<field name="contactno" type="text" default="Some text" 
 description="COM_HELLOWORLD_HELLOWORLD_CONTACT_DESC"
label="COM_HELLOWORLD_HELLOWORLD_CONTACT_LABEL" 
size="10" />
  
      
  1. admin / models / fields / helloworld.php 我在受保护的函数getOptions()
  2. 中添加查询   
$query->select('#__helloworld.id as id,greeting,#__helloworld.contactno as contactno,#__categories.title as category,catid');   
  
      
  1. admin / views / helloworlds / tmpl / default.php ...我在作者字段<下添加了一个contactno字段 < / LI>   
<th width="30%">
                <?php echo JHtml::_('searchtools.sort', 'COM_HELLOWORLD_CONTACTNO', 'contactno', $listDirn, $listOrder); ?>
            </th>
  

td 低于作者

<td align="center"> <?php echo $row->contactno; ?> </td>

  

当我运行helloworld组件时,我得到错误

     

注意:第92行的C:\ xampp \ htdocs \ Joomla \ administrator \ components \ com_helloworld \ views \ helloworlds \ tmpl \ default.php中的未定义属性:stdClass :: $ contactno

     

我的错误是什么......在哪里定义一个新领域......?

1 个答案:

答案 0 :(得分:0)

  

我通过添加配置设置的关联数组来解决。   文件位置为: admin / models / helloworlds.php    我在数组中添加了一个新字段 contactno 并在查询中进行了更新      getListQuery()

 $query->select('a.id as id, a.greeting as greeting, a.contactno as contactno, a.published as published, a.created as created')