Smarty Templates PHP - Remove specific text from a string
I have the following code:
{$product.name}
This outputs all of our p开发者_JS百科roducts, unfortunatly they are stored in the database as 'CompanyNameProductName
'.
I want to remove the string 'CompanyName
' from the string $product.name
How can I do this in PHP?
Replace
{$product.name}
by
{$product.name|replace:'CompanyName':''|capitalize}
This way you can do it in your Smarty template without having to modify your PHP.
.
$str = str_replace('CompanyName','',$str);
http://at2.php.net/str_replace
If you use Prestashop, you need to edit the header.tpl
file of your theme and replace by
<title>{{$meta_title|replace:' - Name of your company':''}|escape:'html':'UTF-8'}</title>
Make sure to leave the space before the dash.
精彩评论