CLiown
CLiown

Reputation: 13853

Smarty Templates PHP - Remove specific text from a string

I have the following code:

{$product.name}

This outputs all of our products, 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?

Upvotes: 3

Views: 8482

Answers (3)

La Carte Musique
La Carte Musique

Reputation: 1

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.

Upvotes: 0

JochenJung
JochenJung

Reputation: 7213

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.

Upvotes: 8

Sebs
Sebs

Reputation: 3058

.

$str = str_replace('CompanyName','',$str);

https://www.php.net/str_replace

Upvotes: 3

Related Questions