1. PHP / Говнокод #21906

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    <?php
    if (isset($_GET['display']) && $_GET['display'] != '') {
    	$display = $_GET['display'];
    } else {	$display = 12; }
    if (isset($_GET['sortby']) && $_GET['sortby'] != '') {
    	$sortby = $_GET['sortby'];
    } else {	$sortby = 'pagetitle';}
    if (isset($_GET['sortdir']) && $_GET['sortdir'] != '') {
    	$sortDir = $_GET['sortdir'];
    } else {	$sortDir = 'DESC';}
    if (isset($_GET['producer']) && $_GET['producer'] != '') {
    	$producer = '|producer,'.$_GET['producer'].',1';
    } else {	$producer = '';}
    if ($modx->documentIdentifier == 56) {
    	if (isset($_GET['mont']) && $_GET['mont'] != '') {
    		$mont = '|type-mont,'.$_GET['mont'].',1';
    	} else {		$mont = '';	}
    	if (isset($_GET['vwidth']) && $_GET['vwidth'] != '') {
    		$vwidth = '|type-width,'.$_GET['vwidth'].',1';
    	} else {		$vwidth = '';	}
    }
    if ($modx->documentIdentifier == 20) {
    	if (isset($_GET['fhol']) && $_GET['fhol'] != '') {
    		$fhol = '|type-hol,'.$_GET['fhol'].',1';
    	} else { 		$fhol = ''; 	}
    }
    if ($modx->documentIdentifier == 27 || $modx->documentIdentifier == 62 || $modx->documentIdentifier == 778) {
    	if (isset($_GET['moi']) && $_GET['moi'] != '') {
    		$moi = '|type-moi,'.$_GET['moi'].',1';
    	} else {		$moi = '';	}
    }
    if (isset($_GET['minval']) && $_GET['minval'] != '') {
    	$sql = 'SELECT contentid, value FROM `modx_site_tmplvar_contentvalues` WHERE tmplvarid = 9'; 
    	$result = mysql_query($sql);
    	if ($result) {
    		while ($row = mysql_fetch_array($result)) {
    			$curPrice = intval(str_replace(array(',', ' '), '', $row['value']));
    			if ($curPrice >= $_GET['minval'] && $curPrice <= $_GET['maxval']) {
    				$preDocs[] = $row['contentid'];
    			}
    		}
    		if (count($preDocs) > 0) {
    			$preDitto = $modx->runSnippet("Ditto", array(
    				"tpl" => "product-inner-tpl",
    				"parents" => $modx->documentIdentifier,
    				"noResults" => "",
    				"depth" => 4,
    				"filter" => "template,7,1".$producer.$mont.$vwidth.$fhol.$moi
    			));
    			$preDitto = trim($preDitto, ',');
    			if ($preDitto != '') {
    				$preDittoDocs = explode(',', $preDitto);
    				$documents = array_intersect($preDittoDocs, $preDocs);
    				if (count($documents) != 0) {
    					$dittoOutput = $modx->runSnippet("Ditto", array(
    						"tpl" => "product-grid-tpl",
    						"documents" => implode(',', $documents),
    						"sortDir" => $sortDir,
    						"sortBy" => $sortby,
    						"noResults" => "",
    						"paginate" => 1,
    						"display" => $display,
    						"id" => "catditto"
    					));
    					$dittoOutput = $modx->parseDocumentSource($dittoOutput);
    					$dittoOutput2 = $modx->runSnippet("Ditto", array(
    						"tpl" => "product-tpl",
    						"documents" => implode(',', $documents),
    						"sortDir" => $sortDir,
    						"sortBy" => $sortby,
    						"noResults" => "",
    						"paginate" => 1,
    						"display" => $display,
    						"tplPaginatePrevious" => "prev-tpl",
    						"tplPaginateNext" => "next-tpl",
    						"tplPaginatePage" => "page-tpl",
    						"tplPaginateCurrentPage" => "page-current-tpl",
    						"id" => "catditto"
    					));
    					$dittoOutput2 = $modx->parseDocumentSource($dittoOutput2);
    					$pagination = $modx->runSnippet("PagesWrapper");
    					echo '
    						<div class="tovars_cont">
    							<ul class="tovars catBody active">'.$dittoOutput.'</ul>
    							<ul class="tovars_list catBody">'.$dittoOutput2.'</ul>
    							</div>
    						<div class="clear"></div>
    					'.$pagination;
    				} else {
    					echo 'Товаров не найдено.';
    				}
    			} else {
    				echo 'Товаров не найдено.';
    			}
    		} else {
    			echo 'Товаров не найдено.';
    		}
    	} else {		echo '-1';	}
    }

    мегафильтрация для интернет магазина на modx evo (при фильтрации минуту страница грузится)

    Запостил: als_1984, 27 Декабря 2016

    Комментарии (4) RSS

    Добавить комментарий