php - Symfony 1.4 Passing variables from action to view -


i symfony 1.4 newbie , i'm joining project need create new dashboard.

i've created following controller in analyse/actions/actions.class.php

public function executetestdashboard(sfwebrequest $request){      $foo = "foobar";     $this->foo = "thisfoobar";     return $this->renderpartial('analyse/testdashboard', array('foo' => $foo);  } 

and analyse/templates/_testdashboard.php view, partial included in home/templates/indexsuccess.php :

<div class="testdashboard">         <h1>test</h1>         <?php var_dump($foo);?> </div> 

it doesn't work, $foo neither "foobar" nor "thisfoobar", "null". how should proceed, in order make work? (or check if executetestdashboard controller processed ?)

you should read partials , components in symfony 1.4. if you're including partial in template using include_partial() partial rendered , no controller code executed.

if need more logic simple rendering partial should use component, like:

in analyse/actions/compononets.class.php

public function executetestdashboard(){      $this->foo = "foobar: ".$this->getvar('somevar'); } 

in analyse/templates/_testdashboard.php

<div class="mydashboard><?php echo $foo ?></div> 

in other template file, want dashboard displayed:

include_component('analyse', 'testdashboard', array('somevar' => $somevalue)); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -