<?php//remove this line - its only for styling in this forum!!!
$chunkname='editchunk';//edit this line for your chunk you want to edit
$e = &$modx->Event;
switch($e->name) {
case 'OnDocFormRender':
echo '<div class="sectionHeader">Chunks</div>
<div class="sectionBody chunks">
<table cellspacing="0" cellpadding="3" border="0" width="96%" style="position: relative;">
<tbody><tr style="height: 24px;"><td align="left" width="150" valign="top"><span class="warning">edit chunk</span>
<br/><span class="comment"/></td>
<td valign="top" style="position: relative;">
<textarea style="width: 100%;" onchange="documentDirty=true;" rows="15" cols="40" name="chunkcontent" id="chunkcontent"/>'.$modx->getChunk($chunkname).'</textarea>
</td></tr></tbody></table>
</div>';
break;
case 'OnBeforeDocFormSave':
if (isset($_POST['chunkcontent'])){ $modx->db->update(array('snippet'=>$modx->db->escape($_POST['chunkcontent'])),$modx->getFullTablename('site_htmlsnippets'),'name="'.$chunkname.'"');
}
default:
return;
break;
}
Excellent have this working..
Just one thing the text is not formattable, is there a way to enable the text editor so i can neaten the text?
Thanks
<?php//remove this line - its only for styling in this forum!!!
$chunkname = 'editchunk';//edit this line for your chunk you want to edit
$e = & $modx->Event;
switch($e->name)
{
case 'OnDocFormRender':
echo '<div class="sectionHeader">Chunks</div>
<div class="sectionBody chunks">
<table cellspacing="0" cellpadding="3" border="0" width="96%" style="position: relative;">
<tbody><tr style="height: 24px;"><td align="left" width="150" valign="top"><span class="warning">edit chunk</span>
<br/><span class="comment"/></td>
<td valign="top" style="position: relative;">
<textarea style="width: 100%;" onchange="documentDirty=true;" rows="15" cols="40" name="chunkcontent" id="chunkcontent"/>'.$modx->getChunk($chunkname).'</textarea>
</td></tr></tbody></table>
</div>';
global $replace_richtexteditor;
if (is_array($replace_richtexteditor))
{
$replace_richtexteditor = array_merge($replace_richtexteditor, array (
"chunkcontent",
));
} else
{
$replace_richtexteditor = array (
"chunkcontent",
);
}
break;
case 'OnBeforeDocFormSave':
if ( isset ($_POST['chunkcontent']))
{
$modx->db->update( array ('snippet'=>$modx->db->escape($_POST['chunkcontent'])), $modx->getFullTablename('site_htmlsnippets'), 'name="'.$chunkname.'"');
}
break;
case 'OnRichTextEditorInit':
//$modx->logEvent(1, 1, print_r($params, true));
break;
default:
return;
break;
}