显示组件视图,并显示500内部服务器错误

编程入门 行业动态 更新时间:2024-10-26 12:35:51
本文介绍了显示组件视图,并显示500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Joomla组件开发教程之后,我遇到了问题.我遵循的与该问题有关的教程是此和此.

I have having issues following the tutorial of component development of Joomla. The tutorials I followed related to the issue are this and this.

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

I can view the default view properly, but when I click the new or edit and delete button, or when I browse too ../administrator/index.php?option=com_testimonials&view=testimonial&layout=edit I get that error.

我已经多次检查了代码,但是我找不到错误的地方.

I have rechecked the code so many times but I just can't find where I went wrong.

文件:controllers \ testimonial.php

File: controllers\testimonial.php

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

文件:models \ testimonial.php

File: models\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; } }

文件:views \ testimonial \ view.html.php

File: views\testimonial\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>

推荐答案

问题出在您的视图文件夹名称中.根据您指定的view = testimonial更改testimonials folder name to testimonial.

The problem is in your view folder name. Change testimonials folder name to testimonial as you have specified view=testimonial.

让我知道它是否不起作用.

let me know if it does not work.

更新: 如前所述,您的表格存在命名问题-

Update: As discussed your table having naming problem-

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

更多推荐

显示组件视图,并显示500内部服务器错误

本文发布于:2023-11-01 22:56:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550651.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   组件   错误   服务器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!