hi friends… as im new to yii with little understanding in yii. could you please help me how to create a widget with pagination support… I know how to create a widget but I dont know to create with pagination… pls help me… thanks in advance…
hi friends… as im new to yii with little understanding in yii. could you please help me how to create a widget with pagination support… I know how to create a widget but I dont know to create with pagination… pls help me… thanks in advance…
[color="#006400"]/* moved from Tips, Snippets and Tutorials */[/color]
Dear Friend
The following is one simple implementation without using any dataprovider.
Imagine that I have 12 images(image1,image2,image3,…) in images folder under webapp folder.
i.e) webapp/images/gallery
WIDGET
components/ImageWidget.php
<?php
class ImageWidget extends CWidget
{
public function run()
{
$images=array('image1','image2','image3','image4','image5','image6','image7','image8','image9','image10','image11','image12');
$count=count($images);
$pages=new CPagination($count);
$pages->pageVar="image";
$pages->pageSize=1;
$image=$images[0];
if(isset($_GET['image']))
$image=$images[$_GET['image']-1];
$this->render('image',array('pages'=>$pages,'image'=>$image));
}
}
?>
VIEW
components/views/image.php
<?php
$url=Yii::app()->baseUrl."/images/gallery/".$image.".jpg";
?>
<div>
<?php echo CHtml::image($url);?>
</div>
<?php
$this->widget('CLinkPager', array(
'pages' => $pages,
'header'=>'Go to Images'
));
?>
Now in any view, we can call
$this->widget('ImageWidget');
I hope this would help you.
Regards.
thanks… great tutorial
please explain about cpagination with its properties and methods… sorry for any inconvenience…
Dear Friend
I am sure that you know the story of an elephant and five blind men.
Each one interpreting differently by touching different parts of the animal.
Yii is like a big elephant and I am one among the blind.
Best thing is going through the API.
CPagination
Regards.
yesterday I tried it friend now I understand the basics of pagination… thanks for ur kind help…
My new personal hero!!!