Closed (duplicate)
Project:
Node Class
Version:
7.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2012 at 13:38 UTC
Updated:
25 Feb 2015 at 14:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
kropka commentedsubscribe
Comment #2
drnikki commentedThis is an issue with the nid not existing in form_state on submit.
Patch attached.
Comment #3
drnikki commentedComment #4
faisaljaved commentedI had same issue. Use hook_node_insert and hook_node_presave. Here is the code which works for me
/*
* insert new record for a node in node_class table
*/
function node_class_node_insert($node){
db_insert('node_class')->fields(array('nid' => $node->nid, 'css_class' => $node->node_class['css_class']))->execute();
}
/*
* Update node class
*/
function node_class_node_presave($node){
db_update('node_class')
->fields(array(
'css_class' => $node->node_class['css_class']
))
->condition('nid',$node->nid)
->execute();
}
Note: Please remove form_submit function (line 67 to 88).
Comment #5
drnikki commentedI didn't want to completely rewrite the author's module, but you'll see the attached patch uses hook_node_insert. Once s/he commits these patches, I'd be happy to remove _submit.
Comment #6
kingfisher64 commentedI'm still getting the error in #1 after the patch on #2 is applied. The patch was successful but the error remains.
Edit: Once editing pre-existing content there is no error message, but upon creating new content it's output.
Comment #7
kingfisher64 commentedcan #4 not be implemented asap? It does say minimally maintained on the status. I'm sure some help to fix this would be appreciated rather than it being viewed as a takeover process.
This little mod will be very handy indeed once errors are fixed. :)
Comment #8
drnikki commentedNot sure how I missed this earlier, but sure enough - a clean checkout & patch from #2 and the error still appears. I'm attaching a patch with changes from #2 and the fix for the error.
Comment #9
kingfisher64 commentedGreat the error has gone, thanks drnikki.
Comment #10
drnikki commentedPatch applied & committed.
http://drupalcode.org/project/node_class.git/commit/88ceb91
Comment #11
Bernsch commentedHy!
The error is back in version 7.x-1.1: After install this module and i add a new content, i become this error message:
Notice: Undefined property: stdClass::$nid in node_class_attributes() (Zeile 31 von /var/www/mywebsite.com/sites/all/modules/node_class/node_class.module).I use Drupal 7.17 and the node class module 7.x-1.1
Comment #12
Anonymous (not verified) commentedThis is weird. If you pull the project with git, this was the last commit and was way before 7-x-1.1. So it is a little confusing as to where 7-x.1.1 came from.
Comment #13
Bernsch commentedI test the git version and 7-x.1.1 in a new local environment an both versions works as design...
I don't know what was the problem before...
Comment #14
Dret commentedI got the same problem!
Please find a solution... my Drupal version is 7.22
Comment #15
Anonymous (not verified) commentedDret - if you use the 7.x-1.x version from git, you will not have this problem. However, the git version doesn't have the changes to put the node class items in the vertical tabs like the 7.x-1.1.
Can someone with git access merge 7.x-1.1 back into git, and then possibly could we have a 7.x-1.2 release be based upon that merge?
Comment #16
shivani.shah commentedI find out a simple solution to this...
Goto: node_class.module :
// Add submit handler for node_class module
Remove: $form['#submit'][] = 'node_class_form_submit';
Add : $form['actions']['submit']['#submit'][] = 'node_class_form_submit';
Comment #17
Bernsch commented@shivani.shah or Maintainers
Can you writhe a patch pleace?
Then we can test it by the community (RTBC)
Comment #18
nomorerice commentedPatch for Node Class Module:
line 29:
function node_class_attributes($node) {
+ if(isset($node->nid))
+ {
$ret = db_query('SELECT css_class FROM {node_class} WHERE nid = :nid',
array(':nid' => $node->nid))->fetchField();
return $ret ? $ret : '';
+ }
+ else
+ {
+ return '';
+ }
}
Comment #19
creatile commentedThanks nomorerice with your patch in #18, The error message has disappeared
Comment #20
Bernsch commentedThe code in #18 works fine!
@Maintainers: Pleace create a patch an commited to dev. Thanks!
Comment #21
kingfisher64 commentedThanks for suggestion in #18. Can someone who knows how to commit this?
Comment #22
moonray commentedFind attached an actual patch.
Comment #23
sandip choudhury commentedI have also got error -
Notice: Undefined property: stdClass::$nid in node_class_attributes() (line 31 of D:\xampp\htdocs\ultracorporatepixel.com\sites\all\modules\node_class\node_class.module).
I delete the below lines from 29 to 33 in node_class.module file -
And add the below lines in that place from line 29
And this works. Thanks nomorerice.
Comment #24
Anonymous (not verified) commented#18 works for me. The patch in #22 did not work both via git and manually.
Comment #25
mhamed commentedhi
with the drupal 7.24 it still gives the same error
with the comment #23 done the error disappeared
thanks
Comment #26
Stanto commentedThat looks fixed with 7.x-1.3
Comment #27
joachim commentedYup, confirming that this is fixed in 1.3:
Fixed in commit:
commit 88ceb91fa9ce28198ebf6f932d2bdc9df5ac2678
Author: Nikki Stevens
Date: Thu May 3 10:29:44 2012 -0400
Issue #1558112 #4160056 by drnikki: node save & edit errors
In which case, this issue should be closed.