making the nodeteaser form collapsible

Christefano - October 25, 2006 - 17:55
Project:Node Teaser
Version:4.7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:jillelaine
Status:needs review
Description

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?

#1

nevets - October 25, 2006 - 18:21

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!'),
    );

#2

nevets - October 25, 2006 - 18:22

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

#3

jillelaine - December 28, 2006 - 15:06

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;
}

#4

jillelaine - December 29, 2006 - 05:22
Assigned to:Anonymous» 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.

#5

Christefano - December 29, 2006 - 17:21

jillelaine, can you create and post a patch?

#6

jillelaine - January 3, 2007 - 02:26
Category:support request» feature request

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

AttachmentSize
nodeteaser-collapsible.patch 1.26 KB

#7

mdupont - March 6, 2009 - 21:53

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

 
 

Drupal is a registered trademark of Dries Buytaert.