Reputation: 9
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?)
Upvotes: 0
Views: 988
Reputation: 16065
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.
Upvotes: 3