joomla3.0 - 未定义的属性:第 92 行 C:\..\..\Joomla\administrator\components\com_helloworld\views\helloworlds\tmpl\default.php 中的 stdClass::$contactno
问题描述
我在 helloworld 组件后端添加了一个contactno 字段。我添加一个不。行代码与添加类别相同。
文件位置:
admin/sql/install.mysql.utf8.sql ...我添加了一个contactno字段
admin/models/forms/helloworld.xml ...我在问候字段下方添加了一个contactno字段
<field name="contactno" type="text" default="Some text"
description="COM_HELLOWORLD_HELLOWORLD_CONTACT_DESC"
label="COM_HELLOWORLD_HELLOWORLD_CONTACT_LABEL"
size="10" />
- admin/models/fields/helloworld.php我在受保护的函数 getOptions()中添加了一个查询
$query->select('#__helloworld.id as id,greeting,#__helloworld.contactno as contactno,#__categories.title as category,catid');
- admin/views/helloworlds/tmpl/default.php ...我在作者字段下方的表格中添加了一个contactno 字段
<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
我的错误是什么...在哪里定义一个新字段...?
解决方案
我通过添加配置设置的关联数组来解决。文件位置是: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')
推荐阅读
- flutter - Flutter/Dart:创建一个 GridView,其中第一项是唯一的网格项
- vuejs2 - 将计算数据作为道具传递给子组件的模式(Promise 问题)
- mysql - 错误 pool.db:错误:ER_CON_COUNT_ERROR:使用 MySql 的连接太多
- javascript - can't get random # 通过 switch 语句
- java - 如何跨返回整数的不同类访问共享bean实例
- java - 使用 Java 进行自适应卡片渲染和创作
- java - 错误:运行 Spring Boot 应用程序时,由于缺少 EmbeddedServletContainerFactory bean,无法启动 EmbeddedWebApplicationContext
- python - 如何在 tkinter 中修复 scrolledtext 小部件的滚动条的位置?
- video - 即使在转码后,FFMPEG音频/视频在剪切和连接后也不同步
- java - 将功能移动到另一个活动后,无法从 Firestore 中检索文档