We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Quote from: rhyno at Aug 18, 2009, 04:21 PM

    My snippet name is About.... so when I enter
    [!About!]
    my page displays
    [[About]]
    That definitely should not happen. Something is wrong elsewhere...where is this tag being placed?
      • 24969
      • 120 Posts
      Unsure of what you are asking opengeek.
      I have my snippet tag in a page by itself.
        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
        • 4310
        • 2,310 Posts
        Looking at your original posted snippet code.
        You have a table in the database named tblabout
        It has columns in it named names & content
        Your chunk is named about
        The about chunk should contain these placeholders:
        [+about+] & [+name+]
        If all the above is correct just call your snippet on the page.
          • 24969
          • 120 Posts
          Thanks for the reply bunk58
          I will post an update of my code again;
          Chunk name is About
          <h3>[+name+]</h3>
          <p>[+about+]</p>


          Snippet name is about
          <?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->getRow($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
          ?>


          I got the snippet from the wiki. http://wiki.modxcms.com/index.php/DB_query_and_Placeholders
            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
            • 4310
            • 2,310 Posts
            I know where you got the code, I wrote it wink
            Are there two columns in the DB => names & content?
              • 24969
              • 120 Posts
              DB table has three columns in it ID, names, content
                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
                • 4310
                • 2,310 Posts
                Calling [!MySnippet!] should work, can’t see what’s different to my setup sad
                  • 24969
                  • 120 Posts
                  Something heppened....
                  Now calling [!about!] displays;
                  1

                  1
                  J

                  J
                  J

                  J

                  lol no idea where that is coming from.... but it is displaying something.
                    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
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    It looks like it’s returning everything as arrays, and only displaying the first element of the array (the first character in the string). I’ve run across that before.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 20413
                      • 2,877 Posts
                      Just for the record - I have that original makeArray() code working perfect.
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower