I added these lines to the nodeteaser form, but it doesn't affect the form at all.

      '#collapsible' => true, 
      '#collapsed' => true,

What do I need to do to make the form collapsible?

CommentFileSizeAuthor
#6 nodeteaser-collapsible.patch1.26 KBjillelaine

Comments

nevets’s picture

This should do it, in _nodeteaser_form() change

   $form['nodeteaser'] = array(
      '#type' => 'textarea',
      '#title' => t('Teaser or Summary'),
      '#default_value' => $tags->teaser,
      '#cols' => 65,
      '#rows' => 12,
      '#description' => t('Enter a teaser, summary, or description for this node. If you would like the whole body to display, DO NOT enter a teaser!'),
    );

to

   $form[holder']['nodeteaser'] = array(
      '#type' => 'fieldset',
      '#title' => t('Teaser or Summary'),
      '#collapsible' => true,
      '#collapsed' => true,
  );
   $form[holder']['nodeteaser'] = array(
      '#type' => 'textarea',
      '#default_value' => $tags->teaser,
      '#cols' => 65,
      '#rows' => 12,
      '#description' => t('Enter a teaser, summary, or description for this node. If you would like the whole body to display, DO NOT enter a teaser!'),
    );
nevets’s picture

Opps $form[holder'] should be $form[;holder'] (missing a single quote)

jillelaine’s picture

i tried the code above (after some minor edits), but it doesn't work. :-(
i looked at other modules that allow collapsing, but was not able to solve the riddle of how they work.
any help is appreciated!

here is the code i used (replaces the function _nodeteaser_form in nodeteaser.module)

/**
 * Create a form - returns a $form variable
 */
function _nodeteaser_form($type, $tags) {
  //$settings = _nodewords_get_settings();
  $form = array();
  
   $form['holder']['nodeteaser'] = array(
  '#type' => 'fieldset',
  '#title' => t('Teaser or Summary'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  );
  $form['holder']['nodeteaser'] = array(
  '#type' => 'textarea',
  '#title' => t('Teaser or Summary'),
  '#default_value' => $tags->teaser,
  '#cols' => 65,
  '#rows' => 12,
  '#description' => t('Enter a teaser, summary, or description for this node. If you would like the whole body to display, DO NOT enter a teaser!'),
);

  return $form;
}
jillelaine’s picture

Assigned: Unassigned » jillelaine
Status: Active » Needs review

Got some code that works! With this code, the nodeteaser field will be collapsed by default. Change to '#collapsed' => FALSE, to switch the default behavior.

Replace the nodeteaser.module function _nodeteaser_form with the code below to make the nodeteaser collapsible.

/*
 * Create a form - returns a $form variable
 */
function _nodeteaser_form($type, $tags) {
  $form = array();
  
  $form['holder'] = array(
      '#type' => 'fieldset', 
      '#title' => t('Teaser or Summary'), 
      '#collapsible' => TRUE, 
      '#collapsed' => TRUE,
  );

   $form['holder']['nodeteaser'] = array(
      '#type' => 'textarea',
      '#default_value' => $tags->teaser,
      '#cols' => 65,
      '#rows' => 12,
      '#description' => t('Enter a teaser, summary, or description for this node. If you would like the whole body to display, DO NOT enter a teaser!'),
    );

  return $form;
}

Please review! Comments? Thank you for all the input on this.

Christefano-oldaccount’s picture

jillelaine, can you create and post a patch?

jillelaine’s picture

Category: support » feature
StatusFileSize
new1.26 KB

Here is a patch to make the nodeteaser.module collapsible.

To apply the patch, copy the nodeteaser-collapsible.patch into the same folder as your nodeteaser.module.

Then, at the command line:

patch <nodeteaser-collapsible.patch

This command will create a back up of your original nodeteaser.module named nodeteaser.module.orig and patch the code in nodeteaser.module.

Feedback requested please. Thank you

mdupont’s picture

The 4.7 version of the module (and Drupal) seems no longer developed. Closing.

mdupont’s picture

Status: Needs review » Closed (fixed)