Truncate node teaser/body field to custom length

wilco - September 19, 2007 - 23:16
Project:Views
Version:5.x-1.x-dev
Component:node data
Category:feature request
Priority:normal
Assigned:sun
Status:needs review
Description

Have you ever come across a need, within your Views results, to trim the output of the node Title and Teaser/Body fields?

This patch enhances Views by offering the Administrator a way to overcome the theming limitations of working with already rendered content. Instead, via a simple Settings screen, you can set a few variables for trimming quality, length, style of MORE element. Then, when adding the Node Title of Node Body fields to the FIELDS form section of Views, you can select whether to output with the normal options or enhanced with the trimmed versions.

Excellent for tight places in your website design where the content needs to be short and sweet.

TODO:

  • Add functionality for Character trimming. (currently only supports word trimming)
  • Add in better validation of length value. (currently will accept negative values and won't change them in the form to a positive value, though in the backend, it converts the negative to an absolute value.)
  • Add the possibility of include whatever the user wishes for the MORE element

Hope this works for everyone as much as it has for me.

Happy Drupalling!

AttachmentSize
views_trim.patch14.93 KB

#1

Mercury500 - April 22, 2008 - 17:22
Version:5.x-1.6» 6.x-2.x-dev

Yes, I come across this need like every day. Really. I do.

Is this coming to vers 6.x? It would be really nice to just grab 15 words or so of the body field to add to my table listings...among other things.

So, yes on this feature request...for 6.x.

m

#2

merlinofchaos - April 22, 2008 - 17:48
Version:6.x-2.x-dev» 5.x-1.x-dev

The patch, however, doesn't apply to Views 2.

#3

wilco - April 24, 2008 - 19:54

I'll do some work on this in the next few days to add some features to the 1.6 version.

I'll then migrate it to version 2 once I get a good grasp on the new code and API.

After that, I'll get a D6 version of the patch ready.

#4

sun - May 27, 2008 - 22:37
Title:Views Node Title and Teaser/Body trimming» Trim node teaser/body field to custom size
Component:User interface» node data
Assigned to:Anonymous» sun

Reducing the scope of this issue. Attached patch adds an option field to define the number of characters a node's body will be trimmed to.

This patch is slightly dependent on #160641: Node: Body outputs entire full node body instead of Body field, since trimming a full node view instead of the body doesn't make much sense.

AttachmentSize
views-DRUPAL-5.node-body-trim.patch 1.28 KB

#5

pribeh - July 12, 2008 - 21:23

Hey,

Wonderful idea. I could use this so much if I could just figure out how to apply the patch. Do I use this as a .inc file or.... ? And how do I use it, where are these settings?

Thanks,

Thomas

#6

sun - July 12, 2008 - 21:24

#7

ramper - September 10, 2008 - 01:07

Has anyone found a way to trim long titles for displaying on a Views 2 block? If anyone has written a patch for D6, could you share?
Thanks in advance.

#8

sun - September 21, 2008 - 01:56
Title:Trim node teaser/body field to custom size» Truncate node teaser/body field to custom length

I need some confirmations that the latest patch does not break existing views.

#9

panji - October 23, 2008 - 06:22
Version:5.x-1.x-dev» 6.x-2.1

it's really great patch,... really need it much,.. put it to the main feature of views, it's would be great,... but how about the drupal 6 and views2? is it work?

please, need a little help here,..

regards,...

#10

merlinofchaos - October 23, 2008 - 06:26
Version:6.x-2.1» 5.x-1.x-dev

panji: This is a patch against a particular version of Views. Changing the version number is merely a disruption, and an annoyance. Please think before you hit that submit button.

#11

merlinofchaos - October 23, 2008 - 06:27

panji: the worst part is, somebody already did what you did and I changed it back. So really, the only explanation appears to be that you can't read.

#12

panji - October 23, 2008 - 21:41

Ops, sory, my bad,.. i'm kind of rush and hurry on reading this,..
I'm just avoiding to make a duplicate thread,... so I'll make new thread then, with the same subject and diferent version of view,..

ragards

#13

ardiwine - November 29, 2008 - 17:02

how do I install this patch ?

I currently have the Views module (ver: 5.x-1.x-dev) installed. But every time I installed the patch using the command patch < [patch_name], for some reason, the patch failed on several lines and I ended up have to install a fresh copy of the views module because I couldn't even load up my page.

Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.