SwiftModders Posted February 25, 2020 Share Posted February 25, 2020 Hi All, I am working on a new module and I know there will be instances where a number of records will be pulled into view. Does WHMCS provide a way to handle pagination of records or should I use the Laravel pagination method? Source: https://laravel.com/docs/5.2/pagination I am curious how other developers do it or if you do your own custom pagination method. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted February 26, 2020 Share Posted February 26, 2020 Custom pagination here 😪I refuse to use Laravel (verbose, unnecessary, limiting, slower). 0 Quote Link to comment Share on other sites More sharing options...
SwiftModders Posted February 28, 2020 Author Share Posted February 28, 2020 On 2/26/2020 at 12:47 AM, Kian said: Custom pagination here 😪I refuse to use Laravel (verbose, unnecessary, limiting, slower). I see, it also appears that WHMCS is not including the Laravel pagination as I cannot call it. Ugh. Any recommendations on alternative pagination functions? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted February 28, 2020 Share Posted February 28, 2020 I have no experience with Lavarel but maybe you could simply include the missing "pagination" component/script. Anyway keep in mind that Laravel is inflexible. Let me quote just this thing from their documentation: Currently, pagination operations that use a groupBy statement cannot be executed efficiently by Laravel. If you need to use a groupBy with a paginated result set, it is recommended that you query the database and create a paginator manually. 😑 so what's the point of using it? Anyway it should be fine if you don't need to filter results with GROUP BY. 0 Quote Link to comment Share on other sites More sharing options...
weelow Posted April 9, 2020 Share Posted April 9, 2020 On 2/28/2020 at 10:12 PM, SwiftModders LLC said: I see, it also appears that WHMCS is not including the Laravel pagination as I cannot call it. Ugh. Any recommendations on alternative pagination functions? This is how I would do it. replace YOURTABLE with your table name and .COL with your column name and you can add as much as you link just add {$HTMLpagePagination} somewhere in your returned html code. This is compatible with bootstrap so you can play with the classes to change the design. $record_count = Capsule::table('YOURTABLE')->count(); $offset=10; $offsets=$record_count/$offset; if (!$_REQUEST['page']){$page = 1;}else{$page = $_REQUEST['page'];} if ($record_count != null) { $record_list = Capsule::table('YOURTABLE') ->select('YOURTABLE.COL1','YOURTABLE.COL2') ->offset(($page-1)*$offset) ->limit($offset) ->get(); } $HTMLpagePagination = ""; if ($record_count < $offset+1){ $HTMLpagePagination .= '<div class="clearfix">'; $HTMLpagePagination .= '<div class="hint-text pull-left">Showing <b>'.$record_count.'</b> out of <b>'.$record_count.'</b> pages</div>'; $HTMLpagePagination .= '</div>';} if ($record_count > $offset){ $HTMLpagePagination .= '<div class="clearfix">'; if ($page*$offset<$record_count){$HTMLpagePagination .= '<div class="hint-text pull-left">Showing <b>'.$page*$offset.'</b> out of <b>'.$record_count.'</b> pages</div>';} else{$HTMLpagePagination .= '<div class="hint-text pull-left">Showing <b>'.$record_count.'</b> out of <b>'.$record_count.'</b> pages</div>';} $HTMLpagePagination .= '<ul style="margin:0px 0px" class="pagination pull-right">'; if ($page<2){$HTMLpagePagination .= '<li class="page-item disabled"><a href="#">Previous</a></li>';} else{$HTMLpagePagination .= '<li class="page-item"><a href="'.$modulelink.'&page='.($page-1).'">Previous</a></li>';} if ($page-2>0){$HTMLpagePagination .= '<li class="page-item"><a href="'.$modulelink.'&page='.($page-2).'" class="page-link">'.($page-2).'</a></li>';} if ($page-1>0){$HTMLpagePagination .= '<li class="page-item"><a href="'.$modulelink.'&page='.($page-1).'" class="page-link">'.($page-1).'</a></li>';} $HTMLpagePagination .= '<li class="page-item active"><a href="'.$modulelink.'&page='.($page).'" class="page-link">'.($page).'</a></li>'; if ($page+1<$offsets+1){$HTMLpagePagination .= '<li class="page-item"><a href="'.$modulelink.'&page='.($page+1).'" class="page-link">'.($page+1).'</a></li>';} if ($page+2<$offsets+1){$HTMLpagePagination .= '<li class="page-item"><a href="'.$modulelink.'&page='.($page+2).'" class="page-link">'.($page+2).'</a></li>';} if ($page+1<$offsets+1){$HTMLpagePagination .= '<li class="page-item"><a href="'.$modulelink.'&page='.($page+1).'" class="page-link">Next</a></li>';} else{$HTMLpagePagination .= '<li class="page-item disabled"><a href="#" class="page-link">Next</a></li>';} $HTMLpagePagination .= '</ul>'; $HTMLpagePagination .= '</div>'; If you need any further help or explanation. please do not hesitate to ask, I am willing to help. Good luck 1 Quote Link to comment Share on other sites More sharing options...
SwiftModders Posted April 9, 2020 Author Share Posted April 9, 2020 3 hours ago, weelow said: This is how I would do it. replace YOURTABLE with your table name and .COL with your column name and you can add as much as you link just add {$HTMLpagePagination} somewhere in your returned html code. This is compatible with bootstrap so you can play with the classes to change the design. Thanks! I ended up coming up with my own solution, but this is definitely helpful information for everyone 🙂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.