Drupal & CKeditor Load Configuration Settings On Dynamic Page

In Drupal the ckeditor hooks into form so that it populates all of the profile configuration information on page load. This works pretty well unless you use an ajax call to dynamically load a textarea. This code will allow you to pull that info for a given profile and place a ckeditor on the textarea. It only utilizes a few of the settings available. You should be able to easily modify to suit your purposes.

Just to note, it was a D6 site, ckeditor module using 3.6.4

function get_cke_settings($profile){
    module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
    $full_profile = ckeditor_profile_load($profile); 
    $profile_settings = $full_profile->settings;
    //send this piece of the array to ckeditor function that populates paths to/for plugins
    $plugin = $profile_settings[loadPlugins];
    $plugin_paths = ckeditor_plugins_render($plugin);
    //replace this part of the array with part returned from function
    $profile_settings[loadPlugins] =  $plugin_paths;
   //if you have encoding type issues try using php's encoder
  //  print json_encode($profile_settings);

You’ll need to add a menu path for the function. Here’s the js that makes an ajax request to this function. I just added this to the success function of the request that loads the dynamic textarea. The id was ‘agenda-text’ – dont forget to change this to match whatever you have. I also set it up so that the last parameter passed to the function is the name of the profile.

$.getJSON('path/to/function/MINItoolbar', function(data) {
var result = data;
toolbarSetting =   result.toolbar;
skinSetting    =   result.skin;
plugins        =  result.loadPlugins;
js_conf        =  result.js_conf;
stylesPath     =   "drupal:" + result.styles_path;
   jQuery.extend(Drupal.settings, {
        "ckeditor": {
                       "agenda-text": {                  
                           "toolbar": toolbarSetting,
                            "skin": skinSetting,
                            "loadPlugins": plugins,
                            "stylesCombo_stylesSet": stylesPath,        

Drupal – Pass Data To Template File

Probably most useful for passing large blocks of data that can be iterated over from within the template file. Using this method allows the developer to keep the application logic separate from the presentation layer. The data being passed in would most typically be an array.

1) Create the function that will generate the data block i.e.

function template_preprocess_my_form(&$variables) {
     $data = array("foo" => "bar", "bar" => "foo");
     $variables['template_data'] = $data;

The important part is to name your function appropriately so that it will hook the correct form. In this instance the form hook is my_form.

2) Modify hook_theme to accomodate the variable

function my_module_theme() {
    $theme = array(
    'my_form' => array(
            'arguments' => array('form' => NULL,
                                 'template_data' => NULL),
            'template' => 'my_form_template',
    return $theme;

Here it is important to ensure the array element key matches the variable that was added to the form’s variable array – in this case it is template_data

3) Access the variable you have created in the template file. The variable will available by adding the $ to the variable created in the steps above, in this case $template_data, and it can be used as a normal php variable, i.e.

foreach ($template_data as $i => $values) :
     echo $template_data[$i]

Update To Drupal 7.2 The Easy Way (SSH)

After backing everything up…

# get the upgrade
wget http://ftp.drupal.org/files/projects/drupal-7.2.tar.gz
# uncompress it
tar xfzv drupal-7.2.tar.gz
# copy all files to my document root
cp -r drupal-7.2/. /www/.

found here