Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2. //Filter Fields Settings
  3. $filter = array();
  4.  
  5. //Sort
  6. if($_GET['sortby']) {
  7. $sortby = $_GET['sortby'];
  8. } else {
  9. $sortby = 'pagetitle';
  10. }
  11. if($_GET['sortdir']) {
  12. $sortdir = $_GET['sortdir'];
  13. } else {
  14. $sortdir = 'asc';
  15. }
  16. //End Sort
  17.  
  18. //Offset
  19. $offset = 0;
  20. if($_GET['offset']){
  21. $offset = $_GET['offset'];
  22. }
  23.  
  24. if($filter) {
  25. $where = $modx->toJSON(array($filter));
  26. } else {
  27. $where = '';
  28. }
  29.  
  30. $params_count = array(
  31. 'parents' => $parents,
  32. 'limit' => 0,
  33. 'tpl' => '@INLINE ,',
  34. 'select' => 'id',
  35. 'includeTVs' => $fields,
  36. 'showHidden' => '1',
  37. 'where' => $where
  38. );
  39.  
  40. $count = $modx->runSnippet('pdoResources',$params_count);
  41. $count = count(explode(',',$count))-1;
  42. $modx->setPlaceholder('count',$count);
  43.  
  44. $params = array(
  45. 'parents' => $parents,
  46. 'limit' => $limit,
  47. 'offset' => $offset,
  48. 'tpl' => $tpl,
  49. 'tplFirst' => $tplFirst,
  50. 'select' => 'id,pagetitle,introtext,content',
  51. 'includeTVs' => $fields,
  52. 'showHidden' => '1',
  53. 'sortby' => $sortby,
  54. 'sortdir' => $sortdir,
  55. 'where' => $where
  56. );
  57.  
  58. $more = $count - $offset - $limit;
  59. $lim = $more > $limit ? $limit : $more;
  60.  
  61. $button = '';
  62. if($more > 0){
  63. $button = '<div class="ajax-filter-count load_more" data-count="'.$count.'"><a href="#" class="ajax-more load_more_link rect_link">Загрузить еще</a></div>';
  64. }
  65.  
  66. return $modx->runSnippet('pdoResources',$params).$button;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement