I am creating a form in my template.php file using drupal_get_form() and I need this form to have Bueditor functionality. To be a bit more specific, I am creating Drupal's comment input form using the following code in template.php:

$vars['comment_form'] = drupal_get_form('comment_form', array('nid' => $vars['node']->nid));

However, Bueditor is not attached to the textarea of this form. How can I attach Bueditor at template.php level?

Comments

ufku’s picture

Isn't this possible configuring visibility settings of your editor?

If you want to force an editor load and attach to a textarea, here is the method.

if (function_exists('bueditor_settle')) {
  bueditor_settle(5);//5 is the editor ID of my choice. You should first grab your editor's id in admin section.
  drupal_add_js('$(document).ready(function() {BUE.processTextarea("edit-comment", "e5")', 'inline');//this will attach editor-5 to a textarea with the ID=edit-comment 
}
2c’s picture

Title: Calling Bueditor in template.php? » @ufku "Isn't this possible configuring visibility settings of your editor?"

@ufku "Isn't this possible configuring visibility settings of your editor?"

I can attach Bueditor to my comments form using the default Drupal process, however when I create a form in template.php the textarea appears without Bueditor. At a guess I'd say that Bueditor normally has a chance to alter the form created by comments.module, however when it is being created at the template.php stage then I'd have to invoke Bueditor specifically (i.e. not relying on hooks) to alter the form.

I will try your method listed in response #1 above.

2c’s picture

Title: @ufku "Isn't this possible configuring visibility settings of your editor?" » Calling Bueditor in template.php?

I tried your code in the phptemplate_preprocess_page function in template.php but it doesn't insert any javascript into the page source. If I include your code listed in #1 outside this function(phptemplate_preprocess_page) then the corresponding javascript is inserted into the page...alas, no bueditor (except bueditor is appearing on my other textarea which has been created by the default Drupal process of creating a comment form). Will investigate this further.

ufku’s picture

That's because js and css files are processed before you call bueditor.
You have to update the variables that were created in template_preprocess_page()
$variables['styles'] = drupal_get_css();
$variables['scripts'] = drupal_get_js();

ufku’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

a_c_m’s picture

Just a minor point, but the call needs the # in the selector or it wont work.

e.g.

if (function_exists('bueditor_settle')) {
  bueditor_settle(5);//5 is the editor ID of my choice. You should first grab your editor's id in admin section.
  drupal_add_js('$(document).ready(function() {BUE.processTextarea("#edit-comment", "e5")', 'inline');//this will attach editor-5 to a textarea with the ID=edit-comment 
}