2012-11-25 34 views
0

我在這裏迷路了,需要建議。我的情況:與如下因素代碼更改默認項限制模塊:添加其他過濾器時保存限制更改

<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'); 

    } 

我的鏈接更改爲:HTTP:* /項目/ lastrecepes = &限制= 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> 

它改變限制OL d值,URL是這樣的:HTTP:* /項目/ lastrecepes = & skip_items = 15

如果我手動添加這些他們一起工作得很好:HTTP:* /項目/ lastrecepes = &限制= 36 & skip_items = 15

任何人都可以幫助我,我喜歡在另一個過濾器進來時保存第一個過濾結果。對不起,我的英語不好,希望你能理解我。

+0

難道這會很難嗎? no1知道?! –

回答

0

當然,當刷新頁面時,限制將從36改回到24,因爲您沒有在任何地方保存更改。如果你去http:*/project/?lastrecepes=&skip_items=15,限制是24,因爲這是默認值。

當你修改它時,你需要做的是將限制保存到一個cookie或一個會話(取決於你的需要),然後每次頁面加載當前限制值時檢查cookie/session。

+0

好的,我明白了,有沒有機會給我舉個例子怎麼做? –

+0

對不起,但這需要一段時間,我無法投資。請谷歌PHP的cookie和自己嘗試。如果你不熟悉它,可能需要幾個小時。 – bogatyrjov

+0

thx,我找到了解決方案,不是沒有你的幫助。 –

相關問題