Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
The Views field handler with read more link theming is difficult. I created a patch, that give custom CSS class for the „read more” link.
Comment | File | Size | Author |
---|---|---|---|
#8 | views_read_more_wrapper-1529718.patch | 3.36 KB | nevergone |
views_read_more_link_css.png | 42.23 KB | nevergone |
Comments
Comment #1
nevergone CreditAttribution: nevergone commentedHere is the patch.
Comment #2
BoobaaI think the checkbox is totally useless. It should be pretty straightforward that if one leaves the textfield empty, no additional classes would be added. Additionally, even the code would be more simplistic.
Comment #3
nevergone CreditAttribution: nevergone commented@Boobaa: All right, checkbox is deleted, and some performance tuning.
Comment #4
nevergone CreditAttribution: nevergone commentedSelf test, working.
Comment #5
dawehnerSo if you look at current code in views, the css classes are added after clicking a checkbox, not using one would make it more consistent.
The current code, though does not change the checkbox at runtime, but clears the values out, if the checkbox is not set.
This is done in views_handler_field::options_submit, so you could do this as well. At the end this allows to have an easy code when generating the more_link, and get a total consistent result.
You could check for !empty($more_link_class) as well, it makes the code a bit easier to understand.
Comment #6
stBorchertFor a customer we needed to wrap the read more link into a HTML element so I modified the patch.
After applying the patch you can select a wrapper element for the link and add CSS classes to the wrapper.
Comment #8
nevergone CreditAttribution: nevergone commentedCorrected patch.
Comment #9
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch in #8 to views_handler_field.inc applied cleanly to the latest views 7.x-3.x-dev, but still needs review.