This modules allows addition of values of taxonomy type fields of an entity as classes in the body element, on the entity's page. It adds the settings per field instance, hence you can enable body classes for individual fields per entity type and not for a field in all entity types.

Sandbox project page: https://www.drupal.org/sandbox/sghosh/2409019
Git repository, branch 7.x-1.x:
git clone --branch 7.x-1.x https://git.drupal.org/sandbox/SGhosh/2409019.git term_body_class

Manual reviews of other projects
https://drupal.org/node/2204535#comment-8835565
https://www.drupal.org/node/2159747#comment-9113285
https://www.drupal.org/node/2709047#comment-11142783

Comments

SGhosh created an issue. See original summary.

PA robot’s picture

Issue summary: View changes

Fixed the git clone URL in the issue summary for non-maintainer users.

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

shuva.15’s picture

Status: Needs review » Needs work
StatusFileSize
new132.63 KB

A notice while checking the term body class occurs. Otherwise the module works perfectly.

SGhosh’s picture

Thank you for testing out the module :)

I have corrected the issue, could you please try replicating the issue and confirm its fixed now?

NOTE: I have changed the module name so it would be better if you did a fresh install.

SGhosh’s picture

Status: Needs work » Needs review
SGhosh’s picture

Issue summary: View changes
SGhosh’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
SGhosh’s picture

Issue summary: View changes
th_tushar’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: single application approval

Automated Review

