Guest User

Untitled

a guest
Jun 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. Код сниппета
  2. <?php Filter Fields Settings
  3. $filter = array();
  4.  
  5.  
  6. if($_REQUEST['classNews']) {
  7. print_r(gettype($_REQUEST['classNews']));
  8. $filter[] = 'classNews='.$_REQUEST['classNews'];
  9. }
  10.  
  11. //Sort
  12. if($_GET['sortby']) {
  13. $sortby = $_GET['sortby'];
  14. } else {
  15. $sortby = 'pagetitle';
  16. }
  17. if($_GET['sortdir']) {
  18. $sortdir = $_GET['sortdir'];
  19. } else {
  20. $sortdir = 'asc';
  21. }
  22.  
  23. //Offset
  24. $offset = 0;
  25. if($_GET['offset']){
  26. $offset = $_GET['offset'];
  27. }
  28. if($filter) {
  29.  
  30. $where = $modx->toJSON(array($filter));
  31. } else {
  32. $where = '';
  33. }
  34.  
  35. $params_count = array(
  36. 'parents' => $parents,
  37. 'limit' => 0,
  38. 'tpl' => '@INLINE ,',
  39. 'select' => 'id',
  40. 'includeTVs' => $fields,
  41. 'showHidden' => '1',
  42. 'where' => $where
  43. );
  44. print_r($params_count);
  45. $count = $modx->runSnippet('pdoResources',$params_count);
  46. $count = count(explode(',',$count))-1;
  47. $modx->setPlaceholder('count',$count);
  48.  
  49. $params = array(
  50. 'parents' => $parents,
  51. 'limit' => $limit,
  52. 'offset' => $offset,
  53. 'tpl' => $tpl,
  54. 'select' => 'id,pagetitle,introtext,content,publishedon',
  55. 'includeTVs' => $fields,
  56. 'showHidden' => '1',
  57. 'sortby' => $sortby,
  58. 'sortdir' => $sortdir,
  59. 'where' => $where
  60. );
  61. print_r($params);
  62. $more = $count - $offset - $limit;
  63. $lim = $more > $limit ? $limit : $more;
  64.  
  65. $button = '';
  66. if($more > 0){
  67. $button = '<div class="ajax-filter-count" data-
  68. count="'.$count.'"><a href="#" class="ajax-more">Загрузить еще
  69. '.$lim.' из '.$more.'</a></div>';
  70. }
  71.  
  72. return $modx->runSnippet('pdoResources',$params).$button;
  73.  
  74. var ajaxContainerSelector = '.ajax-container',
  75. function ajaxMainFunction() {
  76. console.log($(ajaxFormSelector).serialize())
  77. $.ajax({
  78. data: $(ajaxFormSelector).serialize()
  79. }).done(function(response) {
  80. var $response = $(response);
  81. console.log($response+"++")
  82. $(ajaxContainerSelector).fadeOut(fadeSpeed);
  83. setTimeout(function() {
  84. $(ajaxContainerSelector).html($response.find(ajaxContainerSelector).html()).fadeIn(fadeSpeed);
  85. ajaxCount();
  86. }, fadeSpeed);
  87. });
  88. }
  89.  
  90. <div class="row">
  91. <div class="col-xl-2 col-lg-2"></div>
  92. <div class="col-xl-8 col-lg-8 col-md-12">
  93. <div class="row">
  94. <form class="ajax-form">
  95. <input type="hidden" name="sortby" value="pagetitle">
  96. <input type="hidden" name="sortdir" value="asc">
  97. <h1 class="h-contacts">НОВОСТИ</h1>
  98. <ul class="news-sections">
  99. <li class="sections-item-text border" id="allNews" onclick="Border(this,0)">Все новости</li>
  100. <li class="sections-item-text" id="masterClass" onclick="Border(this,1)">Мастер-классы</li>
  101. <li class="sections-item-text" id="expertOpinion" onclick="Border(this,2)">Мнение эксперта</li>
  102. </ul>
  103. <label>
  104. <input type='radio' value="0" name="classNews" checked=""></input>
  105. <input type='radio' value="1" name="classNews"></input>
  106. <input type='radio' value="2" name="classNews" ></input>
  107. </label>
  108. </form>
  109. </div>
  110. </div>
  111. <div class="col-xl-2 col-lg-2"></div>
  112. </div>
  113. </div>
  114. <div class=" ajax-container container " id="result">
  115. [[catalogFilter?
  116. &parents=`4`
  117. &limit=`3`
  118. &fields=`classNews`
  119.  
  120. ]]
  121. </div>
Add Comment
Please, Sign In to add comment