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
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
Opps
$form[holder']should be$form[;holder'](missing a single quote)#3
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
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
jillelaine, can you create and post a patch?
#6
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.patchThis 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
#7
The 4.7 version of the module (and Drupal) seems no longer developed. Closing.