添加第二个字段类别Prestashop 1.7

时间:2018-05-15 13:57:01

标签: php prestashop prestashop-1.7

我正在尝试为Prestashop 1.7中的Category添加可编辑字段

我已经这样做了:

在数据库中插入text_SEO

替换/类/ Category.php

<?php
class Category extends CategoryCore
{

public $text_SEO; // My Custom field

public static $definition = array(
    'table' => 'category',
    'primary' => 'id_category',
    'multilang' => true,
    'multilang_shop' => true,
    'fields' => array(
        'nleft' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
        'nright' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
        'level_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
        'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
        'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
        'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
        'is_root_category' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
        'position' => array('type' => self::TYPE_INT),
        'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
        'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),

        // Lang fields
        'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
        'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
        'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
        'text_SEO' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
        'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
        'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
        'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
    ),
);
}

替换/控制器/管理/ AdminCategoriesController.php

    class AdminCategoriesController extends AdminCategoriesControllerCore
{
    public function renderForm()
    {
        $this->fields_form_override =array(
            array(
                'type' => 'textarea',
                'label' => $this->l('Text SEO'),
                'name' => 'text_SEO',
                'lang' => true,
                'autoload_rte' => true,
                'hint' => $this->l('Invalid characters:').' <>;=#{}',
            ),
        );
        return parent::renderForm();
    }
}

如何显示areatext?

谢谢! :d

1 个答案:

答案 0 :(得分:1)

您的代码是正确的。这应该有用。

您是否在表text_SEO而非category_lang的数据库中添加了category? 在重新加载类别页面之前,您是否清空了PrestaShop缓存?您可以在高级参数&gt;上执行此操作绩效页面