We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    Is there anyway to permanently alter a chunk?

    Like grab the data using:

    $data = $modx->getChunk(’chunk’);

    Then do some stuff to $data, then place $data back in as the data of the chunk from the getChunk call.
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 26435
      • 1,193 Posts
      Well, since you are pulling data from the database, you would need to INSERT INTO or UPDATE the database table fields in order to permanently update the chunk.

      $modx->db->query("UPDATE {PREFIX}.site_htmlsnippets SET snippet=’$data’ WHERE name=’chunkName’");

      -sD-
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages