如何只保留列表中 $product.description_short 的第一段?
How to keep only the first paragraph of $product.description_short in a listing?
我只想保留类别中产品描述的第一段。
示例:<p>This is a pretty good description.</p><p>The rest of the description, even if it's cool to I don't want it.</p>
收件人:<p>This is a pretty good description.</p>
这是产品中的默认代码-list.tpl Prestashop (1.6):
<p class="product-desc" itemprop="description">
{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
</p>
这是我在产品中尝试的默认代码-list.tpl Prestashop (1.6):
<p class="product-desc" itemprop="description">
{assign var $newdescription = $product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
{preg_replace('(?<=<\/p>)\s+<p>.*','',$newdescription)}
</p>
{$_shorten = explode('</p>', $product.description_short)}
// with valid html tags
{$_shorten.0|cat:'</p>'}
// or if you want to strip tags:
{$_shorten.0|strip_tags}
我只想保留类别中产品描述的第一段。
示例:<p>This is a pretty good description.</p><p>The rest of the description, even if it's cool to I don't want it.</p>
收件人:<p>This is a pretty good description.</p>
这是产品中的默认代码-list.tpl Prestashop (1.6):
<p class="product-desc" itemprop="description">
{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
</p>
这是我在产品中尝试的默认代码-list.tpl Prestashop (1.6):
<p class="product-desc" itemprop="description">
{assign var $newdescription = $product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}
{preg_replace('(?<=<\/p>)\s+<p>.*','',$newdescription)}
</p>
{$_shorten = explode('</p>', $product.description_short)}
// with valid html tags
{$_shorten.0|cat:'</p>'}
// or if you want to strip tags:
{$_shorten.0|strip_tags}