在OpenCart版本2上添加管理页面 [英] Adding an admin page on OpenCart version 2

查看:111
本文介绍了在OpenCart版本2上添加管理页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将管理页面添加到Opencart2时遇到了问题,并且遵循关于SO的几乎相同问题的答案无济于事,所以我相信问题是特定于OC2的.

I am havin a problem adding an admin page to Opencart2, and following the answers on pretty much identical questions on SO do no help, so I beleive the problem is specific to OC2.

按照此问题的答案我仍然收到错误消息"致命错误:在第13行的C:\ websites \ weddingshoponline \ shop \ admin \ controller \ custom \ helloworld.php中调用未定义的方法ControllerCustomHelloWorld :: render().任何帮助都将不胜感激,因为我一直在圈子里逛逛.

Following the answer at this question I still get the error message "Fatal error: Call to undefined method ControllerCustomHelloWorld::render() in C:\websites\weddingshoponline\shop\admin\controller\custom\helloworld.php on line 13. Any help would be much appreciated, as I have been going around in circles.

谢谢.

PS尽管是一个不错的选择,但恢复到OC的先前版本是无效的响应.

PS Reverting to a previous version of OC is not valid response, albeit a good one.

推荐答案

OC中页面呈现之间的差异< 2.0和OC 2.0只是少数,但是您必须意识到它们.

The difference between page rendering in OC < 2.0 and OC 2.0 are only few but you have to be aware of them.

在OC中<2.0您将执行此操作:

In OC < 2.0 you would do this:

$this->data['text_button_save'] = $this->language->get('text_button_save');

而在OC 2.0中,它只是$data,即

while in OC 2.0 it is only $data, i.e.

$data['text_button_save'] = $this->language->get('text_button_save');

作为参数传递给$this->load->view()方法,例如:

that is passed over to the $this->load->view() method as an argument, e.g.:

$this->response->setOutput($this->load->view('catalog/category_list.tpl', $data));

2. $this->render()

不见了.现在,您正在呼叫$this->load->view('catalog/category_list.tpl', $data).

2. $this->render()

is gone. Now you are calling $this->load->view('catalog/category_list.tpl', $data) instead.

不见了.现在,模板子模块的位置被实例化为模板属性的一部分,而您必须手动调用它们的控制器(为什么?):

is gone. Now the template child modules' positions are instantiated as part of template properties while you have to call their controllers manually (WHY?):

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

我在想为什么需要这些更改.有什么改进?他们是否希望开发人员编写更少的代码?现在是否更遵循OOP,MVC,WTF(抱歉)原则?并得到了答案:(或第一个没有 ).

I was thinking why the hell were these changes required. What has been improved? Did they want the developers to write less code? Is it now more following the OOP, MVC, WTF (sorry) principles? And got the answer: NO (or nothing to the first one).

我们仍然必须加载翻译(我是说,我们仍然必须加载每个字符串翻译).而且gettext已经存在了8年以上...

We still have to load the translations (I mean, we still have to load each single string translation). And gettext is out there for more than 8 years...

我们现在必须调用更长的时间(而不是难以理解的)$this->response->setOutput($this->load->view('catalog/category_form.tpl', $data));,而不是简短的$this->response->setOutput($this->render());.我们为什么不能这样做:$this->render('catalog/category_form.tpl', $data); ???

Instead of short $this->response->setOutput($this->render()); we now have to call much longer (and incomprehensible) $this->response->setOutput($this->load->view('catalog/category_form.tpl', $data));. Why can't we just do this: $this->render('catalog/category_form.tpl', $data); ???

我个人认为OC 2.0与以前一样是 excrement (从开发人员的角度来看).他们只是更改了包装.但是,老实说,还有更大的排量,这就是为什么我坚持使用OpenCart的原因:-)

I personally think OC 2.0 is the same excrement (from the developers perspective) as it was before. They just changed the packaging. But, honestly, there are even bigger excrements out there, that's why I'm stuck with OpenCart :-)

这篇关于在OpenCart版本2上添加管理页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