I have a template with php enabled on output. However i can’t get str_replace to work. See below code. If i just put {title} without any php then it works. But when i include php and place {title} inside the str_replace function, i get nothing displayed. I tried php with simple echo ‘test’; and it worked. It’s just not parsing {title} or other field tags.
{exp:channel:entries channel="one" url_title="{segment_2}"}
<?php
echo str_replace('old', 'new', '{title}');
?>
{/exp:channel:entries}
This may sound preposterous, but have you tried removing the
url_titleparameter from the{exp:channel:entries}tag to ensure the rest of your code and logic is working properly?The following code should output the entry title of “old test” (without quotes):
Given the same entry title of “old test”, this should output: “new test” (again, without the quotes):
This was tested successfully in a new, blank template with PHP Enabled and set to Output.