Yii Framework Forum: Ideas for changes on CController - Yii Framework Forum

Jump to content

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

Ideas for changes on CController

#1 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 30 March 2009 - 02:56 PM

I don't know if is a good idea and the right place to wrote about this.
I want to have partial views generated from database, as ex the menu.
The search of this forum doesn't helped me too much in finding the right solution.
Even mine which I'll describe it below it's not perfect, but I'm waiting for better suggestion.
I didn't found how to have different partial views rendered in the layout dynamically I chose to change a little the CController class, in fact the render function. (sometimes I prefer to load a model from a view, without the controller, it's possile?) (for partialRender I have to provide the data anyway from the controller)
Now I can have in SiteController:
$this->render(array('content'=>'index', 'menu'=>'menu1'));

So, the function looks now like this.
public function render($view,$data=null,$return=false)

$out = array();
foreach($view as $k=>$v)
$out[$k] = $this->renderPartial($v,$data,true);
$output = implode("", $out);

return $output;
echo $output;

Any better idea?

Because I have talked about menu below is an idea for a dynamic one.
I made a ne widget named HorizontalMenu (an identical copy of the MainMenu) and I changed run function:
public function run()

$criteria=new CDbCriteria;

foreach($model as $item)
//$item2['url']=$item[$this->items['url']]; //if absolute url



not complete, but improvable.
The widget in main.php looks like this:
'model' => 'model_name',
'label' => 'label_field',
'url' => 'url_field'

It has to be integrated with authorization, mine is not fully done.
Hope that helps


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