The "Split Summary At Cursor" button is a new feature in Drupal 6. It allows you to split your content creation into a summary and the main content. This summary is displayed as the teaser and can be different than the main content. When I first learned of this feature, I thought it was great. From a web-development perspective, it is. However, from a usability perspective, this button very confusing. The average site visitor or user will have absolutely no idea what this button is or can do. Would anyone know of a simple way that I can "theme" this button off of the create content form page for everyone except the administrator role? Is there a way to deactivate or hide the button for certain roles? I would really appreciate the help. Thanks!

Comments

rrabbit’s picture

This is indeed a confusing and redundant feature for ordinary users on the community site I am building. Even more so because I am using the FCKeditor module, which seems to prevent the button doing anything at all!

I would really like to know how to hide this, but being new to the complexities of Drupal I have not yet managed to trace whatever it is that generates it.

Thanks in anticipation from me too!

[EDIT 23/03/08]

Found how to fix this.

(1) Edit misc/teaser.js to disable it:

Drupal.behaviors.teaser = function(context) {
  // This breaks in Konqueror. Prevent it from running.
  //if (/KDE/.test(navigator.vendor)) {    COMMENT OUT THIS LINE
    return;
  //}   AND THE CLOSING BRACKET 

(2) Hide the checkbox that is now visible by editing modules/system/system.css:

/* Keeps inner content contained in Opera 9. */
.teaser-checkbox {
  padding-top: 1px;
  display: none; /* ADD THIS */
}

Not elegant, but it works.

dasithds’s picture

Is it possible to completely disable the button?
I too use FCKEditor.

myTechDaily - The One Stop Tech Blog! - http://www.mytechdaily.com

rrabbit’s picture

Basically, just make misc/teaser.js impotent by reducing it to a return statement (don't delete it altogether because that would throw up errors). This gets rid of the button.

For some reason, removing the button reveals a checkbox, but you can remove this by editing modules/system/system.css, adding display: none; to the .teaser-checkbox style.

This solved the problem for me.

dasithds’s picture

ariite thanks for the advice.

myTechDaily - The One Stop Tech Blog! - http://www.mytechdaily.com

Jeff Burnz’s picture

You don't need to hack the core css or anything else for that matter, in your themes style.css file or equivalent you can just write:

.teaser-checkbox {
display:none;
}

Granted this just hides it, but at least there are no core hacks involved.

+1 for this being a configurable option in the node types settings and/or permission controlled.

note: when I installed TinyMCE the button goes away, interesting...

kenorb’s picture

Thanks.

keva’s picture

thanks rrabbit for this solution

nicholasbarcomb’s picture

FormDefaults Module. This module allows you to hide it per content type. The nice thing about this is it is per content type and you can re-enable it at anytime. No php code necessary.

portait’s picture

I have installed this module and I am able to disable the "description" of a content type but not the "split summary at cursor" button.
Where exactly could I disable the button?

simmoe’s picture

but where is it?

goose2000’s picture

I agree, not for everyone. In fact it really begs to be a feature of 'site editors'. It should be controlled by permission and roles.

ramper’s picture

I was checking back here to see if there has been any development to somehow make this feature optional - by way of permissions. I see that you can tweak your theme to hide it - but I was hoping to find a more elegant way (like so many other things in Drupal ;) to make this feature optional. That way, we could still have this feature (obviously it was considered important enought to include in D6) available for certain roles. Dont' know where to put this as a 'feature request' - so I guess I'll add to this thread.

thebenedict’s picture

This is a great feature for me, but confusing for site visitors.

suydam’s picture

+1 for any easy, non-hack way to hide this button. It's very counter-productive for regular web-site development.

arnoldc’s picture

+1.

Stumble on this problem as I use TinyMCE and I thought this can be easily done in hook_form_alter() but couldn't find it there.

Google and find this useful thread. Thanks.

EmanueleQuinto’s picture

Using hook form_later is possible to override (or unset) form element that create "Split Summary At Cursor" on MYTYPE node type:

Add in your custom.module:

function custom_form_alter(&$form, $form_state, $form_id) {
  if($form_id=='MYTYPE_node_form') {
    $form['body_field']['teaser_include'] = array(
      '#type' => 'value',
      '#value' => TRUE,
    );
  }
}

This should solve the problem.

markj’s picture

This works, just tested it on pages using if ($form_id =='page_node_form')

arnoldc’s picture

Great work! This is better as I prefer to keep the all changes in one place.

lourenzo’s picture

Setting as a value can cause errors.
It'd be better to use ['#access']=FALSE; , like this:

function custom_form_alter(&$form, $form_state, $form_id) {
  if($form_id=='MYTYPE_node_form') {
    $form['body_field']['teaser_include']['#access'] = FALSE;
  }
}
adrianmak’s picture

thanks.

rimu’s picture

Or, for ALL content types...


if(isset($form['body_field']['teaser_include'])) {
    $form['body_field']['teaser_include']['#access'] = FALSE;
  }



Naiya’s picture

best option in my opinion (display:none is not a good idea as we still have to render unwanted control)

spyderpie’s picture

Thanks in advance ;)

OneTwoTait’s picture

A simple solution for me was to just use a custom text box added with CCK rather than the default "body" box.

arnoldc’s picture

It is an alternative solution but definitely not simple as you need to install CCK and add a field and maintain the field list...etc

jmav’s picture

This code hides teaser-checkbox block in special content type.
Replace "ideja" with right content type.

___________________________________________________________________

In page.tpl.php add the following code.

<?php if (arg(0) == "node" & arg(1) == "add" & arg(2) == "ideja") { ?>
	<style>
		.teaser-checkbox { display: none;}
	</style>
<?php } ?>
firebee’s picture

This works on FF3 and Google Chrome which I tested, but not IE7. Any other way to keep the core untouched?

adamfeldman’s picture

use http://drupal.org/project/resizable_body - it allows you to disable the "split summary at cursor" button by content type within the edit page for the content type, under submission form settings.

francewhoa’s picture

Thanks adamfeldman. If you don't know how to use CSS then 'resizable_body' module is the easiest way to hide the "split summary at cursor" button. http://drupal.org/project/resizable_body

If you know how to use CSS another option is to hide it by adding one of the two below style to your stylesheet file.

This CSS will hide "split summary at cursor" button on all pages.

.teaser-checkbox {
     display: none;
}

This CSS will hide "split summary at cursor" button only on one specific page. The Zen theme is required for this to work.

.page-node-add-YOUR-NODE-TYPE-HERE 
.teaser-checkbox {
     display: none;
}

For example is your node type is 'job_posting' then the following line
.page-node-add-YOUR-NODE-TYPE-HERE
should read
.page-node-add-job-posting

To find the node type navigate to Administer > Content management > Content types. Click on EDIT link beside your content type. Find section TYPE. Note that in your style underscores _ must be replace with dashes -. For example 'job_posting' should be replace by 'job-posting'

Loving back your Drupal community result in multiple benefits for you  
George2’s picture

using css to hide the inputs is like parking a car in a field and painting it green. the best way is to remove it either with a custom module, or as onopoc and adamfeldman pointed out, with resizable_body :)

