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.

AttachmentSize
excerpt.module.patch.txt1.62 KB

#1

shiyre - August 15, 2006 - 03:46

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

incrn8 - December 8, 2006 - 00:40

Works fine on 4.7.4. Great feature. Thanks.

#3

kvarnelis - December 11, 2006 - 17:47

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

dman - December 19, 2006 - 01:34

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

robotjox - February 16, 2007 - 14:56

is there any way to apply this to drupal 5.1?

#6

kimangroo - April 30, 2007 - 07:49

^^^ would appreciate that too!

#7

incrn8 - April 30, 2007 - 17:52
Status:active» needs review

Try this patch. Works fine on my Drupal5.1 install. Patch rolled against 5.x-1.x-dev, 2007-Apr-21 version.

AttachmentSize
excerpt5_nodevisibility.patch 2.35 KB

#8

incrn8 - May 1, 2007 - 13:54
Version:6.x-1.x-dev» 5.x-1.x-dev
Category:task» feature request
Priority:minor» normal

Just updating the issue details.

#9

somes - May 30, 2007 - 11:02
Status:needs review» reviewed & tested by the community

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

somes - May 30, 2007 - 11:12
Status:reviewed & tested by the community» needs work

Scratch that the patch needs to be built against the latest version with teaser weights included can this be sorted asap

tks
M

#11

incrn8 - May 30, 2007 - 20:25
Status:needs work» needs review

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.

AttachmentSize
excerpt5_nodevisibility_1.patch 2.76 KB

#12

ktnk - June 1, 2007 - 02:02

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

ktnk - June 1, 2007 - 02:50

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

incrn8 - June 1, 2007 - 19:22

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.

AttachmentSize
excerpt.tgz 1.25 KB

#15

gusaus - July 5, 2007 - 21:16

Patched module seems to work fine (so far). Would be ideal to get this fix in for real.

#16

kees@qrios - July 18, 2007 - 14:45

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

AttachmentSize
excerpt.zip_.txt 990 bytes

#17

TBarregren - August 10, 2007 - 00:31

Attached is a patch based on above comment.

#18

TBarregren - August 10, 2007 - 01:02

Oops! I forgot to attach the patch. Here it is.

AttachmentSize
excerpt-5.x-1.x-dev-visibility.patch 2.25 KB

#19

kees@qrios - August 10, 2007 - 17:45

@ TBarregren
Thanks for patch. Did you use the altered module? If so, no issues?

#20

faunapolis - August 20, 2007 - 14:21

Subscribing

#21

jiangxijay - September 25, 2007 - 02:25

Subscribing

#22

hayesr - January 2, 2008 - 05:23
Status:needs review» postponed

I believe this functionality was added.

#23

smk-ka - March 18, 2008 - 20:00
Status:postponed» fixed

Indeed, this has been committed to HEAD. Closing.

#24

Anonymous (not verified) - April 1, 2008 - 20:01
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.