User Tools

Site Tools


dr:api_sequences

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
dr:api_sequences [2005/10/16 19:05] – (old revision restored) 127.0.0.1dr:api_sequences [2008/04/29 15:08] fgm
Line 1: Line 1:
-====== API Sequences: 6 steps to creating a node ======+====== API Sequences: node life cycle=====
  
 (in Drupal 4.6.x) (in Drupal 4.6.x)
  
 +... during the building of the various pages creating and editing a custom node..., as noted on a 4.6.3 installation during the development of the [[http://drupal.org/node/30947|helpdesk module]]
  
  
 +===== Table of hook calls seen by a module =====
  
 +<html>
  
 +<style type="text/css">
 +  body { font-size:small }
 +  th, td { vertical-align: top }
 +  th[scope="row"] { font-weight: normal; font-family:"Courier New", Courier, mono ; text-align: left}
 +  td { vertical-align:top; text-align:center }
 +  </style>
 +<table cellspacing="0" cellpadding="0" border="1">
 +  <tr>
 +    <th><span class="search_hit">Sequence</span> of <span class="search_hit">hooks</span> fired</th>
 +    <th>1: New</th>
 +    <th width="119">2: Preview</th>
 +    <th>3: Submit<br> 
 +    invalid new</th>
 +    <th>4: Submit <br>
 +    valid new</th>
 +    <th>5: Redirect <br>
 +    after create</th>
 +    <th>6: View node</th>
 +    <th>7: Edit node</th>
 +    <th>8: Track node </th>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_menu</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_access</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>1 per node type</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_node_types</th>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_user('load')</th>
 +    <td>no uid<br>
 +      name</td>
 +    <td>no uid<br>
 +      name</td>
 +    <td>no uid<br>
 +name</td>
 +    <td>no uid<br>name</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_load</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi ('load')</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_menu</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_user('load')</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>no uid<br>
 +      name of node owner</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_validate</th>
 +    <td>builtin fields</td>
 +    <td>builtin fields<br>
 +      module fields<br>
 +      no object</td>
 +    <td>builtin fields<br>
 +      module fields<br>
 +      no object</td>
 +    <td>builtin fields<br>
 +      module fields<br>
 +      no object</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>builtin fields<br>
 +        <br>
 +      loaded object</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('validate'</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('fields')</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_insert</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>builtin fields<br>
 +      module fields<br>
 +      no object<br>
 +      valid nid </td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('insert')</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid </td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_user('load')</th>
 +    <td>&nbsp;</td>
 +    <td>    no uid <br>
 +      name</td>
 +    <td>no uid <br>
 +name</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_view</th>
 +    <td>&nbsp;</td>
 +    <td>builtin fields<br>
 +      module fields<br>
 +      no object</td>
 +    <td>builtin fields<br>
 +        <br>
 +      loaded object</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('view')</th>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid </td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('form pre')</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_form</th>
 +    <td>builtin fields</td>
 +    <td>builtin fields<br>
 +module fields<br>
 +no object</td>
 +    <td>builtin fields<br>
 +  module fields<br>
 +  no object</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>builtin fields<br>
 +      <br>
 +      loaded object</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('form post')</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('form admin')</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_nodeapi('form param')</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>valid nid</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_node_name</th>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>valid nid </td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +    <td>&nbsp;</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_node_types</th>
 +    <td>X</td>
 +    <td>&nbsp;</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +    <td>X</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_block</th>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +    <td>1 per block</td>
 +  </tr>
 +  <tr>
 +    <th scope="row">hook_help('node/...')</th>
 +    <td>add/&lt;node type&gt;</td>
 +    <td>add/&lt;node type&gt;</td>
 +    <td>add/&lt;node type&gt;</td>
 +    <td>add/&lt;node type&gt;</td>
 +    <td>&lt;nid&gt;</td>
 +    <td>&lt;nid&gt;</td>
 +    <td>&lt;nid&gt;/edit</td>
 +    <td>&lt;nid&gt;/track</td>
 +  </tr>
 +</table>
  
 +</html>
  
-===== Node creation =====+===== Notes =====
  
 +The difference between 'modules fields' and 'loaded object' occurs if the module defines the additional fields it handles as fields as wrapped in an object [[http://blog.riff.org/index.php/2005/10/10/29-drupal-tips-hook_load-and-data-isolation|elswehere]]
  
-==== Step 1: Clicking on node type in "Create content==== +  * "Module fieldsis just a set of array entries made available, intermixed with the builtin array entries 
-  +  * "Loaded object" refers the samebut when they are returned by core as the wrapper object.
-  * Initialization part +
-    * hook_menu +
-    * hook_node_types +
-    * hook_user('load'). uid not defined at this pointname defined. +
-  * NO LOAD PART +
-  * node_validate +
-    * hook_validate. Builtin fields initialized +
-    * hook_nodeapi('validate'+
-  * Form part +
-    * hook_nodeapi('form pre'+
-    * hook_form. Builtin fields initialized. +
-    * hook_nodeapi('form post'+
-    * hook_nodeapi('form param'+
-  * Rest of page +
-    * hook_name +
-    * hook_node_types. Again. +
-    * hook_block. As many times as there are blocks to be displayed by this module. +
-    * hook_help(section = node/add/<node type>)+
  
 +Basically, modules fields are returned from a HTML form, whereas a loaded object comes from the DB.
  
-==== Step 2 : Clicking on PREVIEW for a new node ==== +Of courseany additional calls done by the module will appear somewhere in between theseFor instancehelpdesk loads the information about a contract's customerwhich is a drupal USERso <code>hook_user('load')</codeis fired from the module.
- +
-  * hook_form. Node contains form fieldsmixing builtin fields and module from objectNo object. +
-  +
-  * Initialization part +
-    * hook_menu +
-    * hook_user('load'). uid not defined at this pointname defined. +
-  * NO LOAD PART +
-  * node_validate +
-    * hook_validate. Node contains form fields, mixing builtin fields and module from object. No object. +
-    * hook_nodeapi('validate'+
-  * Preview part +
-    * hook_user('load'). uid not defined at this pointname defined. Again. +
-    * hook_view().  Node contains form fieldsmixing builtin fields and module from object. No object. +
-  * Form part +
-    * hook_nodeapi('form pre'+
-    * hook_form. Builtin fields initialized. +
-    * hook_nodeapi('form post'+
-    * hook_nodeapi('form param'+
-  * Rest of page +
-    * hook_name +
-    * hook_block. As many times as there are blocks to be displayed by this module. +
-    * hook_help(section = node/add/<node type>+
- +
-==== Clicking on SUBMIT for an invalid node ==== +
- +
-  * hook_validate +
-  * hook_view. Node contains loaded object if applicable +
-  * hook_nodeapi('view'+
- +
- +
- +
-==== Step 4 : Clicking on SUBMIT for a valid node ==== +
- +
-  * Initialization part +
-    * hook_menu +
-    * hook_user('load'). uid not defined at this point, name defined. +
-  * NO LOAD PART +
-  * node_validate +
-    * hook_validate. Node contains form fields, mixing builtin fields and module from object. No object. +
-    * hook_nodeapi('validate'+
-  * Insert part +
-    * hook_nodeapi('fields'+
-    * hook_insert. Node contains form fields, mixing builtin fields and module from object. No object. +
-    * hook_nodeapi('insert'+
-  * Rest of page +
-    * hook_name +
-    * hook_node_types +
-    * hook_block. As many times as there are blocks to be displayed by this module. +
-    * hook_help(section = node/add/<node type>+
- +
-===== Step 6 : Editing the new node ===== +
- +
-  * Loading part: +
-    * hook_load +
-    * hook_nodeapi('load'+
-  * Validation part: +
-    * hook_validate +
-    * hook_nodeapi('validate'+
-  * Form part: +
-    * hook_nodeapi('form pre'+
-    * hook_formNode contains loaded object if applicable. +
-    * hook_nodeapi('form post'+
-    * hook_nodeapi('form admin'+
-    * hook_nodeapi('form param'+
  
 +Similarly, any call to [[http://drupaldocs.org/api/head/function/l|l()]] causes [[http://drupaldocs.org/api/head/function/hook_link|hook_link]] to be fired too.
dr/api_sequences.txt · Last modified: 2020/11/23 17:23 by 127.0.0.1