We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28033
    • 925 Posts
    editedby puts out a date that has to be formatted, and editedon outputs the ID of the user.

    strftime("%d/%m/%y %H:%M:%S", $value)

    I know this exampl was given, but how to I apply that to the variable? And for the ID, how can I make MODx grab the user’s name to replace the ID?
      My Snippets
      -> PopUpChunk v1.0
      • 7231
      • 4,205 Posts
      You can use a snippet like the dateTime snippet to format the timestamp. You can also use phx to format it.

      In your example you are applying the formating to the $value variable, just replace this for the variable you want to format. This page has info on the formating options http://www.php.net/strftime
        [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't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 28033
        • 925 Posts
        I got the date/time working. The only thing is changing the Manager User ID to the name.

        Like on my website, instead of saying (1), I want it to say (Wilhelm).

        EDIT: Also, is there a way to get the st part in something like 31st w/ strftime?
          My Snippets
          -> PopUpChunk v1.0
          • 4041
          • 788 Posts
          This is where you want the info from after you have established $row[’createdby’]:
          $tbl = $modx->dbConfig["dbase"].".".$modx->dbConfig["table_prefix"];
          $sql = mysql_query("SELECT * FROM ".$tbl."manager_users WHERE ".$tbl."manager_users.id = ".$row['createdby']."");
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 28033
            • 925 Posts
            Quote from: Breezer at May 30, 2008, 11:27 PM

            This is where you want the info from after you have established $row[’createdby’]:
            $tbl = $modx->dbConfig["dbase"].".".$modx->dbConfig["table_prefix"];
            $sql = mysql_query("SELECT * FROM ".$tbl."manager_users WHERE ".$tbl."manager_users.id = ".$row['createdby']."");


            If I’m just calling it by [*createdby*], how would I implement that code? Run that code in a snippet or something?
              My Snippets
              -> PopUpChunk v1.0
              • 3749
              • 24,544 Posts
              Quote from: Soshite at May 30, 2008, 11:14 PM

              I got the date/time working. The only thing is changing the Manager User ID to the name.

              I found this in he ditto code. I think it will do what you want (perhaps with some modification). You don’t need to change $createdby since it’s just an argument name. Just set $id and call it as

              $username = getAuthor($id);


              function getAuthor($createdby) {
              		global $modx;
              		
              		$user = false;
              		if ($createdby > 0) {
              			$user = $modx->getUserInfo($createdby);
              		} else {
              			$user = $modx->getWebUserInfo(abs($createdby));
              		}
              		if ($user === false) {
              			// get admin user name
              			$user = $modx->getUserInfo(1);
              		}
              		return ($user['fullname'] != "") ? $user['fullname'] : $user['username'];
              	}


              You could change the last line to:

              return $user['username'];
              if that’s all you want.
                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
                • 4041
                • 788 Posts
                Make this a snippet (name it whatever you want) and add it wherever you want the username to be:
                <?php
                $tbl = $modx->dbConfig["dbase"].".".$modx->dbConfig["table_prefix"];
                $createdbyid = $modx->documentObject['createdby'];
                $sql = "SELECT username
                      FROM ".$tbl."manager_users
                      WHERE ".$tbl."manager_users.id ='".$createdbyid."'";
                
                      $rs = $this->dbQuery($sql);
                      $limit = $this->recordCount($rs);
                      if($limit<1) {
                         $author = "anonymous";
                      } else {
                         $user = $this->fetchRow($rs);
                         $author = $user['username'];
                      }
                 return $author;
                ?>
                
                  xforum
                  http://frsbuilders.net (under construction) forum for evolution
                  • 7231
                  • 4,205 Posts
                  the AuthorTimestamp snippet handles this: http://modxcms.com/AuthorTimestamp-693.html
                    [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]
                    • 28033
                    • 925 Posts
                    Thanks for all of the suggestions. I’ll take a closer look at them and see which works best for my website. smiley
                      My Snippets
                      -> PopUpChunk v1.0