Answer the question
In order to leave comments, you need to log in
How to implement widget display in text in Yii?
Hello! The text has this kind of patterns - [town] and [slider] , which I want to replace. Everything is ok with town (because it's a string), but with slider it's a widget for me. Actually function:
public function modifyContent($content){
$patterns['townName'] = "[\[town\]]";
$patterns['slider'] = "[\[slider\]]";
$replacements['townName'] = $this->getTown()->vname;
//тут соответсвенно выдает ошибку: Object of class BxSlider could not be converted to string и с этим не поспоришь
$replacements['slider'] = $this->widget('application.widgets.BxSlider.BxSlider');
return preg_replace($patterns, $replacements, $content);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question