We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28000 ☆ A M B ☆
    • 397 Posts
    For a news / press / blog module, the client wants the user to be able to decide how many article teasers the user wishes to scan through. The interface is nothing new and is used often in shop systems. I was wondering if someone has a tip on how to achieve this. I have just started brainstorming and would attempt to use getpage and then have 3 buttons: |10|20|30|. each button would be a form that then saves the selected amount as a session variable. Upon page refresh I would look up the variable and set the limit in getpage with it.

    A problem may occur when the user clicks through the pagination, not sure.

    Has anyone already done this and want to share smiley

    Thank you!
      Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      You can override system settings on a per-context and on a per-user basis -- they're hierarchical for scenarios like this. I would structure your Snippet calls to rely on the default_per_page System Setting and update the user's profile page so they can set this variable themselves.
        • 3749
        • 24,544 Posts
        +1 for what Everett said. Rather than use a $_SESSION variable, create a default_per_page User Setting with your form:

        $userId = $modx->user->get('id');
        $value = $_POST['dfp_form_field'];
        
        $setting = $modx->newObject('modUserSetting');
        $setting->set('key', 'default_per_page');
        $setting->set('user', $userId);
        $setting->set('value', $value);
        $setting->save();
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 28000 ☆ A M B ☆
          • 397 Posts
          Sorry, I didn't clarify. I am dealing with the anonymous user - ie. someone not logged in and I am talking about the frontend.

          Could I use the same principle and just target the user (anonymous) in a snippet and set the user setting for a non-logged in user?

          http://rtfm.modx.com/revolution/2.x/administering-your-site/security/users [ed. note: sonicpunk last edited this post 12 years, 6 months ago.]
            Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
            • 3749
            • 24,544 Posts
            I don't think so. The (anonymous) user isn't a real user and has no record in the modx_users table. The best you could do is set a cookie or a $_SESSION variable.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting