Page 1 of 1

how to add the custom field in admin category section?

Posted: Fri Sep 18, 2015 3:29 am
by vaslobas
I want to add the new custom field in admin >> catalog >> category >> "category_name"

Here under Generak section i need to add the custom field similar to Description
Is there any possibility in opencart to add the custom field in admin?

And then to show data from that field on category's page.

Re: how to add the custom field in admin category section?

Posted: Fri Sep 18, 2015 4:36 pm
by opencartboost
Yes that is possible. But you must change some file below and add field/column at database (table category_description).

admin/controller/catalog/category.php
admin/language/your_language/catalog/category.php
admin/model/catalog/category.php
admin/view/template/catalog/category_form.tpl
catalog/controller/product/category.php
catalog/language/your_language/product/category.php
catalog/model/catalog/category.php
catalog/view/theme/your_theme/template/product/category.tpl

Try find code for name from that file and add your code after that.

Re: how to add the custom field in admin category section?

Posted: Fri Sep 18, 2015 8:30 pm
by vaslobas
I did it, but with no success.
I got error inside textarea on category page in admin's panel
Notice: Undefined index: description1 in /home/c/cw31022/public_html/admin/view/template/catalog/category_form.tpl on line 67

Code: Select all

<?php echo isset($category_description[$language['language_id']]) ? $category_description[$language['language_id']]['description1'] : ''; ?></textarea>
And error at category page too
Notice: Undefined variable: description1 in /home/c/cw31022/public_html/catalog/view/theme/franchesco/template/product/category.tpl on line 153

Code: Select all

	<div class="well">
	    <?php if ($description1) { ?>
        <?php echo $description1; ?>
        <?php } ?>
    </div>

Re: how to add the custom field in admin category section?

Posted: Sat Sep 19, 2015 3:25 pm
by opencartboost
The error mean you not put description1 in array.
Of course you get error at front because you failed to insert description1.

Re: how to add the custom field in admin category section?

Posted: Sat Sep 19, 2015 7:52 pm
by straightlight
By default, Opencart does not provide custom fields over categories. In order to do that, at this current time, an extension may be required or to use alternative methods to add custom fields on the categories array and to the database.