We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24969
    • 120 Posts
    Hi,
    I have an about us page for my site. I have the data stored in a table named tblabout.
    I need to display this information in a modx page. So I created a snippet as follows
    <?php
    $output = '';//create variable for holding the output
    $sql = $modx->db->query( 'SELECT * FROM `tblabout` LIMIT 0, 1000');//define the DB query, in this case the table is named 'tblabout', add WHERE AND etc. as needed
    $resultArray = $modx->db->makeArray( $sql );//put it into an array
    foreach($resultArray as $item) //go through each record in the array
    {//start looping through the data array
    $params['name']=$item['names'];//set the placeholders, the $params sets the name of the placeholder, the $item is the field name from the DB table
    $params['about']=$item['content'];
    $output.=$modx->parseChunk('about', $params, '[+', '+]');//define the chunk name and process the content
    }//finish looping through the data array
    return $output;//now return the output from the processed chunk
    ?>

    and a chunk
    <h3>[+names+]</h3>
    <p>[+content+]</p>


    But I cannot get the information to display....
    I am trying to call the chunk as follows
    [+about+]

    I am using Version 1.0.0 on a wamp server.

      The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

      -Albert Einstein (1879 - 1955)

      Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
      • 22303 MODX Staff
      • 10,725 Posts
      Try $modx->db->getRow() instead of $modx->db->makeArray(). I don’t think makeArray() is what you wanted.
        • 24969
        • 120 Posts
        Opengeek:
        I just copied the snippit from http://wiki.modxcms.com/index.php/DB_query_and_Placeholders

        I will definitely give your suggestion a try....

        $modx->db->getRow();

        or
        $modx->db->getRow($sql);
          The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

          -Albert Einstein (1879 - 1955)

          Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: rhyno at Aug 18, 2009, 04:06 PM

          I just copied the snippit from http://wiki.modxcms.com/index.php/DB_query_and_Placeholders
          Though there is some helpful code there, the wiki at wiki.modxcms.com is 100% user contributed and maintained, so it’s not always reviewed for accuracy or full of official solutions.

          Quote from: rhyno at Aug 18, 2009, 04:06 PM

          $modx->db->getRow($sql);

          The latter is the one you want...
            • 24969
            • 120 Posts
            Well thanks for the update....
            Though there is some helpful code there, the wiki at wiki.modxcms.com is 100% user contributed and maintained, so it’s not always reviewed for accuracy or full of official solutions.
            Any other ideas on why it doesn’t show anything on my about page....
            Can I calling the chunk correctly? Do I need to call the snippet before calling the chunk?
              The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

              -Albert Einstein (1879 - 1955)

              Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
              • 22303 MODX Staff
              • 10,725 Posts
              Make sure you call the snippet uncached if your page is cacheable (you do not need to call the chunk, the contents will be returned from the snippet), i.e.
              [!MySnippetName!]
                • 24969
                • 120 Posts
                My snippet name is About.... so when I enter
                [!About!]
                my page displays
                [[About]]
                  The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

                  -Albert Einstein (1879 - 1955)

                  Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
                  • 24969
                  • 120 Posts
                  Any other ideas?
                    The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

                    -Albert Einstein (1879 - 1955)

                    Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
                    • 16278
                    • 928 Posts
                    Might LoopDbChunk http://modxcms.com/forums/index.php/topic,14654.0.html suit your purpose?
                    smiley KP
                      • 24969
                      • 120 Posts
                      Thanks I will look into this.
                        The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

                        -Albert Einstein (1879 - 1955)

                        Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635