Skip to content

Instantly share code, notes, and snippets.

@hkirsman
Last active January 4, 2016 05:39
Show Gist options
  • Save hkirsman/8577029 to your computer and use it in GitHub Desktop.
Save hkirsman/8577029 to your computer and use it in GitHub Desktop.
Alter default Drupal CKEditor.
<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function salva_wysiwyg_editor_settings_alter(&$settings, &$context) {
if ($context['profile']->editor == 'ckeditor') {
if (arg(0) == 'node') {
$nid = arg(1);
// Get node type fast.
$result = db_query('SELECT type FROM {node} WHERE nid = :nid LIMIT 1', array(':nid' => $nid));
$node_type = $result->fetchAssoc();
$node_type = $node_type['type'];
}
// Check status of RDF module.
$result = db_query('SELECT status FROM system WHERE name = \'rdf\' LIMIT 1');
$rdf_status = $result->fetchAssoc();
$rdf_status = $rdf_status['status'];
if ($rdf_status == 1) {
$settings['docType'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">';
}
else {
$settings['docType'] = '<!DOCTYPE html>';
}
$settings['bodyClass'] = 'editor node' . (isset($nid) ? ' page-node-' . $nid . ' node-type-' . $node_type : '');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment