(Background: #287812: Provide a "Content: Read more link" field, #1015632: Option to add links section to end of teaser fields e.g. "read more")
Suppose you want a list of teasers, each with a "read more" link to the full node. This "read more" link should only appear if there actually is more to read i.e. if the teaser is shorter than the body text. This is easy: choose row style nodes ("content"), view mode teaser, check display links and you're done.
Suppose, however, you need row style fields. Because e.g. you need to display specific fields, or because you need a teaser that is shorter than the default teaser length. Displaying a "read more" link only if there actually is more to read is not possible with just views. A work-around exists (see first issue referenced above), involving
- several extra non-displayed fields
- a contributed module to add PHP code
- a piece of CSS
This seems way to complicated. Especially since views already knows there is more to read: just check "Trim this field to a maximum length", and an option will appear to add an ellipsis if a field was trimmed.
Would it be possible to make this easier? By adding an optional "read more" link to the ellipsis option (see mockup)? Or a more generic solution, by replacing the ellipsis with a custom text/token input field?
Comment | File | Size | Author |
---|---|---|---|
#11 | 1218704.patch | 4.31 KB | dawehner |
#9 | 1218704.patch | 4.31 KB | dawehner |
#8 | 1218704.patch | 3.99 KB | dawehner |
#6 | 1218704.patch | 3.36 KB | dawehner |
Screenshot.png | 67.87 KB | gaele |
Comments
Comment #1
dqdyesss! ... and it should also solve the problem of making "readmore" translatable. Using Node:Link with custom text is a problem for i18n sites because t('readmore') does not work here
Comment #2
dawehnerThis seems to be the most generic implementation and conceptual looks fine for me.
Comment #3
mjcarter CreditAttribution: mjcarter commentedYes, this is a seriously missing feature
Edit: Thought I had an idea of a solution but sods law...
Comment #4
Summit CreditAttribution: Summit commentedHi, still very interested in a solution for this please?
greetings, Martijn
Comment #5
RachelIsland CreditAttribution: RachelIsland commentedI would loooove a solution too...
Comment #6
dawehnerHere is a small patch which allows to use tokens both for the more link text and the more link path
Comment #7
Hydra CreditAttribution: Hydra commentedNice work! This is a well needed feature. I think it should be possible to use the node: path field as a token, right now all I could get woring was the nid field as a usable token/path.
It would also be nice, if the read more link would reference automaticly to its content, if possible.
Comment #8
dawehnerTwo changes to the patch.
* Add a help description
* Take sure that relative links like /foo/bar works as well. Basically everything which is runned through url().
Comment #9
dawehnerNow the replacement patterns are shown above it.
Comment #10
Hydra CreditAttribution: Hydra commentedWorks for me! You should adjust the help message to "above" at the end when the eplacementpatterns are shown above and not below.
+ '#description' => t('The path which is used for the more link. You may enter data from this view as per the "Replacement patterns" above.'),
Comment #11
dawehnerJust a small update
Comment #12
Hydra CreditAttribution: Hydra commentedLooks fine :)
Comment #13
dawehnerThanks for all the testing.
Would be definitive a worth feature for 6.x-3.x as well.
Comment #14
traveller CreditAttribution: traveller commentedWhat is the replacement token for the node's link path? Such token is not listed in the options.
Without setting it, the 'read more'-URL is set to the root of the website.
Comment #15
ntg CreditAttribution: ntg commentedYou can add a "Node: Path" field, exclude it from display and then use the "[path]" as the path of the "More..." link.
Comment #16
chunty CreditAttribution: chunty commentedCould someone that knows how extend this patch allow it to accept HTML entities like » in the read more text. I'd do it myself but I'm not quite up to speed enough yet.
Much appreciated
Chris
Comment #17
traveller CreditAttribution: traveller commentedThere is no direct solution, but using 7.x-3.x Views I used ntg's #15 suggestion: add new field "node path", exclude it from display, then set [path] as the path for the "read more" body field.
Comment #18
chunty CreditAttribution: chunty commentedHaving played with this a little more without wanting to disrespect or dismiss the work that has gone into this for D6 (which I'm using) I've come the conclusion that actually the best solution is simply to use a custom markup field.....why? because:
Hope that helps someone but even so thanks to the folks that have put the time into building this and I'm sure it helped you.
C
Comment #19
vchen CreditAttribution: vchen commentedUsing views 7.x-3.3
Confirming that #15 solution works.
Problem: read more links using [title] pattern did not link to the any page. Using [path] pattern (after adding the Content:Path field, and then exclude from display) did the trick. Read more link now links to the content.
Comment #20
Hydra CreditAttribution: Hydra commentedOf Course #15 is working. You can use any token as path. If you are using a token wich not leads you to the destination you wish to, it's not working. It would be nice if it would automaticly reference to the content, but this is an other issue. Right now it's working perfectly well and it's ready to be ported.
Comment #21
shiroitatsu CreditAttribution: shiroitatsu commented#15 doesn't work if one happens to be working in a language that has special characters that [path] messes up for some reason and the path alias is broken. I use [nid] instead, linked to original content and rewritten to be "read more…" or what ever is needed. Quite complicated and not very intuitive for the purpose.
Comment #22
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue