Form Handler:
Code: Select all
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#edit').submit(function(e) {
e.preventDefault();
var id = "<?php echo $Sys->Template->getData('block_id'); ?>";
var type = $('#type').val();
<?php if ($Sys->Template->getData('block_type') == 'wysiwyg') { ?>
tinyMCE.triggerSave();
<?php } ?>
var content = $('#field').val();
var dataString = 'id=' + id + '&field=' + content + '&type=' + type;
$.ajax({
type: "POST",
url: "core/cms/edit.php",
data: dataString,
cache: false,
success: function(html) {
$('#cboxLoadedContent').html(html);
}
});
});
$('#cms_cancel').on('click', function(){
if (tinyMCE.getInstanceById('field')) {
tinyMCE.execCommand('mceFocus', false, 'field');
tinyMCE.execCommand('mceRemoveControl', false, 'field');
}
$(this).colorbox.close();
});
});
</script>
<?php
global $Sys;
if ($Sys->Template->getData('block_type') == 'wysiwyg')
{ ?>
<script type="text/javascript">
tinymce.init({
mode: "textareas",
width: 820,
height: 500,
plugins: [
"advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
],
toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | inserttime preview | forecolor backcolor",
menubar: false,
toolbar_items_size: 'medium',
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
],
templates: [
{title: 'Test template 1', content: 'Test 1'},
{title: 'Test template 2', content: 'Test 2'}
],
// Example content CSS (should be your site CSS)
content_css : "css/style.css, css/tinymce.css"
});
setTimeout(function() {tinyMCE.execCommand('mceAddControl', false, 'field');}, 0);
</script>
<?php } ?>Code: Select all
<div id="cb_wrapper">
<h2>Edit Content Block: <i><?php echo $Sys->Template->getData('block_id'); ?></i></h2>
<form action="" method="post" id="edit">
<fieldset>
<div class="row">
<label for="field">Block Content: </label>
</div>
<div class="row">
<?php echo $Sys->Template->getData('cms_field'); ?>
<input type="hidden" id="type" value="<?php $Sys->Template->getData('block_type'); ?>" />
</div>
<div class="row submitrow">
<input type="submit" name="submit" class="submit" value="Save" />
<a href="#" id="cms_cancel">Cancel</a>
</div>
</fieldset>
</form>
</div>