We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37583
    • 34 Posts
    Hi,

    I designed a site in Evolution and now I have moved it into Revolution 2.1.5.

    In Evolution I had a custom table called havainto. I imported the table into new database but my snippet call doesn't work in Revolution.

    I have a snippet call [!lintuHavainnot!] and a snippet called lintuHavainnot:

    <?php
    $output = '';
    $sql = $modx->db->query('SELECT * FROM  havainto where havainto="' . $modx->documentObject['pagetitle'] . '" ORDER BY date DESC ');//define the DB query, in this case the table is named 'havainto', 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['aika']=$item['date'];//set the placeholders, the $params sets the name of the placeholder, the $item is the column name from the DB table
    // $params['havainto']=$item['havainto'];
    $params['maara']=$item['maara'];
    $params['bongaaja']=$item['nimi'];
    $params['paikka']=$item['paikka'];
    $output.=$modx->parseChunk('naytaHavaintoTpl', $params, '[+', '+]');//define the chunk name and process the content, here it's naytaHavaintoTpl which has the placeholders for the data
    }//finish looping through the data array
    return $output;//now return the output from the processed chunk
    ?>


    with a chunk (naytaHavaintoTpl):

    <p>[+aika+] <strong>[+havainto+]</strong> [+maara+] kpl, [+bongaaja+], [+paikka+]</p>


    How do I get this to work in Revolution?

    I also had an eForm template that posted the content into the custom database. I didn't find any tutorials how to do that in FormIt. Can anyone help with this?

    Thank you!

    This question has been answered by multiple community members. See the first response.

      • 37583
      • 34 Posts
      I have also changed the snippet call into
      [[!lintuHavainnot]]


      In the chunk I replaced the [+...+] with
      [[+...]]
      and in the snippet:

      $params, '[+', '+]'); -> $params, '[[+', ']]');


      Is that correct? [ed. note: [email protected] last edited this post 12 years, 4 months ago.]
        • 37583
        • 34 Posts
        It outputs an error:

        Fatal error: Call to a member function query() on a non-object in /var/home/naturv01/webroot/core/cache/includes/elements/modsnippet/15.include.cache.php on line 8
          • 4172
          • 5,888 Posts
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 37583
            • 34 Posts
            Thanks! It's still not working.
            • discuss.answer
              • 4172
              • 5,888 Posts
              Quote from: [email protected] at Dec 16, 2011, 01:06 PM
              Thanks! It's still not working.
              this means?
              still the same error-message?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
              • discuss.answer
                • 37583
                • 34 Posts
                Yes. Do I need to do something else than just install the extra?
                • discuss.answer
                  • 4172
                  • 5,888 Posts
                  you can also try rowboat:

                  [[!Rowboat?
                     &table=`havainto`
                     &tpl=`naytaHavaintoTpl`
                     &columns=`{"date":"aika","maara":"","nimi":"bongaaja","paikka":""}`
                     &limit=`10`
                     &where=`{"havainto:=":"[[*pagetitle]]"}`
                     &sortBy=`date`
                     &sortDir=`DESC`
                  ]]
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                  • discuss.answer
                    • 37583
                    • 34 Posts
                    Thank you! Now it gets the data from the table.

                    Still, there is an other problem, the query doesn't understand scandinavian characters, like ä, ö, å, can anyone help with that?

                    What about the form?