Hi all, and sorry for my English.
I’m trying to use the following snippet&code to change the way how docs appear in Ditto catalog – visitor able to choose ’show by’ 10,20,50 or 100 docs per page. There is also some possibilities to sort by price and name. Sorting works perfectly, but ‘show by’ option works in Mozilla and Opera but doesn’t work in ie and chrome.
Could you please help to find where is a mistake. My thinking is that it is because the parameter ‘onchange’ does not set for the ‘select’ button in php coding, but can’t figure out how to correct the code… i’ve marked the code in red frames.
here is the php code
<?php
$filterForm = ’<form id="filterForm" action="[~[*id*]~]" method="get">’;
$filterForm .= ’<div id="sortLinks">’;
$filterForm .= ’<input type="hidden" name="sdir" value="" /><input type="hidden" name="sby" value="" />’;
$filterForm .= ’<b>sort by:</b><span class="sortDirLinks" rel="pagetitle"><span class="sortBy" rel="’;
if($_GET["sdir"] == "price" || ($_GET["sdir"] == "pagetitle" && $_GET["sby"] == "DESC")) $filterForm .= "ASC";
elseif(!isset($_GET["sdir"]) || $_GET["sdir"] == "pagetitle") $filterForm .= "DESC";
$filterForm .= ’"></span>name</span><span class="sortDirLinks" rel="price"><span class="sortBy" rel="’;
if(!isset($_GET["sdir"]) || $_GET["sdir"] == "pagetitle" || ($_GET["sdir"] == "price" && $_GET["sby"] == "DESC")) $filterForm .= "ASC";
elseif($_GET["sdir"] == "price") $filterForm .= "DESC";
$filterForm .= ’"></span>price</span>’;
/* show by */
$filterForm .= ’<span class="sortPagination">по <select name="spages">’;
$filterForm .= ’<option value="10"’;
if(!isset($_GET["spages"]) || (isset($_GET["spages"]) && $_GET["spages"] == 10)) $filterForm .= ’ selected’;
$filterForm .= ’>10</option>’;
$filterForm .= ’<option value="20"’;
if(isset($_GET["spages"]) && $_GET["spages"] == 20) $filterForm .= ’ selected’;
$filterForm .= ’>20</option>’;
$filterForm .= ’<option value="50"’;
if(isset($_GET["spages"]) && $_GET["spages"] == 50) $filterForm .= ’ selected’;
$filterForm .= ’>50</option>’;
$filterForm .= ’<option value="100"’;
if(isset($_GET["spages"]) && $_GET["spages"] == 100) $filterForm .= ’ selected’;
$filterForm .= ’>100</option>’;
$filterForm .= ’</select> on the page</span>’;
/* --/show by */
$filterForm .= ’</div></form>’;
/* Ditto parameters */
$params[’id’] = ’catalog’;
$params[’hideFolders’] = 1;
$params[’depth’] = 4;
$params[’tpl’] = ’cattpl’;
$params[’sortDir’] = isset($_GET["sby"]) && !empty($_GET["sby"]) ? $_GET["sby"] : ’ASC’;
$params[’sortBy’] = isset($_GET["sdir"]) && !empty($_GET["sdir"]) ? $_GET["sdir"] : ’pagetitle’;
$params[’paginate’] = 1;
$params[’paginateAlwaysShowLinks’] = 1;
$params[’summarize’] = isset($_GET["spages"]) && !empty($_GET["spages"]) ? $_GET["spages"] : 10;
/* --/Ditto parameters */
return $filterForm.$modx->runSnippet(’Ditto’, $params);
?>
and here is the function
$(document).ready(function(){
$("span.sortDirLinks").each(function(){
$(this).click(function(){
dirvalue = $(this).attr("rel");
byvalue =$(this).find("span.sortBy").attr("rel");
$("#filterForm input[name=\"sdir\"]").val(dirvalue);
$("#filterForm input[name=\"sby\"]").val(byvalue);
$("#filterForm").submit();
});
});
$("select[name=\"spages\"] option").each(function(){
$(this).click(function(){
$("#filterForm").submit();
});
});
$("#filterForm input:reset").click(function(){
$("form[name=\"filterFormReset\"]").submit();
});
});