Heidel Heidel - 7 months ago 65
Smarty Question

smarty get parts of text before and after comment

There is the text which containts

<!-- -->

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, ultrices quis ultricies vel, sodales pharetra massa. Donec iaculis hendrerit odio, quis facilisis odio aliquet non. <!-- -->Phasellus in euismod nunc, eget hendrerit tortor. In porttitor sem metus, ut porta turpis porta ac. Aenean sed semper mi. Fusce ac augue vel mi gravida bibendum eget a ex. Sed at auctor mauris, ut semper nibh. Sed in nisl nunc.

How can I get the first part of text before comment (not including comment itself) and the second part of text after comment (not including comment itself too) in smarty?

In code below I get full text

{if $brand && $current_page_num==1}
{if $category->$brand_descr}


You can use call php's reg_split inside smarty:


Before: {$description.0}
After: {$description.1}

I've also excluded the spaces before and after <-- -->, remove \s* from the regular expression if you don't want this.