We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25307
    • 114 Posts
    No problemo. Glad you got it working, its a killer add-on. I’m in the early stages of using this with some custom attribute fields and its really making the frontend displays buttery smooth.

    I was wondering if anyone could help suggest the best way to integrate a webuser search, like the one on the manager webusers listings page.
      • 13471
      • 2 Posts
      For those of you that would like to be able to use this snippet to display usernames as well.


      find where the $fields = starts and replace all the way down to the sql statement.

      if ($matches[1][0] == 'username') 
            $fields = "wu.{$matches[1][0]}";
        else
      $fields = "wua.{$matches[1][0]}";
      for ($i=1; $i<count($matches[1]); $i++)
      {
        if ($matches[1][$i] == 'username') 
            $fields .= ",wu.{$matches[1][$i]}";
        else
        $fields .= ",wua.{$matches[1][$i]}";
      }
      
      // Get a list of users from the DB. No API call for this :-(
      // Thanks to OpenGeek for making the query
      $wua= $modx->getFullTableName('web_user_attributes');
      $wgn= $modx->getFullTableName('webgroup_names');
      $wg= $modx->getFullTableName('web_groups');
      $wu = $modx->getFullTableName('web_users');
      $sql= "SELECT {$fields} FROM {$wua} wua JOIN {$wg} wg ON wg.webuser = wua.internalKey JOIN {$wgn} wgn ON wgn.name = '{$webGroup}' AND wgn.id = wg.webgroup JOIN {$wu} wu ON wu.id = wua.id ORDER BY wua.fullname ASC";
      
        • 34162
        • 1 Posts
        I want to create al list of members showing their names and te date they where last logged in.

        So, in my template I have:
        [+fullname+] last logged in on [+lastlogin+]<br />


        This produces an output like:
        Administrator last logged in on 1199383601

        How can I format the date to show correctly? Can it be done from within the template?


          • 19726
          • 239 Posts
          It can not be done in a standard way I think. The time you are seeing is a timestamp (number of seconds form 1970 I believe). You will have to convert it some way. On my sites I have PHx running and that should be able to solve it something like this:
          [+fullname+] last logged in on [+phx:input=`[+lastlogin+]`:date=`%d-%m-%Y`+]<br />
          Note that you will need to use the special PHx format because ShowMembers does not have built-in support for PHx.

          For more PHx information see: http://wiki.modxcms.com/index.php/PHx

          If you don’t have PHx running I don’t know how to fix it except for changing the snippet code.
            • 34162
            • 1 Posts
            Thank you for your reply.

            I’ve installed PHx, but formatting the date like you suggest gives this error:

            « MODx Parse Error »

            MODx encountered the following error while attempting to parse the requested resource:
            « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’:input=`[+lastlogin FROM `database`.`modx_web_user_attributes` wua JOIN `database`’ at line 1 »
            SQL: SELECT wua.fullname,wua.phx:input=`[+lastlogin FROM `database`.`modx_web_user_attributes` wua JOIN `database`.`modx_web_groups` wg ON wg.webuser = wua.internalKey JOIN `database`.`modx_webgroup_names` wgn ON wgn.name = ’webdesigners’ AND wgn.id = wg.webgroup ORDER BY wua.fullname ASC
            [Copy SQL to ClipBoard]

            Parser timing
            MySQL: 0.0057 s (11 Requests)
            PHP: 0.0503 s
            Total: 0.0560 s

            I also tried [+lastlogin:date=`%d-%m-%Y`+] but that also returns an error like this one.

            I already looked into the code of the snippet itself, but I don’t know where and how to format the date. huh

            Anyone a suggestion how to solve this?
              • 7231
              • 4,205 Posts
              What does you snippet call look like? It seems that the date info is being passed to the database query.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 34162
                • 1 Posts
                Yes, I also noticed that the date info is being passed to the query.

                This is the snippetcall I’ve used:
                [!ShowMembers? &webGroup=`webdesigners` &tpl=`smLaatst` &seperator=``!]


                Would have been nice if the snippet had a parameter for formatting dates. I just don’t understand the snippet code, so I’m not able to change it. undecided
                  • 19726
                  • 239 Posts
                  Hmm, PHx is not going to work with the current code. ShowMembers searches in the tpl for the fields that it should retrieve. It does this by looking for placeholders like [+blah+] in the template. Unfortunately it can not handle the PHx modifiers :-(. I don’t exactly recall why I made it this way, but I can fix it I think, but not before friday.
                    • 34162
                    • 1 Posts
                    There’s no hurry for me, but if you can fix it, you would make me very happy (and others I think) grin
                      • 34162
                      • 1 Posts
                      Even though I’m not a PHP guru, I solved the problem with date formatting grin

                      Better yet, I made some other changes to the snippet too:
                      - exported the language strings to an external language file, so translations can be added easily
                      - added a setlocale string to the language file
                      - added parameter &lang for selecting language
                      - added parameter &dateFormat for date formatting

                      Date formatting is only applicable for the following fields:
                      - blockeduntil
                      - blockedafter
                      - lastlogin
                      - thislogin
                      - dob (this means "date of birth")

                      I named this version ShowMembers 1.1 and will add it to the repository. This will also include the English and Dutch language files cool