We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25388
    • 31 Posts
    I am trying to update a chunk via eForm. The chunk is used by a calendar snippet which parses the chunk and splits the containing dates by ’\n’ to display them as marked.
    I already managed to get the chunk updated but the calendar wont display the new added dates. When i open the chunk in the manager and save it without touching it, it will be parsed successfully. What is the difference by updating the chunk via query or saving it with the manager? I can’t see any difference in the database either ...

    That’s how i update the chunk
    $table = $modx->getFullTableName("site_htmlsnippets");
    $rows_affected = $modx->db->update("snippet = '". $reservations ."'", $table, "name='Reservationen'");
    


    Any ideas?
      • 22303 MODX Staff
      • 10,725 Posts
      You need to escape the user-input properly to be stored in the database. You can use $modx->db->escape() to do this, e.g.
      <?php
      $table = $modx->getFullTableName("site_htmlsnippets");
      $rows_affected = $modx->db->update("snippet = '". $modx->db->escape($reservations) ."'", $table, "name='Reservationen'");
      ?>
        • 25388
        • 31 Posts
        mhhh... if i escape my content the linebreaks disappear :-S

        could this be a caching issue with cached chunks? As i’ve seen the cache is flushed when saving the chunk via manager ...
          • 25388
          • 31 Posts
          It seemed to be a caching issue. Adding the same code as in the save_htmlsnippet... page solved my issue.