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!
Comment | File | Size | Author |
---|---|---|---|
#4 | views-DRUPAL-5.node-body-trim.patch | 1.28 KB | sun |
views_trim.patch | 14.93 KB | wilco | |
Comments
Comment #1
Mercury500 CreditAttribution: Mercury500 commentedYes, 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
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThe patch, however, doesn't apply to Views 2.
Comment #3
wilco CreditAttribution: wilco commentedI'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.
Comment #4
sunReducing 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.
Comment #5
pribeh CreditAttribution: pribeh commentedHey,
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
Comment #6
sun@pribeh: See http://drupal.org/patch/apply
You also need to apply the patch in #160641: Node: Body outputs entire full node body instead of Body field
Comment #7
ramper CreditAttribution: ramper commentedHas 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.
Comment #8
sunI need some confirmations that the latest patch does not break existing views.
Comment #9
panji CreditAttribution: panji commentedit'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,...
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedpanji: 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.
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedpanji: 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.
Comment #12
panji CreditAttribution: panji commentedOps, 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
Comment #13
ardiwine CreditAttribution: ardiwine commentedhow 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.
Comment #14
esmerel CreditAttribution: esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.