2012-10-17 57 views
0

我有问题遵循Joomla组件开发教程。我跟随的相关教程是thisthis组件视图与500内部服务器显示错误

我可以正常查看默认视图,但是当我单击neweditdelete按钮时,或者当我也浏览../administrator/index.php?option=com_testimonials&view=testimonial&layout=edit时,出现该错误。

我重新检查了这么多次的代码,但我无法找到我出错的地方。

文件:控制器\ testimonial.php

class TestimonialsControllerTestimonial extends JControllerForm 
{ 
    //Nothing yet as per the tutorial 
} 

文件:型号\ testimonial.php

class TestimonialsModelTestimonial extends JModelAdmin { 
    public function getTable($type = 'Testimonials', $prefix = 'TestimonialsTable', $config = array()) { 
     return JTable::getInstance($type, $prefix, $config); 
    } 

    public function getForm($data = array(), $loadData = true) { 
     // Get the form 
     $form = $this -> loadForm('com_testimonials.testimonial', 'testimonial', array('control' => 'jform', 'load_data' => $loadData)); 
     if(empty($form)) { 
      return false; 
     } 
     return $form; 
    } 

    protected function loadFormData() { 
     // Check the session for previously entered form data 
     $data = JFactory::getApplication() -> getUserState('com_testimonials.edit.testimonial.data', array()); 
     if(empty($data)) { 
      $data = $this -> getItem(); 
     } 
     return $data; 
    } 
} 

文件:观点\告别赛\ view.html.php

class TestimonialsViewTestimonial extends JView { 

    protected $form = null; 

    public function display($tpl = null) { 
     //get the data 
     $form = $this -> get('Form'); 
     $item = $this -> get('Item'); 

     $this -> form = $form; 
     $this -> item = $item; 
     $this -> addToolbar(); 

     parent::display($tpl); 
     $this -> setDocument(); 


    } 

    protected function addToolBar() { 
     JRequest::setVar('hidemainmenu', true); 
     $isNew = ($this -> item -> id == 0); 
     JToolBarHelper::title($isNew ? JText::_('COM_TESTIMONIALS_MANAGER_TESTIMONIAL_NEW') : JText::_('COM_TESTIMONIALS_MANAGER_TESTIMONIAL_EDIT'), 'testimonials'); 
     JToolBarHelper::save('testimonial.save'); 
     JToolBarHelper::cancel('testimonial.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE'); 

    } 

    protected function setDocument() { 
     $isNew = ($this -> item -> id < 1); 
     $document = JFactory::getDocument();   
     $document -> setTitle($isNew ? JText::_('COM_TESTIMONIALS_TESTIMONIAL_CREATING') : JText::_('COM_TESTIMONIALS_TESTIMONIAL_EDITING')); 
    } 
} 

文件:views\testimonial\tmpl\edit.php

<form action="<?php echo JRoute::_('index.php?option=com_testimonials&layout=edit&id='.(int) $this -> item -> id); ?>" method="post" name="adminForm" id="testimonial-form"> 
    <fieldset class="adminForm"> 
     <legend><?php echo JText::_('COM_TESTIMONIALS_TESTIMONIAL_DETAILS'); ?></legend> 
     <ul class="adminFormList"> 
      <?php foreach($this -> form -> getFieldset() as $field): ?> 
       <li><?php echo $field -> label; echo $field -> input; ?></li> 
      <?php endforeach; ?> 
     </ul> 
    </fieldset> 
    <div> 
     <input type="hidden" name="task" value="testimonial.edit" /> 
     <?php echo JHtml::_('form.token'); ?> 
    </div> 
</form> 
+0

原因之一时,它只能说明部分是你的网址可能TMPL =组分的表。 – Irfan

+0

@Irfan,这是一个命名问题,我确定我已经将我的问题改变为真正的问题。我很抱歉的混淆。 – mrN

+0

np,看看我的答案。 – Irfan

回答

1

问题出在您的视图文件夹名称中。如您指定view = testimonial一样更改testimonials folder name to testimonial

让我知道它是否无效。

更新: 作为讨论其命名problem-

class TestimonialsTableTestimonial extends JTable 
{ 
public function __construct(&$db) { 
parent::__construct('#__testimonial_table', 'id', $db); 
} 

function bind($array, $ignore = '') 
{ 

return parent::bind($array, $ignore); 
} 

} 
+0

对不起,这也是错字。其实我也有另一种看法'褒奖',也就是设置为默认视图。 – mrN

+0

@mrN:你现在得到什么错误?检查您的控制器/ testimonial.php – Irfan

+0

500内部服务器错误,当我浏览../administrator/index.php?option=com_testimonials&view=testimonial&layout=edit – mrN