3

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?

1
  • Will CompanyName be different for each product? If so, do you have access to it separately? Commented Aug 5, 2010 at 13:00

3 Answers 3

8

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Is there any decent Smarty resources cheatsheets?
Also after removing CompanyName I need to capitalise first new letter.
Just added the capitalitze modifier. See here (smarty.net/manual/en/language.modifiers.php) for a list of smarty modifiers
3

.

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

https://www.php.net/str_replace

1 Comment

You sure live up to your gravatar. :)
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.