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!

CommentFileSizeAuthor
#4 views-DRUPAL-5.node-body-trim.patch1.28 KBsun
views_trim.patch14.93 KBwilco
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mercury500’s picture

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

merlinofchaos’s picture

Version: 6.x-2.x-dev » 5.x-1.x-dev

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

wilco’s picture

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.

sun’s picture

Title: Views Node Title and Teaser/Body trimming » Trim node teaser/body field to custom size
Component: User interface » node data
Assigned: Unassigned » sun
FileSize
1.28 KB

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.

pribeh’s picture

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

sun’s picture

ramper’s picture

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.

sun’s picture

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.

panji’s picture

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,...

merlinofchaos’s picture

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.

merlinofchaos’s picture

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.

panji’s picture

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

ardiwine’s picture

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.

esmerel’s picture

Status: Needs review » Closed (won't fix)

At this time, only security fixes will be made to the 5.x version of Views.