[Best practice issues identified by pareview.sh / drupalcs / coder. Please don't copy/paste all of the results unless they are short. If there are a lot, then post a link to the automated review and mention that problems should be addressed.]

Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
No: Does not follow the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
  1. * Below hook functions doesn't have the module's machine name.
    function taxonomy_field_body_class_form_alter(&$form, &$form_state, $form_id) {
    function taxonomy_field_body_class_preprocess_html(&$variables) {

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

Code too short
This project is too short to approve you as git vetted user. We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed. However, we can promote this single project manually to a full project for you.
SGhosh’s picture

Thanks for testing the module @th_tushar. Really appreciate it!

I have fixed the issue that you pointed. I had actually changed the module name recently and had missed updating the function names. Fixed now.

Coding style & Drupal API usage
* Below hook functions doesn't have the module's machine name.
function taxonomy_field_body_class_form_alter(&$form, &$form_state, $form_id) {
function taxonomy_field_body_class_preprocess_html(&$variables) {

I have also made an addition to the module by enabling the term body class for user pages as well. It would be really great if you could test it out once more.

About Code too short

This project is too short to approve you as git vetted user. We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed. However, we can promote this single project manually to a full project for you.

This module is not a very complex module(yet) though in future if we find some limitations in it as per some use cases then I'll be extending the module. But for now, it's fairly simple and generally an add-on module for themers.
So consider this: for somebody -

  • * who isn't a developer
  • * but is doing some theming
  • * wants some css in all content pages which are tagged with term X

This module could come handy is such a scenario. Ofcourse, the code they will need to write to do this isn't complex, but for a non-dev any code is difficult to feel confident about. So writing their own code vs. something easily pluggable AND RTBC is definitely something they will feel more secure about.
And hence the module. I hope I am able to justify why this module has a place on DO :)

And thanks a lot again :)

SGhosh’s picture

Status: Needs work » Needs review
evucan’s picture

Automated Review

Passed

Manual Review

Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
[Yes: Follows] the guidelines for master branch.
Licensing
[Yes: Follows] the licensing requirements.
README.txt/README.md
[Yes: Follows] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[No: Does not Follow] the guidelines for project length and complexity.
Secure code
[Yes: Meets the security requirements. / No: List of security issues identified.]
Coding style & Drupal API usage
[List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance. Replace the text below by the issues themselves:
  1. Possibly consider making the module bigger by providing more class related options, like defining your own body classes per content.
  2. Works good on user pages too.
  3. Consider writing readme docs as per https://www.drupal.org/node/2190239.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

This review uses the Project Application Review Template.

SGhosh’s picture

Thanks for the review @evucan. Appreciate! :)

Could you give me more details on the below -

1.Possibly consider making the module bigger by providing more class related options, like defining your own body classes per content.

2. Consider writing readme docs as per https://www.drupal.org/node/2190239.

Currently, I don't have plans of adding anything else to the module but I am open to suggestions. I don't think it would be a good ides to extend it just for the sake of going for 150 lines of code as per guidelines. If there is anything additional the community feels that should be there​ before going live I would love to work on it.

evucan’s picture

I recently came across a case where I needed to add additionaly body classes on a node basis - also possible to do using context module tho. Thinking about it, making this module for just taxonomy is probably a nice way to package it.

Re the documentation, I actually meant that for this project page (not documentation), simply follow the guidelines, they display nicely and all the usual useful headings are there.

SGhosh’s picture

Hi @evucan. Thanks for that. I have updated my project page with the relevant headers from the project page template.
The updates page here - https://www.drupal.org/sandbox/sghosh/2409019.

califken’s picture

Status: Needs review » Needs work

Was able to checkout via the clone command on the project page.

califken’s picture

Status: Needs work » Needs review
califken’s picture

Status: Needs review » Needs work
StatusFileSize
new98.64 KB
new102.39 KB

First, let me say great module. Well done. It worked exactly as intended. However, I did find an issue, as documented below in the review template.

Automated Review

$ phpcs --standard=Drupal *

    FILE: ...\htdocs\sites\all\modules\term_body_class\term_body_class.module
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n" but
    |       |     found "\r\n"
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    Time: 410ms; Memory: 4.25Mb

Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
No: Does not follow the README Template.
Code long/complex enough for review
No: Does not follow the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage


  1. * CSS Class Name collisions

    * If a user tags content with a term that already exists as a system, module or theme's CSS class name, then the page will receive that class's styling. Only in instances where the CSS class declaration exists on it's own with no preceding elements, classes or IDs preceding it (unless that element is body), and no elements or IDs directly chained to it as part of the declaration (.thisclass, but not div.thatclass) (again, unless it is body.thaaaatclass).

    As a result, for example,

    I tagged a node with "overlay", hence the body got the class "overlay". In Bartik's style.css line 1576, there is a declaration ".overlay #header" to display: none;. Hence, for having tagged the node with overlay, I've lost the administration menu.

    There are a few ways I can think of to remedy this. You might consider prefixing any classes added by Term Body Class with a unique identifier, such as tbc-termnamehere, so as to avoid these collisions.

    You might implement a blacklist, and either provide a warning to users that their term name collides with a system CSS class, perhaps only prefix that specific term, allow overriding of that displayed term name with a custom term alias for the body class string that will be inserted (for example: mytermthatcollides {bodyclassversionofmyterm}.

    I would probably recommend the simple prefixing, though the other methods would be more likely to push your number of lines of code past 120! :)

  2. Line 51 of the module: machinen is misspelled.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

SGhosh’s picture

Status: Needs work » Needs review

@califken thanks so much for the prefix tip, totally agree with it. I have updated the module with the same - tbc-[term name].

I have fixed the spelling mistake as well.

However, I am using sublime text and could not replicate the below issue -

End of line character is invalid; expected "\n" but found "\r\n"

Any hints on how to resolve this?

Thanks again :)

remkor’s picture

In Sublime Text change line endings from Windows to Unix.

th_tushar’s picture

Hi remkor,

This is not a blocker though. Apart from this, are there any issues or it can be RTBC?

SGhosh’s picture

Hey @remkor, I did check in my sublime and the line ending is selected for UNIX so couldn't replicate the issue. I looked up a few places online as well to check whether i can replace it but found nothing successfully.

But probably that's not a blocker for RTBC @th_tushar, @remkor?

remkor’s picture

If you are using Windows the try this:
git config --global core.autocrlf false
This is not a blocker.

ashwinsh’s picture

Automated Review

Pareview.sh has found One Git errors.
http://pareview.sh/pareview/httpsgitdrupalorgsandboxsghosh2409019git

Git errors: Git default branch is not set, see the documentation on setting a default branch.

Thanks,

bapi_22’s picture

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: follows
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
  1. (*) term_body_class_preprocess_html() uses only 2 entity node & user. Try to make it generic. For example if any entity having a field like term_reference, It should add the body class on that entity view page.
  2. (+) Use hook_form_form_id_alter() instead of using hook_form_alter().
  3. (+) Try drupal provided function for generating class instead of using your own.(Line no: 78/79).
    Use direct function drupal_html_class('tbc-'. $machine_readable))

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

bapi_22’s picture

Status: Needs review » Needs work

Changed Status.

asiby’s picture

Thanks for your review Bapi

The README guideline is not respected. No template was used. And it one was used, it would have allowed @SGhosh to clearly outline the module's limitations. In this case, the limitation/know issues would have been that the current version of the module only supports node and user entities.

@SGhosh, if you adjust your README file, that may solve the issue 1. pointed out by Bapi.

For 2. and 3., they need to be fixed IMHO.

bapi_22’s picture

Hi SGhosh,
Good point by Asiby. Please mention it on README file that it supports only 2 entities(node & user).
In the next version you can try to implement it.

SGhosh’s picture

remkor
If you are using Windows the try this:
git config --global core.autocrlf false
This is not a blocker.

Thanks @remkor, but I am on Mac and on my sublime text 2 line endings are set to Unix. Yet I cannot figure out how to fix this. Will continue to figure out a solution but I guess it's not a blocker for go live :)

SGhosh’s picture

ashwin.shaharkar
Automated Review

Pareview.sh has found One Git errors.
http://pareview.sh/pareview/httpsgitdrupalorgsandboxsghosh2409019git

Git errors: Git default branch is not set, see the documentation on setting a default branch.

Thanks,

Thanks for the review @ashwin.shaharkar. I have set the default branch now.

SGhosh’s picture

Thanks a lot for the review @bapi_22. I have added my replies inline -

Coding style & Drupal API usage
(*) term_body_class_preprocess_html() uses only 2 entity node & user. Try to make it generic. For example if any entity having a field like term_reference, It should add the body class on that entity view page.

Currently, this module only supports node and user and I have updated the same in the README file. Most reviewers have given a go ahead so I would like to go ahead with my initial plan extend the functionality in future after release.

(+) Use hook_form_form_id_alter() instead of using hook_form_alter().

I have updated the code with this.

(+) Try drupal provided function for generating class instead of using your own.(Line no: 78/79).
Use direct function drupal_html_class('tbc-'. $machine_readable))

