R
R
Roman Kilanov2020-10-31 11:47:54
YouTube
Roman Kilanov, 2020-10-31 11:47:54

Yii2: How to process content after rendering by controllers but before showing to user?

Good afternoon! Can you please tell me how to process all content after rendering by controllers and before showing it to the user?

Those. the task such, is a certain value in base which changes periodically. It is necessary that after the content is rendered but before being shown to the user, change some substring "[replace]" in it and replace it with the value then.

for example, 1c-bitrix has the following event:
AddEventHandler("main", "OnEndBufferContent", "ChangeMyContent");
here a function is called that processes $content and returns it to the output

, or if in self-written code, the usual methods:
ob_start();
....
code
.....
$out = ob_get_clean();
echo str_Replace('','',$out);

and how to implement it correctly here in Yii2?

The implementation is needed either globally or at the controller level, both are possible.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question