nodeapi

Drupal 5: CCK fields in custom content type

I have module that implements custom content type via NodeAPI hooks (hook_insert, hook_update etc). I want to add CCK field to this content type and populate it via hook_nodeapi calls like create or update (to show content nodes in Views). Problem is, I cannot access CCK fields for this content type. Sure, it's enabled on "Manage Fields...

How can I load the title of parent item in Drupal

I want to extend Nodes with the title of the parentnode so I can display a hierarchy link. I have a solution that sometimes works: function modulename_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'view': loadParentTitle($node); break; } } function loadParentTitle(&$node) { ...

How do I update a node (book or Page) before saving it without touching the module code in Drupal?

I would like to set some values in the node before actually writing the data to the DB. I already have it working by modifying book_nodeapi but I would like to do it from outside the code, some _alter option that allows me to leave the module code untouched would be great. Thanks ...

Drupal - assign menu to block based on node type

I want to assign a specific menu in left sidebar block, based on the node type of the page currently being displayed. I think it should look something like this, but I am stuck. function my_module_nodeapi(&$node, $op) { switch ($op) { case 'view': if ($node->type == "large_reptiles") { //menu_set_active_menu_...

Drupal cck checkbox with global setting

Hi, I am creating a "sticky" checkbox for my content type "news". this means that one news node is sticky, and is used in a banner like box. This is marked by a checkbox int the cck create content form. The checkbox is handled by the node_api, so I check: if $op = 'update' and $node->type = 'news' then ... logic. I don't know why bu...

How do I set the value for a CCK Node-reference field automatically when create form submits

I have a content type (A) that references a single node of a different content type (B). The node referenced (B) can be programmatically determined using the information for the user creating this new node (A)... Each user can only create a single node of the referenced content type (B), so this single node will always be referenced from...