I use drush_make to gather my drupal 7 installation. I also get CKEditor automatically. But I am struggling to find out, how I can use the install profile to set it up automatically?

Here I get the files:

http://github.com/lsolesen/larsolesen.dk/blob/master/larsolesen_dk.make

libraries[ckeditor][download][type] = "get"
libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.4.1/ckeditor..."
libraries[ckeditor][directory_name] = "ckeditor"
libraries[ckeditor][destination] = "libraries"

I have an .install file based on standard, but cannot find any docs on how to setup the editor, e.g. choose it and configure it, during the install process.

My install file is here:

http://github.com/lsolesen/larsolesen.dk/blob/master/larsolesen_dk.install

Thanks in advance.

Comments

lsolesen’s picture

Anybody know this?

lsolesen’s picture

I need to find out how the settings are saved in th wysiwyg module. I found out, that I think I need the

function wysiwyg_profile_form_submit($form, &$form_state) {} from wysiwyg.admin.inc. However, I cannot find what $form_state is? And which stuff should go in form to save which buttons to show? And finally, how to even choose the appropriate editor for the different html outputs (filtered / unfiltered / plain).

lsolesen’s picture

Nobody else struggling with this?

jastraat’s picture

I'm also interested in an answer to this -

Silicon.Valet’s picture

Check the contents of the wysiwyg table after configuring your site. The configration data is serialized, you can use something like http://www.functions-online.com/unserialize.html to take a look, but a SQL dump from that table and subsequent import in your install profile (AFTER installing wysiwyg module!) should preserve settings.

SQL dump follows for simple base configuration.

INSERT INTO `wysiwyg` (`format`, `editor`, `settings`) VALUES
(1, 'ckeditor', 'a:20:{s:7:"default";i:1;s:11:"user_choose";i:0;s:11:"show_toggle";i:1;s:5:"theme";s:8:"advanced";s:8:"language";s:2:"en";s:7:"buttons";a:1:{s:7:"default";a:4:{s:4:"Bold";i:1;s:6:"Italic";i:1;s:9:"Underline";i:1;s:9:"PasteText";i:1;}}s:11:"toolbar_loc";s:3:"top";s:13:"toolbar_align";s:4:"left";s:8:"path_loc";s:6:"bottom";s:8:"resizing";i:1;s:11:"verify_html";i:1;s:12:"preformatted";i:0;s:22:"convert_fonts_to_spans";i:1;s:17:"remove_linebreaks";i:1;s:23:"apply_source_formatting";i:0;s:27:"paste_auto_cleanup_on_paste";i:0;s:13:"block_formats";s:32:"p,address,pre,h2,h3,h4,h5,h6,div";s:11:"css_setting";s:5:"theme";s:8:"css_path";s:0:"";s:11:"css_classes";s:0:"";}'),
(2, 'ckeditor', 'a:20:{s:7:"default";i:1;s:11:"user_choose";i:0;s:11:"show_toggle";i:1;s:5:"theme";s:8:"advanced";s:8:"language";s:2:"en";s:7:"buttons";a:1:{s:7:"default";a:20:{s:4:"Bold";i:1;s:6:"Italic";i:1;s:9:"Underline";i:1;s:11:"JustifyLeft";i:1;s:13:"JustifyCenter";i:1;s:12:"JustifyRight";i:1;s:12:"BulletedList";i:1;s:12:"NumberedList";i:1;s:7:"Outdent";i:1;s:6:"Indent";i:1;s:4:"Undo";i:1;s:4:"Link";i:1;s:6:"Unlink";i:1;s:5:"Image";i:1;s:6:"Source";i:1;s:3:"Cut";i:1;s:4:"Copy";i:1;s:9:"PasteText";i:1;s:13:"PasteFromWord";i:1;s:12:"RemoveFormat";i:1;}}s:11:"toolbar_loc";s:3:"top";s:13:"toolbar_align";s:4:"left";s:8:"path_loc";s:6:"bottom";s:8:"resizing";i:1;s:11:"verify_html";i:1;s:12:"preformatted";i:0;s:22:"convert_fonts_to_spans";i:1;s:17:"remove_linebreaks";i:1;s:23:"apply_source_formatting";i:0;s:27:"paste_auto_cleanup_on_paste";i:0;s:13:"block_formats";s:32:"p,address,pre,h2,h3,h4,h5,h6,div";s:11:"css_setting";s:5:"theme";s:8:"css_path";s:0:"";s:11:"css_classes";s:0:"";}'),
(3, '', NULL);
m_wiking’s picture

You probably solved it by now but here is a a method for this if someone else also are thinking about this. I've stole it from Openpublic my self. Look into openpublic_defaults.install to find more ideas about installation profiles.

