How to use renderDynamic from within a Widget

Say I have a widget PostWidget that displays a certain post and in that widgets view I have a piece of content that should be rendered dynamically (should not be cached)

So in my view I have:




	if($this->beginCache('showPost', $cacheConfig)) 

	{

		$this->widget('PostWidget', array( 'id' => 1));


		$this->endCache();

	}



And in PostWidget’s view I have:




..

$this->controller->renderDynamic(array($this, 'getDynamicContent'));

..



Unfortunately it doesnt work - it only displays:

<###dynamic-0###>

instead of the dynamic content.

Am I doing it wrong? Should I not use dynamic content from within a widget?

Any help would be appreciated!

What does getDynamicContent do?

It’s just a function that returns any dynamic content, like for example I am using it to return the HTML for a delete button if the user is allowed to delete this post.

The result of this function should not be cached since different users will have different permissions for posts - only some will be allowed to delete a certain post.

Can you post here this function?

Note that the callback to renderDynamic should return the dynamic content instead of echoing it.

Hello mdomba

It really doesnt matter what this function returns, it is just any HTML that should not be cached.

For argument sake lets say the function is:




public function getDynamicContent()

{

return 'some <b>html</b>';

}



I still get

<###dynamic-0###>

returned instead of the dynamic content.

:)

I though that could be something in the method that is the reason for this… but just remembered that there where an issue with this in Yii 1.1.4 - http://code.google.c…/detail?id=1565

try with the current trunk…