【问题标题】:Prestashop add hyperlink or image to product featuresPrestashop 将超链接或图像添加到产品功能
【发布时间】:2023-03-09 00:29:01
【问题描述】:

您好,我正在尝试为 prestashop 的产品功能添加自定义链接。

这是我尝试过的:

编辑/classes/FeatureValue.php

// 语言字段

'value' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required'
  => true, 'size' => 255),

到这里

// 语言字段

'value' => array('type' => self::TYPE_NOTHING, 'lang' => true, 'validate' => 'isAnything', 'required'
  => true, 'size' => 255),

还有这个文件:/themes/<your theme folder>/product.tpl

发件人:

{foreach from=$features item=feature}
                    <tr class="{cycle values="odd,even"}">
                        {if isset($feature.value)}
                        <td>{$feature.name|escape:'html':'UTF-8'}</td>
                        <td>{$feature.value|escape:'html':'UTF-8'}</td>
                        {/if}
                    </tr>
                    {/foreach}

到这里:

{foreach from=$features item=feature}
                    <tr class="{cycle values="odd,even"}">
                        {if isset($feature.value)}
                        <td>{$feature.name|escape:'html':'UTF-8'}</td>
                        <td>{$feature.value|escape:'UTF-8'}</td>
                        {/if}
                    </tr>
                    {/foreach}

还有这个文件:admin1234/themes/default/template/controllers/products/features.tpl

改变了这个:

<textarea class="custom_{$available_feature.id_feature}_ALL textarea-autosize"  name="custom_{$available_feature.id_feature}_ALL"
                                cols="40" style='background-color:#CCF' rows="1" onkeyup="{foreach from=$languages key=k item=language}$('.custom_{$available_feature.id_feature}_{$language.id_lang}').val($(this).val());{/foreach}" >{$available_feature.val[1].value|escape:'html':'UTF-8'|default:""}</textarea>

到这里:

<textarea class="custom_{$available_feature.id_feature}_ALL textarea-autosize"  name="custom_{$available_feature.id_feature}_ALL"
                                cols="40" style='background-color:#CCF' rows="1" onkeyup="{foreach from=$languages key=k item=language}$('.custom_{$available_feature.id_feature}_{$language.id_lang}').val($(this).val());{/foreach}" >{$available_feature.val[1].value|escape:'UTF-8'|default:""}</textarea>

问题是当我将值添加到自定义字段时,单击保存后它会消失并且没有插入到数据库中。 但是,如果我将超链接添加到定义的功能,那么它会保存在数据库中并且我可以使用它。 但由于我想添加多个超链接/高度,假设我无法制作 100 个预定义的组合。

如果我不清楚,我深表歉意,如果您需要更多信息,请告诉我。 Prestashop 版本:1.6.0.11

【问题讨论】:

    标签: php mysql hyperlink prestashop


    【解决方案1】:

    编辑
    类/Product.php

    寻找

    Add new feature to product
    

    和2行上方查找

    $row = array('id_feature_value' => (int)$id_value, 'id_lang' => (int)$lang, 'value' => pSQL($cust));
    

    改变

    $row = array('id_feature_value' => (int)$id_value, 'id_lang' => (int)$lang, 'value' => $cust);
    

    我只是删除 并且您自己的所有其他更改都是真实的。在 1.6 版本中进行此更改自定义 html 工作正常!
    只需清除缓存即可。 . .

    出于某种原因检查

    /override/classes/
    

    如果您看到 Product.php 和 FeatureValue.php 也对它们进行更改

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      • 1970-01-01
      • 2019-02-25
      • 2012-03-28
      • 2014-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多