Currently, there is a way to trim text by enabling "Trim this field to a maximum length" in the field options when adding a field and then to add an ellepsis "..." after the text. I'm requesting to have a feature to use add a read more link instead of an ellipsis. You can integrate with ed_readmore.module or have your own thing.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | views-field-trim-dependent-suffix.patch | 3.17 KB | brynbellomy |
| #9 | views-566128-9.patch | 952 bytes | tim.plunkett |
Comments
Comment #1
dawehnerYou could create a read more link via the ui, with rewrite output and display as link.
Then you can display the created field inline. Thats all you need.
Comment #3
jeffschulerdereine, one could also create an ellipsis ("...") via a field in the Views UI, however, it was thought practical to include it as part of the trimming functionality.
I agree with radj that customizing this post-trim-text ( "read more", "...", etc.,) -- and the option to link that text to the original post -- would make the trimming a lot more functional.
A couple downsides I see to dereine's proposed solution are:
Comment #4
buckley commentedyup, specifying a "read more" link after the ellipsis is the way to go. I need this and have had the same remark a couple of times on irc.
As jeffschuler points out this woul print "read more" only when the text is actually trimmed.
dereine solution is the one I am using now but it also suffers from the fact that you cannot place it after the "..." because there is a closing
tag after it.
Comment #5
buckley commentedWarning !! I hacked the core
If you are sensitive don't read more. Every time someone hacks the core a pussycat gets killed :(
If you edit the file
views_handler_field.inc
and search for the following line :
if (!empty($this->options['alter']['ellipsis'])) {
You can replace it with
if (!empty($this->options['alter']['ellipsis'])) {
//hack :(
$value .= '... ' ;
}
That's it ... the readmoreplaceholder won't be displayed if not used but you can replace it in your template file with the real link that you get from a views field (link not node).
Some day when I know drupal better and this gigantic views module I will come back and write a patch...
Comment #6
esmerel commentedComment #7
rwt commentedHello,
This is a basic solution I've come up with that does not require any code. I've you need something more advanced, you may always install the "Views Custom Field" module.
Using CCK, I created a new text field to my content_type : "field_summary".
In Views, I include Node >Path, my custom field Content > Summary and the body Node > Body
I exluded Path from display… obviously.
I you wish, you may trim your custom field's maximum length, just remember to remove the ellipsis.
Then for the body node, I rewrote my output as such:
…corresponds to the ellipsis html unicode.And checked "Hide if empty".
Voilà !
The advantage of that solution is that it's quickly done (if you haven't already filled in your content) and it gives two fields for the "writer" to use which is more straightforward.
With views_custom_fields you could check for the lenght, and then trim the text and add the Read more link to the '[path]' node.
Comment #8
AdrianB commentedI'm with jeffschuler on this one.
I think dereine is missing what's important here: To only display the "Read more" link when there's more to read. I don't see how the proposed solution by dereine takes care of that. And dereine's logic there should be an ellipsis option either, but there is.
Views Custom Field is overkill in this case since it's almost there already, the logic of when the ellipsis is shown should be reusable.
Comment #9
tim.plunkettIn D6, node.module checks before printing the "Read more" links. (
$node->readmore = $node->teaser != $node->body;).I think what is being suggested is similar. A way to only print the "Read more" links when the trimmed result is shorter than the untrimmed data.
This doesn't work at all, but its a push in the right direction.
Comment #10
dawehnerAdditional this will break any instance of ellipsis
Comment #11
LEternity commentedsubscribe
Comment #12
jasher commentedI'd also like to see a more straightforward, "post-trim text" option. Perhaps with something like "link this text to this field's node".
I struggle to think of cases where one would want post-trim text that said something *other* than an equivalent of "Read more" ("read the rest of this article", "Cont.", etc.). But it would probably be nice if the option was there from the start.
(Similarly, I can't think of a case where one wouldn't want "read more" to be a link to the whole node, but giving the option for other links could overcomplicate things.)
Comment #13
njathan commentedCan this be done using PHP code in the Views Customfield module rather than hacking the Views module itself?
Comment #14
summit commentedSubscribing, needing a link to the complete node using ellipsis ("...").
Because when I use the field Node: Link as ..read more.., the link is always shown, also when the node-body is too small for it.
Thanks for going into this!
greetings, Martijn
Comment #15
brynbellomy commentedThis should do the trick. This gives a textbox (which accepts replacement tokens), the contents of which is only appended to the field if the trimmed text does not match the original text.
Comment #16
brynbellomy commentedChanging title due to expanded scope of this feature.
Comment #17
jthomasbailey commentedWorks great, exactly what I needed. Just too bad the closing
makes it appear on another line.
Comment #18
merlinofchaos commentedHmm. Why is this separate from the ellipsis? Couldn't we retool the ellipsis checkbox to turn this on, and then have the ellipsis be the default text to add?
Comment #19
leoduquette commentedIf I'm reading this properly, I think this is what was needed as the original response.
Under "VIEWS>>Fields>>Node: Link (Provide a simple link to the node.)
You can add whatever text you want there and it will link to it's node.
And of course Turn ellipsis off
Comment #20
rv0 commentedsubscribe
Comment #21
rv0 commentedI solved this now partially with the solution in #7
but instead of using views custom field, i just loaded the field i needed twice:
first instance: trim to length, exclude from display
second instance: rewrite output as [firstinstance_name] Read more
that way no theming change was needed as I'm still using the original field.
Comment #22
LiloLilo commentedI can't figure out how to add a Read more link to trimmed text. Can anybody explain me again? Thanks
Comment #23
mustanggb commented