Excerpt visibility on node types
stefano@tipic.com - July 22, 2006 - 00:30
| Project: | Excerpt |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
The attached patch allows admins to set the excerpt visibility on node types. The excerpt textarea will be visible in the edit form for the selected node types only.
| Attachment | Size |
|---|---|
| excerpt.module.patch.txt | 1.62 KB |

#1
Does this patch work for 4.7? How do you apply it? I'm having problems with the teaser field appearing on forum postings.
#2
Works fine on 4.7.4. Great feature. Thanks.
#3
BRAVO!!!!
Excerpt module is fantastic work, but this kind of flexibility is key in making Drupal easier to use. If you're not going to promote pages, stories, book nodes, images, etc. etc. to the front page, then likely you won't need the teaser. Seeing that big field there is kind of daunting for the uninitiated and a waste of screen space for others. THANK YOU!! Please allow this patch to be integrated into the module.
#4
Just what I needed. It was the first thing I went looking for - what - no node-type settings?
This patch went great on 4.7 for me (revisit admin/modules to make the new option show up in the menu)
Please commit as standard!
#5
is there any way to apply this to drupal 5.1?
#6
^^^ would appreciate that too!
#7
Try this patch. Works fine on my Drupal5.1 install. Patch rolled against 5.x-1.x-dev, 2007-Apr-21 version.
#8
Just updating the issue details.
#9
5.1 patch looks fine
though Show excerpt for the selected node types, needs to be changed to opposite of what is taking place
#10
Scratch that the patch needs to be built against the latest version with teaser weights included can this be sorted asap
tks
M
#11
Try this. It was rolled against the April 24, 2007 version. I have also modified the weight so that it appears below the title and categories, and just above the body. Some text has also been changed to reflect the changes in the settings, etc.
This feature is sorely needed, and I hope it will be committed sometime soon.
#12
I tried installing the patch:
- renamed the patch to excerpt.module
- placed the file in the excerpt module folder
- went to update.php
- got the following error before even going ahead with the update:
-- excerpt.module Fri Dec 30 12:31:10 2005 +++ excerpt.module Wed May 30 16:18:46 2007 @@ -5,12 +5,30 @@ function excerpt_help($section) { switch ($section) { case 'admin/modules#description': return t('Allows users to enter a separate excerpt for nodes.'); - case 'admin/node/configure/defaults': - return t('
If you want users to be able to enter separate excerpts for nodes, check the excerpt box in the appropriate column.
'); + case 'admin/settings/excerpt': + return t('
If you want users to be able to enter separate excerpts for nodes, check the box for the appropriate node type.
'); } } +function excerpt_menu($may_cache) { + $items = array(); + + if ($may_cache) { + $items[] = array( + 'path' => 'admin/settings/excerpt', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('excerpt_admin_settings'), + 'title' => t('Excerpt'), + 'type' => MENU_NORMAL_ITEM, + 'access' => user_access('administer site configuration'), + 'description' => t('Select the node types in which to show an excerpt textarea.'), + ); + } + return $items; +} + function excerpt_nodeapi(&$node, $op, $arg) { + if (!_excerpt_is_visible($node)) return; switch ($op) { case 'validate': if (trim($node->teaser) == '') { @@ -27,6 +45,7 @@ function excerpt_form_alter($form_id, &$ if (isset($form['type'])) { $node = $form['#node']; + if (!_excerpt_is_visible($node)) return; if ($form['type']['#value'] .'_node_settings' == $form_id) { $form['excerpt'] = array('#type' => 'fieldset', '#title' => t('Excerpt')); $form['excerpt']['excerpt_options_'. $form['type']['#value']] = array( @@ -45,10 +64,27 @@ function excerpt_form_alter($form_id, &$ '#default_value' => $node->teaser, '#cols' => 60, '#rows' => 5, - '#weight' => -17.5, + '#weight' => -1, '#description' => t('Enter an excerpt for this item. It will be shown on listing pages along with a read more link which leads to the full view. Leave empty to auto-generate one from the body.') ); } } +} + +function excerpt_admin_settings() { + $form['excerpt_node_types'] = array( + '#type' => 'checkboxes', + '#title' => t('Node type visibility'), + '#default_value' => variable_get('excerpt_node_types', ''), + '#options' => node_get_types('names'), + '#description' => t('Show the Excerpt field for the selected node types.'), + ); + return system_settings_form($form); +} + +function _excerpt_is_visible($node) { + // check the excerpt visibility for current node type + $vis_types = variable_get('excerpt_node_types', ''); + return $vis_types[$node->type]; }
Drupal database update
warning: Cannot modify header information - headers already sent by (output started at /home/heritage/web/drupal5/modules/excerpt/excerpt.module:8) in /home/heritage/web/drupal5/includes/common.inc on line 141.
#13
Sorry, I read op on patching, donloaded the gnu patch utility, ran it against the latest posted april dev version, and the patch utility had errors.
patch -b excerpt.module excerpt5_nodevisibility_1.patch
patching file excerpt.module
Hunk #2 FAILED at 45.
Hunk #3 FAILED at 64.
2 out of 3 hunks FAILED -- saving rejects to file excerpt.module.rej
Can someone please post a patched module file?
Ktnk.
#14
I sometimes also get the "Hunk failed" error, and I think its something to do with the patch program itself. Anyway here is the patched module.
#15
Patched module seems to work fine (so far). Would be ideal to get this fix in for real.
#16
Does not work for me (5.1), I want the settings available where they belong, in contenttypes administration.
Altered module is attached. Please provide a patch against "5.x-1.x-dev 2007-Apr-21". Does anyone know if the author has abandoned this module?
Please test and let me now how it behaves.
(remove .txt from attachment)
Regards,
Kees
Qrios Webdiensten
#17
Attached is a patch based on above comment.
#18
Oops! I forgot to attach the patch. Here it is.
#19
@ TBarregren
Thanks for patch. Did you use the altered module? If so, no issues?
#20
Subscribing
#21
Subscribing
#22
I believe this functionality was added.
#23
Indeed, this has been committed to HEAD. Closing.
#24
Automatically closed -- issue fixed for two weeks with no activity.