对OpenCart主题的简单修改 [英] Simple modification to OpenCart theme

查看:738
本文介绍了对OpenCart主题的简单修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OpenCart中使用Shoppica主题.我想对类别页面进行修改.它提供了说明(我在后端输入了内容),然后提供了产品列表.

在category.tpl中说:

<?php if ($description) echo $description; ?>

但是我想要一个额外的描述,我们称其为description2.这应该在产品列表之后. 在PhpMyAdmin中,我在* oc_category_description *中添加了另一行,并将其称为description2 手动(因此在PhpMyAdmin中)我在其中填充了文字.

现在,我将以下内容放置在category.tpl文件中:

<?php if ($description2) echo $description2; ?>

但是现在我收到一个错误:

未定义变量:description2 in /home/.../public_html/catalog/view/theme/shoppica2/template/product/category.tpl 在第187行

任何想法,我做错了什么.我是否需要在其他地方声明它(在另一个文件中?在哪里?)

解决方案

需要了解OpenCart内置的MVC模式.

简而言之-您有一个与数据库交互的Model类,一个在上面运行并调用Model方法(数据检索,数据更新,数据插入)的Controller类,并将输出传递给brwoser,同时由View处理(应该是另一个类,但OpenCart仅具有MC-带有模板文件的Model-Controller部分).

所以要解决您的问题:您必须修改catalog/model/catalog/category.php并寻找称为getCategory的方法来检索具体的类别数据.选择查询中的此处应为select * from ...-如果是这样,则一切正常,但如果类似于select category_id, category_description, ... from ...,则还必须在此处添加您的新字段(对不起,我不记得来自OpenCart的SQL查询).

另外编辑catalog/controller/product/category.php并查找控制类别数据的部分(称为类别模型),或查找以$this->data['description'] = ...;开头的行,并在此处添加您的新字段,例如$this->data['description2'] = ...;. /p>

希望这会有所帮助.

I'm using the Shoppica theme with OpenCart. I'd like to make a modification to the category page. It gives a description (which I entered in the backend) and than a list of products follow.

In category.tpl it says:

<?php if ($description) echo $description; ?>

But I'd like to have an extra description, let's call it description2. This should come AFTER the list of products. In PhpMyAdmin I added another row in *oc_category_description* and called it description2 Manually (so in PhpMyAdmin) I filled this with text.

Now I placed the following in the category.tpl file:

<?php if ($description2) echo $description2; ?>

But now I receive an error:

undefined variable: description2 in /home/.../public_html/catalog/view/theme/shoppica2/template/product/category.tpl on line 187

Any idea, what I did wrong. Do I need to declare it somewhere else (in another file? where?)

解决方案

There is need of understanding of the MVC pattern which is OpenCart built in.

Briefly - You have a Model class that interacts with the database, a Controller class that operates above and calls Model methods (data retrieval, data update, data insertion) and pass the output to the brwoser while it is processed by the View (should be another class but OpenCart has only like MC - Model-Controller part with template files).

So to Your problem: You have to modify catalog/model/catalog/category.php and look for method called getCategory that retrieves the concrete category data. Here in select query should be select * from ... - if it is so, everything is OK, but if it is like select category_id, category_description, ... from ... then You have to add Your new field here as well (sorry, I do not remember the SQL queries from OpenCart).

Additionaly edit the catalog/controller/product/category.php and look for the part where the category data is controlled (the category model is called) or look for line that starts with $this->data['description'] = ...; and add Your new field here, like $this->data['description2'] = ...;.

Hope this will help.

这篇关于对OpenCart主题的简单修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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