【问题标题】:Prestashop 1.5.6 - Add a custom field in Admin Product PagePrestashop 1.5.6 - 在管理产品页面中添加自定义字段
【发布时间】:2016-04-08 14:24:18
【问题描述】:

我一直在尝试在管理产品页面中引入一个新的自定义字段,但出现了一个奇怪的错误。实际上,此字段与现有字段具有相同的文本区域类型。 如果我输入纯文本,它可以正常工作,但如果我输入任何以左尖括号 (

这就是我所做的。

  1. 新的数据库字段

  2. ProductCore 类。在引用“描述”的地方进行了更改,因为它们几乎相同。

  3. Information.tpl 已修改以显示此新字段。

  4. 这是更改后管理产品页面的外观。如您所见,可以毫无问题地保存纯文本。

  5. 1234563

我检查了文件和文件夹的权限以及错误日志,但找不到任何线索。有人有想法吗?请帮忙!

信息.tpl

        <tr>
            <td class="col-left">
                {include file="controllers/products/multishop/checkbox.tpl" field="description" type="tinymce" multilang="true"}
                <label>{l s='Description:'}<br /></label>
                <p class="product_description">({l s='Appears in the body of the product page'})</p>
            </td>
            <td style="padding-bottom:5px;">
                    {include file="controllers/products/textarea_lang.tpl" languages=$languages
                    input_name='description'
                    input_value=$product->description
                    }
                <p class="clear"></p>
            </td>
        </tr>
        <tr>
            <td class="col-left">
                {include file="controllers/products/multishop/checkbox.tpl" field="alternate_item" type="tinymce" multilang="true"}
                <label>{l s='Alternate Item:'}<br /></label>
            </td>
            <td style="padding-bottom:5px;">
                    {include file="controllers/products/textarea_lang.tpl"
                    languages=$languages
                    input_name='alternate_item'
                    input_value=$product->alternate_item}
                <p class="clear"></p>
            </td>
        </tr>

textarea_lang.tpl

<div class="translatable">
{foreach from=$languages item=language}
<div class="lang_{$language.id_lang}" style="{if !$language.is_default}display:none;{/if}float: left;">
    <textarea cols="100" rows="10" id="{$input_name}_{$language.id_lang}" 
        name="{$input_name}_{$language.id_lang}" 
        class="autoload_rte" >{if isset($input_value[$language.id_lang])}{$input_value[$language.id_lang]|htmlentitiesUTF8}{/if}</textarea>
    <span class="counter" max="{if isset($max)}{$max}{else}none{/if}"></span>
    <span class="hint">{$hint|default:''}<span class="hint-pointer">&nbsp;</span></span>
</div>
{/foreach}
</div>
<script type="text/javascript">
    var iso = '{$iso_tiny_mce}';
    var pathCSS = '{$smarty.const._THEME_CSS_DIR_}';
    var ad = '{$ad}';
</script>

【问题讨论】:

    标签: prestashop http-status-code-403 prestashop-1.5


    【解决方案1】:

    您必须覆盖 ProductCore 类而不是修改 ProductCore 类

    class Product extends ProductCore 
    {
       public $alternate_item;
    
       public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
       {
             self::$definition['fields']['alternate_item'] = array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml');
             parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
       }
    }
    

    覆盖类必须放在 override/classes 文件夹或 yourmodule/override/classes

    当你覆盖一个类时,你必须删除 cache/class_index.php

    【讨论】:

    • 嗨 fito,我已经尝试了您建议的所有方法,但仍然遇到相同的 403 错误。我真的不明白为什么会这样。你还有别的想法吗?它一定与那些 HTML 标签有关..
    • 我觉得我也应该对 AdminProductsController.php 做点什么?
    • 我只是放了一些信息代码。tpl 以及 textarea_lang.tpl ..感谢您的时间和帮助!请看一下
    • 好像是文件权限问题。检查您的 prestashop 安装文件和目录权限。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    • 2018-03-25
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多