Hey there,

as far as I understood the rpoblem, it is not possible to use wysiwyg editors on the input field of the guestbook module, although I can assign an input filter in the guestbook settings.

What is necessary to get guestbook working with wysiwyg editors? Is this a guestbook or a wysiwy topic? I remember, that worked with the old tinyMCE module.

Best wishes,
forschi

CommentFileSizeAuthor
#12 guestbook1.diff1.6 KBAlmAck

Comments

sun’s picture

Title: Make wysiwyg compatible to guestboo module » Wysiwyg support
Project: Wysiwyg » Guestbook
Version: 6.x-2.0 » 6.x-2.x-dev
Component: User interface » Code

Guestbook has to store the input format for each message - and therefore expose an input format selector in the guestbook entry form. The hard-coded admin setting must go away.

See also http://drupal.org/node/358316

Anonymous’s picture

Thanks for that information. It seems important to me, to provide WYSIWYG support for this module.

The admin settings are useful, as I don't want to bother my site visitors with the selection of input formats or with the useless help messages below a wysiwyg area. Maybe it's possible to define the input format as admin but store the input format for each message anyway.

nikolajb’s picture

Gah. This seems like a huge problem to me. Couldn't the formats be hidden by using the Better Formats module, or am I completely mistaken?

I think I'm going to make a simple guestbook by setting up a commentable page instead. Not a perfect solution, but when the Guestbook doesn't support something as essential as a wysiwyg editor, I think that's the best choice :)

darthf1’s picture

Subscribe. I tried to do fix this manually with the link provided earlier, but no results. Is there a page with more documentation to create wysiwyg support?

CWolff’s picture

you can code this in yourself by changing:

this section:
$form['message'] = array(
'#type' => 'textarea', '#title' => t('Message'),
'#cols' => 74, '#rows' => GUESTBOOK_TEXTAREA_ROWS, '#description' => $filter_tips, '#required' => TRUE,
);

to this:
$form['message']['message_area'] = array(
'#type' => 'textarea', '#title' => t('Message'),
'#cols' => 74, '#rows' => GUESTBOOK_TEXTAREA_ROWS, '#description' => $filter_tips, '#required' => TRUE,
);
$form['message']['format'] = filter_form(2, NULL, array('message'));

--------

and then find this line:
$message = $form_state['values']['message'];

and change it to this:
$message = $form_state['values']['message_area'];

--------
and lastly:
if ($entry['message'] == $message) {
return;
}

to this:
if ($entry['message_area'] == $message) {
return;
}

darthf1’s picture

Maybe supply this as a patch? Would be awesome and simple if it works.

darthf1’s picture

Tried #5, works for 6.x-2.x-dev!

tragic.rich’s picture

Thanks CWolff your code worked perfectly!
One problem that still remains for me:
I am only using guestbook as a site guestbook, the wysiwyg works perfectly for adding a guestbook entry, but when I try to comment on anyone's entry as an administrator the wysiwyg does not show up.
In fact ALL html that I enter as a 'comment' gets displayed as plain text...???

I have set the input format for the guestbook to filtered html, which works perfect for the entry, but for some reason it does not work for the comment. I have better inputs installed and have my admin role is set to use full html all the time...

help!!

promes’s picture

Comment #5 of CWolff is very usefull. There is one error in the code:
$form['message']['format'] = filter_form(2, NULL, array('message'));
should read:
$form['message']['format'] = filter_form(variable_get('guestbook_input_format', 1), NULL, array('message'));
since the format needs to be controlled by the admin settings.

I added myself the following code:

  if (variable_get('guestbook_input_format', 1) == 1) {
    $form['message']['format'][1]['#disabled'] = TRUE;
    $form['message']['format'][2]['#disabled'] = TRUE;
    $form['message']['format'][2]['#description'] = '';
    unset($form['message']['format'][3]);
    unset($form['message']['format'][4]);
    unset($form['message']['format'][5]);
  }

