XF 2.2 Replace variable on templates before rendering

Scandal

Well-known member
Hello all!

1. Let's say we have the template variable $post.User.username.

On $post I have a getEditedUsername() getter.

Is that possible via php / class extension (without modification of the template) etc. when on the templates called the $post.User.username, in reality to give as result the $post.getEditedUsername()? I mean to look backward, bypass the .User.

2. Another question: is that possible via a class extension and a method (example: extension of the Templater), to replace all $post.User.username with $post.getEditedUsername() while running the code, without touch the saved templates?

I did some tries but it seems the Templater has the rendered html code. I need to modify the template level code, not the html / rendered, before the output.
Example, by using this:
PHP:
$m = parent::something($params)

$m = str_replace('$post.User.username', '$post.getEditedUsername()', $m);

return $m;

Of course, this on public site. I don't mean to replace code directly on the template system.
All template saved codes should be untouched. :)
 
Back
Top Bottom