Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
How use pager function ?
Hi, i create a gallery application, but i don't understand how add the pager function inside ...
My model is
class GalleryModel {
public static function GetGallery($Offset = '0',$Limit = '', $Wheres = '') {
if ($Limit == '')
$Limit = Gdn::Config('Gallery.Media.PerPage', 8);
$Offset = !is_numeric($Offset) || $Offset < 0 ? 0 : $Offset;
$Result = Gdn::SQL()
->Select('m.*')
->From('Media m')
->OrderBy('m.MediaID','desc')
->Limit($Limit, $Offset)
->Get();
return $Result;
}
public static function GetCountGallery() {
$Result = Gdn::SQL()
->Select('m.*')
->From('Media m')
->Get();
return $Result;
}
}
my controller is :
public function index() {
$this->GalleryDataSet = GalleryModel::GetGallery();
$CountGallery = GalleryModel::GetCountGallery();
$this->SetData('CountGallery', $CountGallery);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->FireEvent('BeforeBuildPager');
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$CountGallery,
'gallery/%1$s'
);
$this->FireEvent('AfterBuildPager');
// Deliver JSON data if necessary
if ($this->DeliveryType() != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'gallery';
}
$this->Render();
}
and in my view i add :
<?php echo $this->Pager->ToString('more'); ?>
But no pager... someone have an idea ?
My model is
class GalleryModel {
public static function GetGallery($Offset = '0',$Limit = '', $Wheres = '') {
if ($Limit == '')
$Limit = Gdn::Config('Gallery.Media.PerPage', 8);
$Offset = !is_numeric($Offset) || $Offset < 0 ? 0 : $Offset;
$Result = Gdn::SQL()
->Select('m.*')
->From('Media m')
->OrderBy('m.MediaID','desc')
->Limit($Limit, $Offset)
->Get();
return $Result;
}
public static function GetCountGallery() {
$Result = Gdn::SQL()
->Select('m.*')
->From('Media m')
->Get();
return $Result;
}
}
my controller is :
public function index() {
$this->GalleryDataSet = GalleryModel::GetGallery();
$CountGallery = GalleryModel::GetCountGallery();
$this->SetData('CountGallery', $CountGallery);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->FireEvent('BeforeBuildPager');
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure(
$Offset,
$Limit,
$CountGallery,
'gallery/%1$s'
);
$this->FireEvent('AfterBuildPager');
// Deliver JSON data if necessary
if ($this->DeliveryType() != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'gallery';
}
$this->Render();
}
and in my view i add :
<?php echo $this->Pager->ToString('more'); ?>
But no pager... someone have an idea ?
Tagged:
0
Comments
$Limit = Gdn::Config('Gallery.Media.PerPage', 8);
(if i change to 100 perPage i have all my results)
OffsetLimit() function will help you...