The goal is to prevent anyone to switch to full HTML if filtered HTML is defined.
You can limit filtered html to only guests, if you change:
if (variable_get('guestbook_input_format', 1) == 1) {
into,
if (variable_get('guestbook_input_format', 1) == 1 && !$user->uid) {
or, into only user 1 can do full HTML:
if (variable_get('guestbook_input_format', 1) == 1 && $user->uid != 1) {
When you make this change, everyone will get the default filter first, but all logged in users or only user 1 still can switch to full HTML.

The lines
$form['message']['format'][1]['#disabled'] = TRUE;
$form['message']['format'][2]['#disabled'] = TRUE;
prevent format switching on the form.

$form['message']['format'][2]['#description'] = '';
removes the text about the filter options.

unset($form['message']['format'][3]);
unset($form['message']['format'][4]);
unset($form['message']['format'][5]);
removes additional formats, like php formatting, and the message about more filter options. I don't like to inform guests about all formatting possibilities in my sites and use this also for restricting format information in comment forms.

I hope somebody will be happy with this comment. I did learn a lot from other comments as myself.

promes’s picture

Today I discovered how to get rid of the "inputformat" fieldset on the form to be shown. Just add the line:
$form['message']['format']['#title'] ='';
You will keep a straight line (it previously was there as well with the text: Inputformat).
So you don't need anymore these lines:

    $form['message']['format'][1]['#disabled'] = TRUE;
    $form['message']['format'][2]['#disabled'] = TRUE;
    $form['message']['format'][2]['#description'] = '';
    unset($form['message']['format'][3]);
    unset($form['message']['format'][4]);
    unset($form['message']['format'][5]);

If we add a permission to change the default format settings in guestbook_perm():
'change guestbooks format settings',
the total format setting will be as simple as:

  $form['message']['format'] = filter_form(variable_get('guestbook_input_format', 1), NULL, array('message'));
  if (!user_access('change guestbooks format settings')) {
    $form['message']['format']['#title'] ='';
  }
Lubas’s picture

Subscribe.
Supply as a patch would definitely be useful!

AlmAck’s picture

StatusFileSize
new1.6 KB

I'm interested in the same subject. I have collected all the tips and prepared a patch (attached)
Everything works fine but, 1 more thing to debug. The guestbook module use a variable to define if show or not the tips in the message area. This patch introduce the "filter_form" call, and the result is that the page show 2 copy of the same filter tips. One solution is to completely remove this line of code:
$filter_tips = variable_get('guestbook_filter_tips', TRUE) ? _guestbook_form_filter_tips() : NULL;
then if we need to hide the tips we must install the module better_formats. Other solutions?

This patch introduce:
- new wysiwyg text area
- new permission "change guestbooks format settings", if the user have this rights can change the format settings

ToDo:
- improve the filter tips display method

sun’s picture

Status: Active » Closed (duplicate)

Thanks for taking the time to report this issue.

However, marking as duplicate of #72607: Use entities for guestbooks and guestbook entries. You can follow up on that issue to track its status instead. If any information from this issue is missing in the other issue, please make sure you provide it over there.

dionis44’s picture

A little addition to CWolff's hack(Comment #5): don't forget change string
db_query("UPDATE {guestbook} SET message = '%s' WHERE id = %d", $form_state['values']['message'], $form_state['values']['entry_id']);
to
db_query("UPDATE {guestbook} SET message = '%s' WHERE id = %d", $form_state['values']['message_area'], $form_state['values']['entry_id']);
otherwise when user edits guestbook's entries he gets error (instead of edited text input filter id)

maki3000’s picture

To propose something to promes comments:

I think a more smoother way to blend out the input format fieldset than your mentioned way:
$form['message']['format']['#title'] ='';
(which actually just sets the related fieldset to 'display: none' in the system.css and leaves the lines of the standart fieldset style there. at least it does so in my settings.)

is to set a class for the input format fieldset, e.g. like this:
$form['message']['format']['#attributes']['class'] = 'guestbook-input-format';

That way you can control all of the fieldset with your custom CSS and not just the content of it.