Skip to content

Instantly share code, notes, and snippets.

<?php
public function getEntryJson(EntryModel $entry)
{
$entryData = array();
foreach ($entry->getType()->getFieldLayout()->getFields() as $field)
{
$field = $field->getField();
$handle = $field->handle;
<?php
// Get the entry
$entry = craft()->entries->getEntryById(100);
// Define the new Matrix data
$matrixData = array(
'1' => array( // '1' is an existing block ID
'type' => 'text', // 'text' is the block type handle
'enabled' => true,