向自定义Joomla组件添加新视图 [英] Add a new view to a custom Joomla component
问题描述
I'm trying to add a new view to my custom component. I've followed this post but the instructions are not quite clear to me.
这就是我所做的:
我复制了其他视图的结构(称为Plandetails)
I copied the structure of my other view (called 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实例:
I changed the billingdetails.php controller to be the same as plandetails.php but with billingdetails instance:
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:
I changed view.html.php in the billingsdetails folder with the appropriate class:
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
Now in my default.php (inside billingdetails view folder) I just echo "TESTING". If I go to the component with view name: mysite.com/index.php?option=com_plandetails&view=billingdetails
我收到此错误:
View not found [name, type, prefix]: billingdetails, html, plandetailsView
注意:我没有对模型进行任何更改,因为我认为这没有必要.我想对该视图重用相同的方法.
Note: I didn't make any changes to the model as I don't think that is necessary. I want to reuse the same methods for this view.
我还想念什么?
推荐答案
视图的类名称应该是组件的名称,单词View
,然后是视图名称.所以正确的视图类是这样的:
Class name for the view should be the component's name, the word View
, and then the view name. So the correct view class is like this:
class plandetailsViewBillingdetails extends JView
这篇关于向自定义Joomla组件添加新视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!