Im lost here, and need advice. My situation: with folowing code I change default items limit in module:
<form method="get" style="text-align:center;">
<input type="hidden" name="lastrecepes" value="">
<button type="submit" value="24" id="limit" name="limit" onclick="change();" style="width:200px;margin:20px 0 20px 0;"/>change limit</button>
<script>
function change(){
var elem = document.getElementById("limit");
if (elem.value=="24") elem.value = "36";}
</script>
</form>
helper.php:
public static function getLists(&$params)
{
$total_items = ($_GET['limit']) ? $_GET['limit'] : $params->get('count');
if ($_GET['limit']) $params->set('count',$_GET['limit']);
$content_source = $params->get('content_source','joomla');
}
my link changes to: http:*/project/?lastrecepes=&limit=36
and it works, but when im trying to add another filter like:
<button type="submit" value="0" id="skip_items" name="skip_items" onclick="change1();" style="width:200px;margin:20px 0 20px 0;"/>more</button><script>
function change1(){
var elem = document.getElementById("skip_items");
if (elem.value=="0") elem.value = "15";}
</script>
it changes limit to old value, and url looks like: http:*/project/?lastrecepes=&skip_items=15
If i manually add those together they work fine: http:*/project/?lastrecepes=&limit=36&skip_items=15
can anyone help me with it, i dlike to save first filtering result when another filter comes in. Sorry for my bad english hope u can understand me.
Well of course the limit will change back from 36 to 24 when you refresh the page, because you are not saving the change anywhere. If You go to
http:*/project/?lastrecepes=&skip_items=15, the limit is 24, because that is the default value.What you have to do is save the limit to a cookie or a session (depending on your needs) when you change it and then check the cookie / session every time when page loads for a current limit value.