Hello,

Apologies if this has been answered but I scanned all the issues here and spent some time on google and drupal.org with no success. I would like to require my users to use ckeditor to edit their biographical info on their profile page, eg http://kabissa.org/user/4313 for my profile. Right now that is straight HTML and it appears to be unfiltered to prevent unsafe code.

Is there a way to have ckeditor appear by default for everybody except admins for any textarea?

Thanks,

Tobias

Comments

TwoD’s picture

The user profile does not currently have a format selector (or stores the format), which Wysiwyg needs to figure out which editor to attach. This is something that would need fixing in Core, or by modifyng the profile form using the provided hooks. This has been discussed before but I can't find the issue now. It was suggested to create a helper module for Wysiwyg to provide format selectors for several fields in D6 Core which are missing format selectors.

Re your other question; no this is not possible using Wysiwyg alone (it doesn't "filter" on fields or roles, just input formats). If you use Better Formats you can make different input formats the default one per user role (and content type). Wysiwyg always shows an editor if a format with one is available and selected (unless manually disabled when editing).
There are several issues about improving this behaviour, but Wysiwyg profiles will always be associated with an input format. We'll be trying to allow multiple profiles per input format in Wysiwyg 3.x though.

whatsnewsisyphus’s picture

Use advanced profile kit of content profiles to use improved user profiles

Michelle’s picture

Just saw this mentioned on IRC and wanted to point out for future searchers that #2 doesn't make any sense here. APK will not help with this problem.

Michelle

crandallr’s picture

subscribing

W.M.’s picture

Component: Editor - CKeditor » Code

subscribing, me too.

I guess I can make the author list on one of my sites by a node based view (with links to biographies). But I think the more accurate way is to do it by an user based view. However, it seems like the Wysiwyg cannot be loaded in the edit pages of profile textarea fields. Any help will be highly appreciated.

sun’s picture

Status: Active » Closed (won't fix)

This is not possible, because the core Profile module does not expose any input/text formats for profile fields. It (always) defaults to the site's default text format.

Don't use core's Profile module. It's a horrible thing of the past.

ankheg’s picture

Managed to enable TinyMCE for profile fields via Wysiwyg. Here is my solution.

1. Create a custom module containing this code:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    $form['mycategory']['profile_myfield1']['#resizable'] = FALSE;
    $form['mycategory']['profile_myfield2']['#resizable'] = FALSE;
    $form['mycategory']['profile_myfield3']['#resizable'] = FALSE;
    // Initialize editor js
    $profile = wysiwyg_get_profile(1);
    if ($profile) {
      $theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : ''));
      wysiwyg_add_plugin_settings($profile);
      wysiwyg_add_editor_settings($profile, $theme);
    }
  }
}

2. In /sites/all/modules/wysiwyg/editors/tinymce.inc add some TinyMCE cconfiguration code to wysiwyg_tinymce_settings() after $settings initialization.

if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' && arg(3)) {
    $settings['mode'] = 'exact';
    $settings['elements'] = 'edit-profile-myfield1,edit-profile-myfield2,edit-profile-myfield3';
}

"Mymodule", "mycategory" and "profile_myfield" should be changed according to your setup.

I suppose similar workaround is possible with ckeditor.

ParisLiakos’s picture

thanks ankheg.
in order for the above to work on drupal 7,you need to replace

$profile = wysiwyg_get_profile(1);

with

$profile = wysiwyg_get_profile('filtered_html');
elliotcapelo’s picture

this is a fantastic idea! and thankyou so much for the code. Im having a bit of trouble implementing it, could you put up instruction on how to implement this module?

elliotcapelo’s picture

or could you put up instructions on how to implement a hook?

I put the above code in my install and it didn't work. This is what I have installed:
Drupal 6.22
Wysiwyg 6.x-2.1
WYSIWYG Panels 6.x-2.2
Wysiwyg SpellCheck 6.x-1.3
TinyMCE editor v 1.35

phelix’s picture

$ckeditor_format = mymodule_get_ckeditor_format();

I don't seem to have this function. I have tried mymodulename_get_ckeditor_format and also mymodulename_ckeditor_format did you need to use this function in order for this to work? Here is the c ode that I am using. I have been trying to get this to display on one of my custom fields I created in User Management -> Profiles in a text area.

function form_alter_form_alter($form, $form_state, $form_id){
global $user;


  if ($form_id == 'user_profile_form') {
    $form['Teacher Profile']['profile_teacher_schedule']['#resizable'] = 'FALSE';
	$form['Teacher Profile']['profile_teacher_schedule']['#rows'] = '10';
	$form['Teacher Profile']['profile_teacher_schedule']['#cols'] = '60';
	$form['Teacher Profile']['profile_teacher_schedule']['#weight'] = '50';
	$form['Teacher Profile']['profile_teacher_schedule']['#after_build'] = 'wysiwyg_process_form';
	$form['Teacher Profile']['profile_teacher_schedule']['format'] = filter_form($ckeditor_format, NULL, array('format'));
	$form = wysiwyg_process_form($form);
	$wysiwyg_profile = wysiwyg_get_profile(4);

  

//   print_r($form);
 
  }
  
// return($form);
}
premanup’s picture

Thank you, ankheg. Your solution works for my site.
Drupal 6.26
Wysiwyg 6.x-2.4
TinyMCE 3.5.0.1