modChunk.save
Last updated not available | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodChunk::save¶
Writes the Chunk record to the database. The call goes through modElement::save, which also synchronizes the external file of a static Chunk.
Both events fire only when the instance is a modX: OnChunkBeforeSave before the write, OnChunkSave after it succeeded. Each event receives the mode (new or upd), a reference to the chunk, and the cacheFlag.
A listener can modify the Chunk because the write happens after the event. Listener return values are ignored, so the save cannot be aborted from an event. A failed write is logged as chunk_err_create for a new Chunk or as chunk_err_save for an existing one.
Syntax¶
boolean save ([boolean|integer $cacheFlag = null])
-
$cacheFlag(boolean|integer) Whether the record is cached; an integer is the lifetime in seconds, by defaultnull. Both events receive it as a parameter. - Declared in
modChunk(core/src/Revolution/modChunk.php), wrapsmodElement::save(core/src/Revolution/modElement.php).
Example¶
$chunk = $modx->newObject('modChunk');
$chunk->fromArray([
'name' => 'MyChunk',
'content' => '<p>Hello!</p>',
]);
$chunk->save();
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










