将新视图添加到自定义Joomla组件

时间:2013-10-01 17:06:26

标签: joomla joomla2.5

我正在尝试向自定义组件添加新视图。我已按照post进行了操作,但说明书对我来说并不十分清楚。

这就是我所做的:

我复制了另一个视图的结构(称为plandetails)

所以现在我有:

site
controllers
helpers
language
models
views
controller.php
billingdetails.php //new controller
plandetails.php //previous controller
   plandetails //previous view
      tmpl
         default.php
         metadata.xml
      view.html.php
   billingdetails //new view
      tmpl
         default.php
      view.html.php

我将billingdetails.php控制器更改为与plandetails.php相同,但使用了billingdetails实例:

defined('_JEXEC') or die;
// Include dependancies
jimport('joomla.application.component.controller');

// Execute the task.
$controller = JController::getInstance('Billingdetails');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

我使用相应的类更改了billingsdetails文件夹中的view.html.php:

class BillingdetailsViewBillingdetails extends JView
{
    // Overwriting JView display method
    function display($tpl = null) 
    {
        // Display the view
        parent::display($tpl);
    }
}

现在在我的default.php(在billingdetails视图文件夹中)我只是回显“TESTING”。如果我转到视图名称为mysite.com/index.php?option=com_plandetails&view=billingdetails

的组件

我收到此错误:

View not found [name, type, prefix]: billingdetails, html, plandetailsView

注意:我没有对模型进行任何更改,因为我认为没有必要。我想为这个视图重用相同的方法。

我还缺少什么?

1 个答案:

答案 0 :(得分:1)

视图的类名应该是组件的名称,单词View,然后是视图名称。所以正确的视图类是这样的:

class plandetailsViewBillingdetails extends JView
相关问题