doulie0178 2019-08-06 08:24
浏览 84

在2行上创建prestashop 1.7名称和描述

everyone!

I need to make the name and description in the product miniatures on 2 lines. So what I did was, I changed templates\catalog_partials\miniatures\product.tpl like so:

        {block name='product_name'}
          <h3 itemprop="name"><a href="{$product.url}" class="product_name">{$product.name|truncate:45:'...'}</a></h3>
          <div class="miniature-description" id="miniature-description">{$product.description_short|truncate:45:''|escape:'html':'UTF-8' nofilter}</div>
          {if $product.description_short == ' '}
          <div class="miniature-description-2">{$product.description|truncate:45:''|escape:'html':'UTF-8' nofilter}</div>

          {/if}
        {/block}

This works to some degree, but I want it to always show the first 2 lines no matter how long the description is.

If someone can tell me what I can do to make it work, I would be really grateful.

  • 写回答

1条回答 默认 最新

  • douerlin4366 2019-08-07 06:57
    关注

    First of all, I don't recommend you to use truncate for description. It can contain HTML data and it's a huge probability that you will truncate it in an inappropriate place and you will lose HTML tags. What about your goal, I think that it isn't possible at all if consider it like a reliable approach. Because you can have any description and you never know what it contains. But if you want it exceptionally for your site you can add some conditional mark to all descriptions and explode them by it. For example

    {assign var="desc" value="your_conditional_mark_here"|explode:$product.description}
    {$desc[0]}<!--Part before your mark-->
    {$desc[1]}<!--Part after your mark-->
    

    But remember that it still wouldn't be reliable approach

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加