Yii Framework Forum: How to use renderDynamic from within a Widget - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to use renderDynamic from within a Widget It outputs <###dynamic-1###> instead of dynamic content Rate Topic: -----

#1 User is offline   edanb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 16-June 09

Posted 21 October 2010 - 05:20 PM

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!
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 October 2010 - 04:19 AM

What does getDynamicContent do?
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   edanb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 16-June 09

Posted 22 October 2010 - 05:19 AM

View Postmdomba, on 22 October 2010 - 04:19 AM, said:

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.
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 October 2010 - 05:29 AM

Can you post here this function?

Note that the callback to renderDynamic should return the dynamic content instead of echoing it.
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   edanb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 16-June 09

Posted 22 October 2010 - 05:38 AM

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.
0

#6 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,317
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 October 2010 - 06:00 AM

:)

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...
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users