Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Need help on regex_replace

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
8ternity
Smarty n00b


Joined: 27 Jan 2020
Posts: 2

PostPosted: Fri Jan 31, 2020 2:38 pm    Post subject: Need help on regex_replace Reply with quote

Hi,

I have a prestashop store and they use in List mode view a |strip_tags command which remove everything in the Description Summary.

All our products are created with <UL><LI></LI></UL> and i want to add a . before closing the</li>.

I've used |regex_replace to replace Return line and add an . before closing the </li>.

I have no experience on how regex_replace work. I've try so many things but does anyone can help me with that please?

The original code is :

Code:
          {block name='product_description_short'}
            <div class="product-description-short" itemprop="description">{$product.description_short|strip_tags:false}</div>
          {/block}


I've try this :
Code:
          {block name='product_description_short'}
            <div class="product-description-short" itemprop="description">{$product.description_short|regex_replace:"[\n]":". "|strip_tags:false}</div>
          {/block}


Thanks.
Back to top
View user's profile Send private message
8ternity
Smarty n00b


Joined: 27 Jan 2020
Posts: 2

PostPosted: Fri Jan 31, 2020 3:12 pm    Post subject: Reply with quote

I resolved it.

I was using that regex_replace :
Code:
{$product.description_short|regex_replace:"(<\/li>)":".</li>"|strip_tags:false}


Glad it worked!

Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP