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.
The request comes from ticket #1198388: Checker only works on the core "body" field and on sites without localization. The goal is that besides the node body, content in cck fields would be checked as well.
Comment | File | Size | Author |
---|---|---|---|
#3 | seo_checker-check_all_long_text_fields-1215586-3.patch | 11.17 KB | spidersilk |
Comments
Comment #1
spidersilk CreditAttribution: spidersilk commentedI may be able to help with this. I'm working on a site now for a client who would like this module to check more fields than just the body, so if I have to figure out a way to make it work for them, hopefully I can find a way to apply the work I do for them for other people as well.
Tentatively thinking of having it look for all fields of the "Long text" (or Long text with summary) type and check all of them, since that would at least include any fields with a considerable amount of text, regardless of their names. But we'll see what I can get to work...
I'm also working on finding a way to have it check image fields as well as images in the body, so again, if I can get that to work I'll happily contribute my code.
Comment #2
spidersilk CreditAttribution: spidersilk commentedSo, I just got this working! To a limited extent, anyway...
My modified version looks through all the node's fields, checks to see if they're of the "long text" or "long text and summary" type, and if they are, it adds their content to the $body variable (even if the node doesn't actually have any fields called "body"), and then analyzes the whole thing.
It even looks for field collections (created with the Field Collection module), and when it finds one, goes through as many instances as it has, checking each one for long text fields. (I added this mainly because the client project I'm working on right now uses that.)
It no longer returns false if there's no body field - only if there are no long text fields at all.
It seems to work well, but it's not the most elegant solution - ideally it would be nice to be able to choose which fields to check within the SEO Compliance Checker settings for each content type, and maybe have the results for each one reported separately. But hey, at least it's checking more fields than just the body now!
I am determined, this weekend, to finally learn how to make patches with Git, and make one for this modification. Also, I'll be tackling the issue of alt text for image fields later this evening and tomorrow, and will hopefully have a patch for that too before the end of the weekend.
Comment #3
spidersilk CreditAttribution: spidersilk commentedOK, here's a (rather large) patch that addresses this issue and a few others. List of changes:
This patch definitely needs testing before it can be committed - I tested it on two sites, but there are many different configurations and module combinations it has not been tested with, so please feel free to try it out and provide feedback.
Also - this is only the second patch I've created, and I'm still getting used to Git, so hopefully I haven't made any major errors on that front. I guess we'll see...