function hive_set_wysiwyg_settings() {

  $settings = array(
    'default' => 1,
    'user_choose' => 1,
    'show_toggle' => 1,
    'theme' => 'advanced',
    'language' => 'en',
    'buttons' => array(
      'default' => array(
        'Bold' => 1,
        'Italic' => 1,
        'Underline' => 1,
        'Strike' => 1,
        'JustifyLeft' => 1,
        'JustifyCenter' => 1,
        'JustifyRight' => 1,
        'BulletedList' => 1,
        'NumberedList' => 1,
        'Undo' => 1,
        'Redo' => 1,
        'Link' => 1,
        'Unlink' => 1,
        'Anchor' => 1,
        'Image' => 1,
        'Superscript' => 1,
        'Subscript' => 1,
        'Blockquote' => 1,
        'HorizontalRule' => 1,
        'Cut' => 1,
        'Copy' => 1,
        'Paste' => 1,
        'PasteFromWord' => 1,
        'RemoveFormat' => 1,
        'SpecialChar' => 1,
        'Format' => 1,
        'Table' => 1,
        'Maximize' => 1,
      ),
      'imce' => array(
        'imce' => 1,
      ),
    ),
    'toolbar_loc' => 'top',
    'toolbar_align' => 'left',
    'path_loc' => 'bottom',
    'resizing' => 1,
    'verify_html' => 1,
    'preformatted' => 0,
    'convert_fonts_to_spans' => 1,
    'remove_linebreaks' => 1,
    'apply_source_formatting' => 0,
    'paste_auto_cleanup_on_paste' => 1,
    'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
    'css_setting' => 'self',
    'css_path' => '%t/css/editor.css',
    'css_classes' => '',
  );

  $fields = array(
    'format' => 'full_html',
    'editor' => 'ckeditor',
    'settings' => serialize($settings),
  );

  db_insert('wysiwyg')->fields($fields)->execute();

  db_update('filter_format')
  ->condition('format', 'filtered_html')
  ->fields(array('weight' => 1))
  ->execute();

  db_update('filter_format')
  ->condition('format', 'full_html')
  ->fields(array('weight' => 0))
  ->execute();

}
alfthecat’s picture

Hi, I am struggling with this for a long time, ideally I'd like a Feature to take care of configuring text editors but I have given up on that.

Would you have a tip for me to find appropriate code for my installation profile for Drupal 6?

Thanks in advance, appreciate any help!

----
"People make mistakes. To really mess something up you need a computer."

mlconnor’s picture

Here are a few more details that may help. First, setup Drupal and WYSIWYG with CK and then configure your options.

Then, get what you did from the database.

drush sql-query "select * from wysiwyg"

It will look nasty like this.

format	editor	settings
filtered_html	ckeditor	a:20:{s:7:"default";i:1;s:11:"user_choose";i:0;s:11:"show_toggle";i:1;s:5:"theme";s:8:"advanced";s:8:"language";s:2:"en";s:7:"buttons";a:2:{s:7:"default";a:49:{s:4:"Bold";i:1;s:6:"Italic";i:1;s:9:"Underline";i:1;s:6:"Strike";i:1;s:11:"JustifyLeft";i:1;s:13:"JustifyCenter";i:1;s:12:"JustifyRight";i:1;s:12:"JustifyBlock";i:1;s:12:"BulletedList";i:1;s:12:"NumberedList";i:1;s:7:"Outdent";i:1;s:6:"Indent";i:1;s:4:"Undo";i:1;s:4:"Redo";i:1;s:4:"Link";i:1;s:6:"Unlink";i:1;s:6:"Anchor";i:1;s:5:"Image";i:1;s:9:"TextColor";i:1;s:7:"BGColor";i:1;s:11:"Superscript";i:1;s:9:"Subscript";i:1;s:10:"Blockquote";i:1;s:6:"Source";i:1;s:14:"HorizontalRule";i:1;s:3:"Cut";i:1;s:4:"Copy";i:1;s:5:"Paste";i:1;s:9:"PasteText";i:1;s:13:"PasteFromWord";i:1;s:10:"ShowBlocks";i:1;s:12:"RemoveFormat";i:1;s:11:"SpecialChar";i:1;s:6:"Format";i:1;s:4:"Font";i:1;s:8:"FontSize";i:1;s:6:"Styles";i:1;s:5:"Table";i:1;s:9:"SelectAll";i:1;s:4:"Find";i:1;s:7:"Replace";i:1;s:5:"Flash";i:1;s:6:"Smiley";i:1;s:9:"CreateDiv";i:1;s:6:"Iframe";i:1;s:8:"Maximize";i:1;s:12:"SpellChecker";i:1;s:5:"Scayt";i:1;s:5:"About";i:1;}s:6:"drupal";a:1:{s:5:"break";i:1;}}s:11:"toolbar_loc";s:3:"top";s:13:"toolbar_align";s:4:"left";s:8:"path_loc";s:6:"bottom";s:8:"resizing";i:1;s:11:"verify_html";i:1;s:12:"preformatted";i:0;s:22:"convert_fonts_to_spans";i:1;s:17:"remove_linebreaks";i:1;s:23:"apply_source_formatting";i:0;s:27:"paste_auto_cleanup_on_paste";i:0;s:13:"block_formats";s:32:"p,address,pre,h2,h3,h4,h5,h6,div";s:11:"css_setting";s:5:"theme";s:8:"css_path";s:0:"";s:11:"css_classes";s:0:"";}

