Skip to content

Instantly share code, notes, and snippets.

@amphibian
Created May 24, 2011 21:21
Show Gist options
  • Save amphibian/989719 to your computer and use it in GitHub Desktop.
Save amphibian/989719 to your computer and use it in GitHub Desktop.
Set default formatting options in ExpressionEngine.
<?php
// Note that this has only been tested with the 2.1.5 beta
// Editing starts at line 3926 and goes until line 3963 of /system/expressionengine/controllers/cp/admin_content.php
// Start here:
// build list of formatting options
// (Add whatever additional formatting plugins you like here)
$vars['field_fmt_options'] = array(
'none' => $this->lang->line('none'),
'br' => $this->lang->line('auto_br'),
'xhtml' => $this->lang->line('xhtml'),
'format_characters' => 'Format Characters',
'textile' => 'Textile',
'valid_url' => 'Valid URL'
);
if ($type == 'new')
{
$vars['edit_format_link'] = '';
}
else
{
$confirm = "onclick=\"if( !confirm('".$this->lang->line('list_edit_warning')."')) return false;\"";
$vars['edit_format_link'] = '<strong><a '.$confirm.' href="'.BASE.AMP.'C=admin_content'.AMP.'M=edit_formatting_options'.AMP.'id='.$field_id.'" title="'.$this->lang->line('edit_list').'">'.$this->lang->line('edit_list').'</a></strong>';
$this->db->select('field_fmt');
$this->db->where('field_id', $field_id);
$this->db->order_by('field_fmt');
$query = $this->db->get('field_formatting');
if ($query->num_rows() > 0)
{
foreach ($query->result_array() as $row)
{
if(!array_key_exists($row['field_fmt'], $vars['field_fmt_options']))
{
$vars['field_fmt_options'][$row['field_fmt']] = ucwords(str_replace('_', ' ', $row['field_fmt']));
}
}
}
}
// The above chunk of code replaces everything until this line:
$vars['field_fmt'] = (isset($field_fmt) && $field_fmt != '') ? $field_fmt : 'xhtml';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment