gpt4 book ai didi

joomla - 错误 : Call to a member function getKeyName() - component for Joomla 2. 5

转载 作者:行者123 更新时间:2023-12-02 02:12:04 25 4
gpt4 key购买 nike

我的组件出现 fatal error 。假设组件名称是 com_shirts,这是我的代码我的代码在 administrator/component/com_shirts/controllers/code.php

<?php
defined('_JEXEC') or die;

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

class ShirtsControllerCode extends JControllerForm{
protected $view_list = 'codes';
}

我的代码在 administrator/component/com_shirts/controllers/codes.php

<?php
defined('_JEXEC') or die;

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

class ShirtsControllerCodes extends JControllerAdmin{
protected $text_prefix = 'COM_SHIRTS';

function getModel($name='Code', $prefix='ShirtsModel', $config=array('ignore_request'=>TRUE)){
$model = parent::getModel($name, $prefix, $config);

return $model;
}
}

我的代码在 administrator/component/com_shirts/models/code.php

<?php
defined('_JEXEC') or die;

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

class ShirtsModelCode extends JModelAdmin{

function getTable($type='Code', $prefix='ShirtsTable', $config=array()){
return JTable::getInstance($type, $prefix, $config);
}

function getForm($data=array(), $loadData=TRUE){
$form = $this->loadForm();

return $form;
}
}

我的代码在 administrator/component/com_shirts/models/codes.php

<?php
defined('_JEXEC') or die;

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

class ShirtsModelCodes extends JModelList{

function getItems(){
$items = parent::getItems();

foreach($items as &$item){
$item->url = 'index.php?option=com_shirts&amp;task=code.edit&amp;code_id='.$item->code_id;
$item->event_description = substr($item->code_desc, 0);
}

return $items;
}

function getListQuery(){
$query = parent::getListQuery();

$query->select('*');
$query->from('#__shirts_codes');

return $query;
}
}

我的代码在 administrator/component/com_shirts/tables/code.php

<?php
defined('_JEXEC') or die;

class ShirtsTableCode extends JTable{

public function __construct(&$dbo){
parent::__construct('#__shirts_codes', 'code_id', $dbo);
}
}

我的代码在 administrator/component/com_shirts/views/codes/view.html.php

<?php
defined('_JEXEC') or die;

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

class ShirtsViewCodes extends JView{
protected $codes;

function display($tmpl=NULL){

$this->codes = $this->get('Items');

$this->toolbar();

parent::display($tmpl);
}

function toolbar(){
JToolBarHelper::title(JText::_('HEADER'));

JToolBarHelper::addNew('code.add');
JToolBarHelper::editList('code.edit');

JToolBarHelper::divider();

JToolBarHelper::publishList('codes.publish');
JToolBarHelper::unpublishList('codes.unpublish');

JToolBarHelper::divider();

JToolBarHelper::archiveList('codes.archive');
JToolBarHelper::trash('codes.trash');

JToolBarHelper::divider();

}
}

我的代码在 administrator/component/com_shirts/views/codes/tmpl/default.php

<?php defined('_JEXEC') or die; ?>

<form action="index.php?option=com_shirts&amp;view=codes" method="post" name="adminForm" id="adminForm">

<table class="adminlist">
<thead>
<tr>
<th style="width: 1%">
<input type="checkbox" name="checkall-toggle" value="" onclick="checkAll(this)" />
</th>
</tr>
</thead>
<tbody>
<?php foreach($this->codes as $i=>$code):
$url = 'index.php?option=com_shirts&amp;view=code&amp;task=code.edit&amp;event_id='.$code->code_id;
?>
<tr class="row<?php echo $i%2; ?>">
<td class="center">
<?php echo JHtml::_('grid.id', $i, $code->code_id); ?>
</td>

<td class="center">
<a href="<?php echo $code->url; ?>">
<?php echo $this->escape($code->code); ?>
</a>
</td>

<td>
<a href="<?php echo $code->url; ?>">
<?php echo $this->escape($code->code_desc); ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
</form>

我的代码在 administrator/component/com_shirts/views/code/tmpl/edit.php

<?php defined('_JEXEC') or die; ?>
<form
method="post"
name="adminForm"
class="form-validate"
action="index.php?option=com_shirts&amp;code_id=<?php echo $this->code->code_id; ?>"
>

<div class="width-50 fltlft">
<fieldset class="adminform">
<ul class="adminformlist">
<?php foreach($this->form->getFieldset('required') as $field): ?>
<li>
<?php echo $field->label; ?>
<?php echo $field->input; ?>
</li>
<?php endforeach; ?>
</fieldset>
</div>

<div class="width-40 fltrt">
<fieldset class="adminform">
<ul class="adminformlist">
<?php foreach($this->form->getFieldset('optional') as $field): ?>
<li>
<?php echo $field->label; ?>
<?php echo $field->input; ?>
</li>
<?php endforeach; ?>
</ul>
</fieldset>
</div>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

我的代码在 administrator/component/com_shirts/views/code/view.html.php

<?php
defined('_JEXEC') or die;

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

class ShirtsViewCode extends JView{
protected $code;
protected $form;

function display($tmpl=NULL){

$this->event = $this->get('Item');
$this->form = $this->get('Form');

$this->toolbar();

parent::display($tmpl);
}

function toolbar(){
if($this->code->code_id){
JToolBarHelper::title(JText::_('COM_SHIRTS_EDIT'));
}else{
JToolBarHelper::title(JText::_('COM_SHIRTS_ADD'));
}

JToolBarHelper::apply('code.apply', 'JTOOLBAR_APPLY');
JToolBarHelper::save('code.save', 'JTOOLBAR_SAVE');
JToolBarHelper::save2new('code.save', 'JTOOLBAR_SAVE_AND_NEW');

JToolBarHelper::divider();

JToolBarHelper::cancel('code.cancel');
}
}

当我进入组件 View 时,出现此错误

"PHP Fatal error: Call to a member function getKeyName() on a non-object in /var/www/joomla/libraries/joomla/application/component/controllerform.php on line 393"

我该如何解决这个问题?

最佳答案

好吧,那是我的错,我在 manifest.xml 中出错了,现在一切都好了

list 中没有行

<folder>tables</folder>

关于joomla - 错误 : Call to a member function getKeyName() - component for Joomla 2. 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12313272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com