Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Clistview ,active Record And Viewdata

$
0
0
Hello,
I am trying to list items from a db using AR and viewData but I would like to call to getimage function in my PersonController to search pictures in a directory based on the id_person that should return the AR cListView.

Person::model()->id_person is not returning me the id_person that i expect but viewData is calling to the function perfectly.

Have any idea ? Help will appreciate it.

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'itemView'=>'_view',
	'viewData'=>array('image'=>$this->getimage(Person::model()->id_person)),
       
)); ?>


public function getimage($idperson)
		{
			
			//options for findfiles
			$options = array(
			'level'=>0,
			'include'=>array('.png','.jpg','.gif','.avi'),
			'exclude'=>array('Thumbs.db'),
			);
			
			//finding files on the person directory
			$files = CFileHelper::findFiles(realpath('./images/person/'.$idperson),$options);		
	
		return $files[0]; 
			
	}

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>