mrgavindb’s picture

This works for me. No problems whatsoever. This is probably the easiest way to hide the button. Thanks!

Rob T’s picture

Thanks for the recommendation.

mathieso’s picture

Here's some code I use to hide the Split button and the grippie, and replace the input format selection w/ some help. The code is specific to my needs, of course. Note that the BetterFormats module breaks this code.

The CSS file suppress_grippie.css has one line in it:

.grippie { display: none; }

Must be a better way to do this, but it works.

The changes are only made for users with the "editor" role, and for user 1.

/**
 * Alter the body input form to remove selection of input formats,
 * remove the teaser split doody, remove the grippie-field-expander
 * thing, and add some custom help.
 *
 * REMEMBER: Dogs are your friends!
 */
function coredogs_forms_form_alter(&$form, $form_state, $form_id) {
  global $user;
  //Only make changes for users who do not have the editor role.
  //Leave user 1 alone as well.
  $user_is_editor = in_array('editor', array_values($user->roles));
  $user_is_admin = $user->uid == 1;
  if ( ! ($user_is_editor || $user_is_admin) ) {
    //Is this a node content form, or a comment form?
    $is_node_content_form = strstr($form_id, '_node_form') !== FALSE;
    $is_comment_form = strstr($form_id, 'comment_form') !== FALSE;
    if ( $is_node_content_form || $is_comment_form ) {
      //Hide the Evil Grippie of Doom.
      drupal_add_css(
          drupal_get_path('module', 'coredogs_forms')
          .'/suppress_grippie.css'
      );
      //Create the help instructions.
      $help = <<<HELP
<p>Just type normally. Leave a blank line between paragraphs.</p>
<p>URLs will be converted into links.<p>
<p>You can add HTML tags, though you don't have to. You can use tags
for headings (&lt;h1&gt; to &lt;h6&gt;),
lists (&lt;ul&gt;, &lt;ol&gt;, &lt;li&gt;),
character formatting(&lt;strong&gt;, &lt;em&gt;),
indenting(&lt;blockquote&gt;), and other things. Experiment.</p>
<p>You can attach images and other files. Click the "File
attachments" link below.</p>
HELP;
      //Create the help instructions fieldset and display area.
      $help_fieldset =  array(
          '#title' => 'Input help',
          '#type' => 'fieldset',
          '#collapsible' => TRUE,
          '#collapsed' => TRUE
      );
      $help_display_area = array(
            '#type' => 'markup',
            '#prefix' => '<div class="coredogs-input-help">',
            '#value' => t($help),
            '#suffix' => '</div>'
      );
      //Adjust node content forms.
      if ( $is_node_content_form ) {
        //Replace format stuff with help.
        //REMEMBER: Be kind to dogs!
        $form['body_field']['format'] = $help_fieldset;
        $form['body_field']['format']['help'] = $help_display_area;
        //Remove the teaser.
        $form['body_field']['teaser_include'] = array(
          '#type' => 'value',
          '#value' => TRUE,
        );
      } // end is _node_form
      //Adjust comment forms.
      if ( $is_comment_form ) {
        //Replace format stuff with help.
        //REMEMBER: Your dog loves you!
        $form['comment_filter']['format'] = $help_fieldset;
        $form['comment_filter']['format']['help'] = $help_display_area;
      } // end is comment_form
    } // end is _node_form or comment_form
  } // end user is not admin or editor
}

