Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Hey dp,
Though I have no personal experience with the CCK (Content Creation Kit) module, I've heard a lot of good comments about, it might be worth your time. CCK is newer and more robust than Flexinode i hear.
you'd need to create a new table have nid as the key, install file for it, and add a hook for hook_nodeapi to handle the operations, i.e. update load delete insert, something like
function mymodule_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'delete revision':
db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);
break;
case 'delete':
db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);
break;
case 'insert':
db_query("INSERT INTO {mytable} (nid, myfield1, myfield2) VALUES (%d, '%s', '%s')", $node->nid, $node->myfield1, $node->myfield2);
break;
case 'update':
db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);
db_query("INSERT INTO {mytable} (nid, myfield1, myfield2) VALUES (%d, '%s', '%s')", $node->nid, $node->myfield1, $node->myfield2
break;
case 'load':
$object = db_fetch_object(db_query('SELECT myfield1, myfield1 FROM {mytable} WHERE nid = %d', $node->nid));
return array (
'myfield1' => $object->myfield1,
'myfield1' => $object->myfield1);
break;
case 'validate':
case 'submit':
break;
}
}
Hi bazzaboy,
That is exactly what I want ! In Drupal comment is a special content type unlike others. I want to add custom fields where users can give their rating on that node and post their comments too. It is just like tripadvisor.com where users can rate accommodations and post their comments. I love to hear more advice on this topic.
Thank you,
dp.
another useful tip is to temporarily add a drupal_set_message to output the parameters coming into your nodeapi hook, that way you can find out what type of page is being displayed, I did this to quickly work out what case I needed to action upon for the comment form.
also I noticed my example code has a small typo in the last case statement, I reference myfield1 twice.
Comments
To Add Content-Type
I'm not sure about your question, but the part I do understand, add content-type:
Install flexinode module : http://drupal.org/project/flexinode
Go to administer -> content
Click on "add content type" tab
Probably not what you're asking, but just in case.
-ron
Try the CCK module
Hey dp,
Though I have no personal experience with the CCK (Content Creation Kit) module, I've heard a lot of good comments about, it might be worth your time. CCK is newer and more robust than Flexinode i hear.
You might also wanna check these links out:
Lullabot podcast on CCK among other things
http://lullabot.com/podcast/drupal_podcast_no_13
The CCK project page
http://drupal.org/project/cck
-Janne C.
create a module, new table and hook into comment form
I am assuiming you are using 4.7. I'd create a new module
use hook_form_alter to add form fields to the comment page, something like this
you'd need to create a new table have nid as the key, install file for it, and add a hook for hook_nodeapi to handle the operations, i.e. update load delete insert, something like
hope this helps
Thank you!
Hi bazzaboy,
That is exactly what I want ! In Drupal comment is a special content type unlike others. I want to add custom fields where users can give their rating on that node and post their comments too. It is just like tripadvisor.com where users can rate accommodations and post their comments. I love to hear more advice on this topic.
Thank you,
dp.
you are welcome
dp,
another useful tip is to temporarily add a drupal_set_message to output the parameters coming into your nodeapi hook, that way you can find out what type of page is being displayed, I did this to quickly work out what case I needed to action upon for the comment form.
also I noticed my example code has a small typo in the last case statement, I reference myfield1 twice.
Barry
I read your question poorly
Hey dp,
I read your question too quickly and missed the whole point that you were looking to work with comments, not nodes.
-Janne