1

I'm new to Smarty and I have a variable which contains a URL http://someurl.com and I'm trying to perform a replace operation on it, to show http://m.someurl.com. This is what I have, but it's not working.

{$theurl | replace: 'http://' :'http://m.'}

I also tried assigning the $theurl to a second variable and perform the replacement there, but I have no luck.

I also tried escaping the slashes, replacing http for xxx, and nothing works.

I took a look here for reference: http://www.smarty.net/docsv2/en/language.modifier.replace.tpl

1 Answer 1

1

Can you give us some more information on the variable itself? How about you use a var_dump to show the current value of the variable:

{$theurl|var_dump}

Why are you using spaces in the smarty syntax, maby that is the problem:

{$theurl|replace:'http://':'http://m.'}
Sign up to request clarification or add additional context in comments.

1 Comment

I'm not familiar with PHP, nor Smarty. In a decent language (or Framework) spaces don't matter. Thanks anyway, I figured out that the problem was caused by the innocent spaces. Accepting your answer since it the solution for my problem.

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.