Yii Framework Forum: BeginWidget - Yii Framework Forum

Jump to content

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

BeginWidget Récupération des propriétés Rate Topic: -----

#1 User is offline   Mahdi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 127
  • Joined: 23-August 10
  • Location:Tunisia

Posted 17 February 2011 - 05:06 AM

Bonjour,

je viens d'utiliser beginWidget, mon problème est de savoir comment récupérer les propriétés dans ma classe.

Merci.
0

#2 User is offline   ouhman 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 26-December 08

Posted 17 February 2011 - 05:24 AM

OK,

Donc tu appelles ton widget comme ca:

<?php
$this->widget('widgetName',array(
    'data1' => 'blabla',
	'data2' => 'blabla'
));
?>


et dans ta class, tu les recuperes via des variables publiques:

class widgetName extends CWidget
{
	public $data1;
	
	public $data2;
	
    public function init()
    {
        
    }
 
    public function run()
    {
        $this->render('widgetViewName');
		//Et dans ta view tu appelles tes variables comme: $this->data1, $this->data2
    }
}


En esperant que ca t'aide!
2

#3 User is offline   Mahdi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 127
  • Joined: 23-August 10
  • Location:Tunisia

Posted 17 February 2011 - 08:42 AM

Merci ouhman, c'est exactement ce que j'ai besoin :)
0

#4 User is offline   fouss 

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

Posted 18 February 2011 - 11:09 AM

View Postouhman, on 17 February 2011 - 05:24 AM, said:

OK,

Donc tu appelles ton widget comme ca:

<?php
$this->widget('widgetName',array(
    'data1' => 'blabla',
	'data2' => 'blabla'
));
?>


et dans ta class, tu les recuperes via des variables publiques:

class widgetName extends CWidget
{
	public $data1;
	
	public $data2;
	
    public function init()
    {
        
    }
 
    public function run()
    {
        $this->render('widgetViewName');
		//Et dans ta view tu appelles tes variables comme: $this->data1, $this->data2
    }
}


En esperant que ca t'aide!

Merci (+1)!
Cela aide plus d'un!
Posted Image
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