Copy the serialized piece and run this with php.

 $str = <<EOT
serialized text goes here....
EOT;
 var_export(unserialize($str));

This gives you the serialized options back as code. Then you can paste that into your profile.

  $filtered_html_wysiwyg = array(
  'default' => 1,
  'user_choose' => 0,
  'show_toggle' => 1,
  'theme' => 'advanced',
  'language' => 'en',
  'buttons' =>
  array (
    'default' =>
    array (
      'Bold' => 1,
      'Italic' => 1,
      'Underline' => 1,
      'Strike' => 1,
      'JustifyLeft' => 1,
      'JustifyCenter' => 1,
      'JustifyRight' => 1,
      'JustifyBlock' => 1,
      'BulletedList' => 1,
      'NumberedList' => 1,
      'Outdent' => 1,
      'Indent' => 1,
      'Undo' => 1,
      'Redo' => 1,
      'Link' => 1,
      'Unlink' => 1,
      'Anchor' => 1,
      'Image' => 1,
      'TextColor' => 1,
      'BGColor' => 1,
      'Superscript' => 1,
      'Subscript' => 1,
      'Blockquote' => 1,
      'Source' => 1,
      'HorizontalRule' => 1,
      'Cut' => 1,
      'Copy' => 1,
      'Paste' => 1,
      'PasteText' => 1,
      'PasteFromWord' => 1,
      'ShowBlocks' => 1,
      'RemoveFormat' => 1,
      'SpecialChar' => 1,
      'Format' => 1,
      'Font' => 1,
      'FontSize' => 1,
      'Styles' => 1,
      'Table' => 1,
      'SelectAll' => 1,
      'Find' => 1,
      'Replace' => 1,
      'Flash' => 1,
      'Smiley' => 1,
      'CreateDiv' => 1,
      'Iframe' => 1,
      'Maximize' => 1,
      'SpellChecker' => 1,
      'Scayt' => 1,
      'About' => 1,
    ),
    'drupal' =>
    array (
      'break' => 1,
    ),
  ),
  'toolbar_loc' => 'top',
  'toolbar_align' => 'left',
  'path_loc' => 'bottom',
  'resizing' => 1,
  'verify_html' => 1,
  'preformatted' => 0,
  'convert_fonts_to_spans' => 1,
  'remove_linebreaks' => 1,
  'apply_source_formatting' => 0,
  'paste_auto_cleanup_on_paste' => 0,
  'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div',
  'css_setting' => 'theme',
  'css_path' => '',
  'css_classes' => '',
);

  db_query('INSERT INTO wysiwyg VALUES (\'filtered_html\',\'ckeditor\', :serial)',
    array('serial'=>serialize($filtered_html_wysiwyg)));

So that will push the values back into the database within your profile. In this case, it also sets the editor for filtered to be ckeditor.

I selected all options within CK thinking it would be nice to turn them on and off within the code. If you simple remove line items it will turn options off.

stongo’s picture

Thanks for the great info.
Only thing I would recommend is using the db_insert function instead of db_query for Drupal 7

  $wysiwyg = db_insert('wysiwyg')->fields(array(
    'format' => 'filtered_html',
    'editor' => 'ckeditor',
    'settings' => serialize($filtered_html_wysiwyg)    
  ))
  ->execute();
thekrux’s picture

The above has helped me greatly and I want to first thank you for sharing it.

I'm wondering if it is possible to use the CKEditor during an install tasks with its buttons, etc showing. I have my module setup that supplies the form, which is part of my dependencies in the profile's .info file. I listed WYSIWYG as a dependency before any others, not sure if that implies the order they are activated or if that would matter at all. When I get to the install task form, I am met with a plain textarea where the field's '#type' is set to 'text_format' and '#format' is set to 'full_html'. This displays as expected on the module configuration screen, after Drupal installation is complete.

Currently I am exploring documentation on installation profiles and examples, but I thought I would ask here since this thread has gotten me so close. I will definitely post the solution if I find it on my own. Any ideas?