Dru Documentation

Go to front page

developer/hooks/core.php, string 1358 Versions 5 - 6 hook_nodeapi (&$node, $op, $a3 = NULL, $a4 = NULL) "Translation" the Pre-image Fulfils operations over нодами. In spite of the fact that the name can confuse, hook_nodeapi () is not reserved only for units which define the types нодов. On the contrary, he allows units to react to the operations influencing all sorts нод, is not dependent on, whether has defined appropriate ноду unit. Basically hook_nodeapi () it is used together with hook_form_alter (). Units use hook_form_alter () for addition of forms of editing with new units and hook_nodeapi () for reading and an entry of values of these units from and in a database. Do not use given хук for performance of operations only with type ноды, created by your unit. Instead use хуки intended for units creating new type ноды, such as hook_insert () and hook_form (). But for some operations, such as ' delete revision ' or ' rss item ', is not present corresponding хука, therefore even if the unit defines type ноды, it is necessary to use hook_nodeapi (). Parametres &$node Noda over whom operation will be made. $op Type of executable operation. Possible values: * ' alter ': the array $node-> content отрендерен so a skew field ноды or тизер there have taken place filters and now contain HTML. This operation should be used only when text substitution, filtering or other operations with raw (raw) the text are necessary. * ' delete ': Нода is deleted. * ' delete revision ': edition ноды Is deleted. You can delete the data linked to edition. * ' insert ': Нода forms (it is added in a database). * ' load ': Нода it is ready to loading from a database. This хук can be used for adding of the additional data at this time. * ' prepare ': Нода it is ready to mapping in the form of adding/editing. * ' prepare translation ': There is a clone ноды for translation. You can load the additional data, or copy values $node-> translation_source. * ' print ': the image ноды for the press Is prepared. It is used for deriving of adaptive representation for the printer ноды in book_module. * ' rss item ': fillet RSS Is created. The unit can get access to properties, определнным for unit RSS of a fillet given ноды. Look comment_nodeapi () and upload_nodeapi () for an example. For adding or removal of contents of units RSS of a fillet it is possible to take advantage also of variable modification $node. * ' search result ': Нода it is mapped as outcome of search. If you wish to output the additional information with outcomes, take advantage of this returned value. * ' presave ': Нода has passed check and it will be soon saved. Units can use this хук to make modifications in ноду before it will be saved in a database. * ' update ': Existing нода it is refreshed. * ' update index ': The node is being indexed. If you want additional information to be indexed which is not already visible through nodeapi ' view ', then you should return it here. * ' validate ': The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check the node data. Errors should be set with form_set_error (). * ' view ': There was a contents assemblage ноды before rendering. The unit can add units $node-> content before rendering. This хук will be called after hook_view (). A format $node-> content same, as in API forms. $a3 * For ' view ', the parametre $teaser from node_view () is transmitted. * For ' validate ', the parametre $form from node_validate () is transmitted. $a4 * For ' view ', the parametre $page from node_view () is transmitted. Returned value Value depends on operation. * Operations ' presave ', ' insert ', ' update ', ' delete ', ' print ' and ' view ' do not return value. * Operation ' load ' should return the array containing steams of = field> of value which, owing to, will be united in ноды object. Act on nodes defined by other modules. Despite what its name might make you think, hook_nodeapi () is not reserved for node modules. On the contrary, it allows modules to react to actions affecting all kinds of nodes, regardless of whether that module defined the node. It is common to find hook_nodeapi () used in conjunction with hook_form_alter (). Modules use hook_form_alter () to place additional form elements onto the node edit form, and hook_nodeapi () is used to read and write those values to and from the database. If you are writing a node module, do not use this hook to perform actions on your type of node alone. Instead, use the hooks set aside for node modules, such as hook_insert () and hook_form (). That said, for some operations, such as "delete revision" or "rss item" there is no corresponding hook so even the module defining the node will need to implement hook_nodeapi (). Parameters &$node The node the action is being performed on. $op What kind of action is being performed. Possible values: * "alter": the $node-> content array has been rendered, so the node body or teaser is filtered and now contains HTML. This op should only be used when text substitution, filtering, or other raw text operations are necessary. * "delete": The node is being deleted. * "delete revision": The revision of the node is deleted. You can delete data associated with that revision. * "insert": The node is being created (inserted in the database). * "load": The node is about to be loaded from the database. This hook can be used to load additional data at this time. * "prepare": The node is about to be shown on the add/edit form. * "prepare translation": The node is being cloned for translation. Load additional data or copy values from $node-> translation_source. * "print": Prepare a node view for printing. Used for printer-friendly view in book_module * "rss item": An RSS feed is generated. The module can return properties to be added to the RSS item generated for this node. See comment_nodeapi () and upload_nodeapi () for examples. The $node passed can also be modified to add or remove contents to the feed item. * "search result": The node is displayed as a search result. If you want to display extra information with the result, return it. * "presave": The node passed validation and is about to be saved. Modules may use this to make changes to the node before it is saved to the database. * "update": The node is being updated. * "update index": The node is being indexed. If you want additional information to be indexed which is not already visible through nodeapi "view", then you should return it here. * "validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check the node data. Errors should be set with form_set_error (). * "view": The node content is being assembled before rendering. The module may add elements $node-> content prior to rendering. This hook will be called after hook_view (). The format of $node-> content is the same as used by Forms API. $a3 * For "view", passes in the $teaser parametre from node_view (). * For "validate", passes in the $form parametre from node_validate (). $a4 * For "view", passes in the $page parametre from node_view (). Return value This varies depending on the operation. * The "presave", "insert", "update", "delete", "print" and "view" operations have no return value. * The "load" operation should return an array containing pairs of fields => values to be merged into the node object. The linked subjects Хуки Allows units to co-operate with kernel Drupal. ? 1 function calls hook_nodeapi ()