3

コンポーネントで致命的なエラーが発生しました。コンポーネント名が com_Shirt で、これが私のコードであるとしましょう

<?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');
   }
}

コンポーネントビューに入ると、このエラーが発生します

"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"

これを修正するにはどうすればよいですか?

4

1 に答える 1

2

OK、それは私の悪いことでした。manifest.xmlで間違いを犯しました。

マニフェストには線がありませんでした

<folder>tables</folder>
于 2012-10-17T09:23:44.087 に答える