Thanks a lot for this tip. I have removed preg_replace and used this function directly after converting the title to lowercase.

Again thanks a lot for the review. Look ahead for your replies again. :)

SGhosh’s picture

Thank you so much for the review @asiby.

As per your suggestion I have updated the README file as per the suggested template and also mentioned it's current limitations. I will be planning the extension in the next release :)

#2 and #3 have been fixed.

SGhosh’s picture

Status: Needs work » Needs review
gaurav.goyal’s picture

Status: Needs review » Reviewed & tested by the community

Hey SGhosh,

Thanks for your efforts. I think its a very handy module.

  • Module works as expected.
  • Code looks clean.

Looks like RTBC to me.

arun ak’s picture

Hi,

I reviewed this module and looks like a short module but giving a good feature, more helpful for theming. Code looks clean and fixed all the issues mentioned in previous comments. Couldn't see more application blockers.

@SGhosh, meanwhile as per review bonus program you can review three more other application from the queue to prioritize your own application.

Thanks,
ARUN AK

SGhosh’s picture

Thank you so much Arun for reviewing my module and the suggestions.

Will review a few more to roll my application to the top again :)

arun ak’s picture

Status: Reviewed & tested by the community » Fixed

No objections for more than a month, so ...

I have promoted the project for you. Now you can create the release of the project.

Thanks for your contribution, SGhosh!

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

SGhosh’s picture

Thank you Arun. It's great to see my module finally live :)