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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nevergone’s picture

Status: Active » Needs work
FileSize
3.53 KB

Here is the patch.

Boobaa’s picture

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

nevergone’s picture

@Boobaa: All right, checkbox is deleted, and some performance tuning.

nevergone’s picture

Status: Needs work » Needs review

Self test, working.

dawehner’s picture

Status: Needs review » Needs work

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

+++ b/handlers/views_handler_field.incundefined
@@ -1148,7 +1162,17 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
+        if (!empty($this->options['alter']['more_link_class'])) {

You could check for !empty($more_link_class) as well, it makes the code a bit easier to understand.

stBorchert’s picture

Title: "Read more" link with CSS classes » "Read more" link with wrapper and CSS classes
Status: Needs work » Needs review
FileSize
3.27 KB

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

Status: Needs review » Needs work

The last submitted patch, views_read_more_wrapper-1529718-6.patch, failed testing.

nevergone’s picture

Status: Needs work » Needs review
FileSize
3.36 KB

Corrected patch.

Chris Matthews’s picture

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

Checking patch handlers/views_handler_field.inc...
Hunk #1 succeeded at 439 (offset 21 lines).
Hunk #2 succeeded at 942 (offset 30 lines).
Hunk #3 succeeded at 1244 (offset 33 lines).
Applied patch handlers/views_handler_field.inc cleanly.