Yii Framework Forum: passage de variable dans view - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

passage de variable dans view Rate Topic: -----

#1 User is offline   cedpiel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 09-March 12

Posted 09 March 2012 - 09:20 AM

Bonjour, je débute et y'a un truc que j'arrive pas à faire.
Je calcul une valeur dans un controller et souhaite l'afficher dans l'index de ce controller.

Comment fait-on?
exemple :
le controller
public function actionDatemax(){
            $sql = "select MAX(dateexpedition) as date_max from expeditions";
                $rows = Yii::app()->db->createCommand($sql)->queryAll();
               
                $date_max =  $rows[0]['date_max'];
                return $date_max;
        }


la vue:
<?php
$this->breadcrumbs=array(
	'Pms',
);

$this->menu=array(
	array('label'=>'Create Pms', 'url'=>array('create')),
	array('label'=>'Manage Pms', 'url'=>array('admin')),
);
?>

<h1>Pms</h1>

<?php echo $date_max;?>
	
));?>

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'itemView'=>'_view',
));
?>


Merci
0

#2 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 385
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 09 March 2012 - 11:37 AM

Ajoute ça à ton controlleur
		$this->render('nom_de_ta_vue',array(
			'date_max'=>$date_max,
		));


Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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