I really like this module, but found some limitations, so I thought I could make it better.
So here's a big patch fixing/improving lots of things. I also attached the whole module updated.
Let me know if you'd like me to split this patch into several smaller ones.

- Node Class location: I created a page for settings to set if the class is supposed to be displayed in the body tag, in the node, or both.
- Node Class widget: By default Node Class shows a textfield, but there is the option to have a dropdown (to select one value), or an autocomplete field (to select multiple values).
- Source of autocomplete / dropdown: Here we have two options: "database" means it'll find all values already pre-entered, and "predefined set of values". In that case a textarea will appear where it's possible to enter a list of classes.
- Code cleanup: fixing white spaces and comments to follow Drupal best practices (thanks to Coder). I also removed the Readme file since it was only describing D6 behavior.
- A specific permission also exists to administer the settings.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JurriaanRoelofs’s picture

Status: Active » Needs review

+1, nice patch --I also reviewed your block_class patch. This needs to be reviewed by 2 people before it can get committed, if someone is interested in using this improvement please review here.
Works as advertised for me.

by the way it needs to patch against 7.x-1.3, it won't patch against latest dev because the 7.x-1.x branch does not contain the commits from recent tags.

sumanthkumarc’s picture

I have tested it with dreditor simplytest.me link. Tried both body and node separately. Working fine in both cases. Tried predefined set of values. Working fine. Attaching screenshots.

dineshw’s picture

Hello @JurriaanRoelofs and @Stanto
I tried to apply patch over git but it was not successful,

$ git apply -v node_class-big_feature_update_code_cleanup.patch
Checking patch README.txt...
error: while searching for:
  ------------------------------------------------------------------------------
-----------
                                    ABOUT THE MODULE
  ------------------------------------------------------------------------------
-----------
  This is a simple module that adds custom classes per node



  ------------------------------------------------------------------------------
-----------
                                    HOW TO USE NODE CLASS - Drupal 6 Only
  ------------------------------------------------------------------------------
-----------
  Open your node.tpl.php in your theme and add the following :
  <?php print node_class($node) ?>

  So your whole tag will look like :
  <div id="node-<?php print $node->nid; ?>" class="<?php print node_class($node)
 ?>
  node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' no
de-unpublished'; } ?>">
error: patch failed: README.txt:1
error: README.txt: patch does not apply
Checking patch node_class.info...
Checking patch node_class.install...
Checking patch node_class.js...
Checking patch node_class.module...
error: while searching for:
 * Extends the node's classes with any user defined classes.
 */
function node_class_preprocess_node(&$vars) {
  $node = $vars['node'];
  $classes = node_class($node);
  $vars['classes_array'] = array_merge($vars['classes_array'],
    explode(' ', $classes));
}

/**

error: patch failed: node_class.module:9
error: node_class.module: patch does not apply

I feel you can try creating patch again.
For reference, I have created patch from files you have given in node_class.zip which is working perfectly fine as tested by @sumanthkumarc.

@sumanthkumarc can you re test the patch I provided using?

sumanthkumarc’s picture

I tested the patch provided by @dineshw and its applying good on branch 7.x-1.x. It's working as expected.

dineshw’s picture

Added More Cleaner version of patch based on current 7.x-1.x Branch,
Contains Fixes for

  • Coder Review
  • Better formatting
  • Clean DB Query.

Working Fine! Needs Review!

nidhi.badani’s picture

Assigned: Unassigned » nidhi.badani
madzakaria’s picture

Hello guys, may i know how to apply the patch ?

dineshw’s picture