我在这里迷路了,需要建议。我的情况:使用下面的代码,我更改了模块中的默认项目限制:
<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>
助手.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');
}
我的链接更改为:http:*/project/?lastrecepes=&limit=36它可以工作,但是当我尝试添加另一个过滤器时,例如:
<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>
它将限制更改为旧值,URL 如下所示:http:*/project/?lastrecepes=&skip_items=15
如果我手动将它们加在一起,它们工作正常:http:*/project/?lastrecepes=&limit=36&skip_items=15
谁能帮我,我想在另一个过滤器进来时保存第一个过滤结果。对不起,我的英语不好,希望你能理解我。
当然,当您刷新页面时,限制将从 36 更改为 24,因为您没有将更改保存在任何地方。如果转到 http:*/project/?lastrecepes=&skip_items=15
,则限制为 24,因为这是默认值。
保存到 cookie 或会话(取决于您的需要),然后在每次页面加载时检查 cookie/会话以获取当前限制值。