Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Render in Yii

Tags:

php

yii

I have a "view" page in Yii.
It is cached with page cache.
Now, I want to insert some dynamic content:

$this->renderDynamic('renderPartial','view_name'); 

The rendered view looks like this:

<?php some code ?>  
<div>...some html...</div>

The code works fine, but there is this error:

<###dynamic-0###>

So I understand the html is being echoed instead of returned.
I try to pass the return=true to the renderPartial function.
What is the right syntax to do it?

like image 397
lvil Avatar asked Apr 05 '12 14:04

lvil


2 Answers

More info: http://www.yiiframework.com/doc/api/1.1/CController#renderDynamic-detail

  1. Cached view file:

    $this->renderDynamic('dynamicTest');
    
  2. Controller file (callback function):

    public function dynamicTest()
    {
        return $this->renderPartial('dynamicTest', null, true);
    }
    
  3. Dynamic view file:

    echo 'dynamicTest_' . time();
    

I think that You forgot to add return in callback function (step 2).

like image 119
Naki Avatar answered Oct 07 '22 17:10

Naki


I try to pass the return=true to the renderPartial function. What is the right syntax to do it?

third param of renderPartial is needed flag

   $this->renderDynamic('renderPartial','view_name', null, true);
like image 40
Dmitry Dedov Avatar answered Oct 07 '22 18:10

Dmitry Dedov