If you want, you can grab a zip file with the code in module form.

Suggestions for improvements?

Kieran Mathieson
http://coredogs.com

scheyal’s picture

I used a few of the mentioned methods to try to hide the "split" button (all within a module, removing the teaser_include, or restricting access or adding a .css to hide the text).

The button is gone but I get the following warning after the post:

You specified that the summary should not be shown when this post is displayed in full view. This setting has been ignored since you have not defined a summary for the post. (To define a summary, insert the delimiter "

" (without the quotes) in the Body of the post to indicate the end of the summary and the start of the main content.)

(Adding the

before/after the body did not fix it).

Anyone hit this / know what code snippet is missing?

Thanks.

ccshannon’s picture

This 'feature' of D6 (which I didn't even know about six months into developing a site using D6 - given I went from D5 to D6 and installed all contrib modules without actually seeing the default D6 node edit forms) has caused me no small amount of stress.

If I had my project all over again, I would have done what was suggested above - use a separate CCK field for the body. This seems a bit much, given Body is a default feature across all Drupal nodes, but that's the easiest way to provide a real WYSIWYG experience for professional news editors, who really want to use an MS Word-like app to edit their stories, and avoid conflict with all this client-side javascript split-window, break-tag, teaser-body-re-concatenation business.

You need to hide the checkbox, but keep it checked. My guess is to use a form_alter hook in a custom module, OR create a javascript file with a jquery function that makes sure the checkbox is checked, even when hidden.

The message is triggered in this code, from node.module - the teaser_include checkbox is hidden, but not marked as 'checked':

/**
 * Ensure value of "teaser_include" checkbox is consistent with other form data.
 *
 * This handles two situations in which an unchecked checkbox is rejected:
 *
 *   1. The user defines a teaser (summary) but it is empty;
 *   2. The user does not define a teaser (summary) (in this case an
 *      unchecked checkbox would cause the body to be empty, or missing
 *      the auto-generated teaser).
 *
 * If JavaScript is active then it is used to force the checkbox to be
 * checked when hidden, and so the second case will not arise.
 *
 * In either case a warning message is output.
 */
function node_teaser_include_verify(&$form, &$form_state) {
  $message = '';

  // $form['#post'] is set only when the form is built for preview/submit.
  if (isset($form['#post']['body']) && isset($form_state['values']['teaser_include']) && !$form_state['values']['teaser_include']) {
    // "teaser_include" checkbox is present and unchecked.
    if (strpos($form_state['values']['body'], '<!--break-->') === 0) {
      // Teaser is empty string.
      $message = t('You specified that the summary should not be shown when this post is displayed in full view. This setting is ignored when the summary is empty.');
    }
    elseif (strpos($form_state['values']['body'], '<!--break-->') === FALSE) {
      // Teaser delimiter is not present in the body.
      $message = t('You specified that the summary should not be shown when this post is displayed in full view. This setting has been ignored since you have not defined a summary for the post. (To define a summary, insert the delimiter "&lt;!--break--&gt;" (without the quotes) in the Body of the post to indicate the end of the summary and the start of the main content.)');
    }

    if (!empty($message)) {
      drupal_set_message($message, 'warning');
      // Pass new checkbox value on to preview/submit form processing.
      form_set_value($form['teaser_include'], 1, $form_state);
      // Pass new checkbox value back onto form for those cases
      // in which form is redisplayed.
      $form['teaser_include']['#value'] = 1;
    }
  }

  return $form;
}

Also, in node.module, is this thing:

/**
 * See if the user used JS to submit a teaser.
 */
function node_teaser_js(&$form, &$form_state) {
  if (isset($form['#post']['teaser_js'])) {
    // Glue the teaser to the body.
    if (trim($form_state['values']['teaser_js'])) {
      // Space the teaser from the body
      $body = trim($form_state['values']['teaser_js']) ."\r\n<!--break-->\r\n". trim($form_state['values']['body']);
    }
    else {
      // Empty teaser, no spaces.
      $body = '<!--break-->'. $form_state['values']['body'];
    }
    // Pass updated body value on to preview/submit form processing.
    form_set_value($form['body'], $body, $form_state);
    // Pass updated body value back onto form for those cases
    // in which the form is redisplayed.
    $form['body']['#value'] = $body;
  }
  return $form;
}

and this line from the node_body_field function in node.pages.inc:

    '#default_value' => $include ? $node->body : ($node->teaser . $node->body),

Which causes all kinds of mayhem when you have TinyMCE installed, given the break tag won't work with TinyMCE (type it in and the comment tag will be converted to visible entities - Drupal won't see the break tag, etc.) So, instead when you open the node edit form, you get the teaser + body (the body already containing the teaser text) and it results in the body having repeating text.

I'd love to hear how to turn this all off, without hacking core, upgrading to D7, having to migrate all my body fields to a new CCK field (and subsequently change all my template code that points to the default body field).

Guo’s picture

subscribing

cardentey’s picture

My solutions from "Resizable Body module"

/**
 * Implementation of hook_form_alter()
*/
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  //
  // contenttype node form
  //
  if (substr($form_id, -10) == '_node_form') {

    $form['body_field']['body']['#rows'] = 5;
    $form['body_field']['body']['#resizable'] = TRUE;
    
    // remove "split summary at cursor" button and related elements if necessary
    $form['body_field']['#after_build'] = NULL;
    $form['body_field']['teaser_js'] = NULL;
    $form['body_field']['teaser_include'] = NULL;

  }

}
capellic’s picture

The solution nested as a reply above is probably the best, cleanest solution:

http://drupal.org/node/225955#comment-2065386

wwwoliondorcom’s picture

http://drupal.org/project/resizable_body works and is a great module with other functions

MakeOnlineShop’s picture

Yes it works perfectly !

Coupon Code Swap’s picture

This module works quite well and also lets you control other settings:

http://drupal.org/project/nodeformsettings

spyderpie’s picture

I don't care where, maybe permissions, maybe in the post settings, but I agree. It is too confusing for users and I would like to opt it out ;)
Julie

Stitchard’s picture

I use the Jammer module on all of my builds - http://drupal.org/project/jammer