You are here

function hook_node_import_types in Node import 6

Same name and namespace in other branches
  1. 5 docs/node_import_hook_docs.php \hook_node_import_types()

List the available content types.

Use this hook to return a list of available types of content. You are not limited to returning node content types, but you can return any type of content you want.

@par Content type

The key of the returned array is used as internal content type ($type) and will be passed to all other hooks. For example "user", "node:story", ...

This last example shows how supported/node.inc handles different content types.

\par Content information

The value of the returned array is an array with a number of keys that describes how the content type can be created:

  • \b "title" : Human readable name (required).
  • \b "can_create" : Either a boolean (TRUE or FALSE) or a callback function that checks whether the user can create the specific type of content.
  • \b "create" : Callback function that creates the object.

You may set other data for this content type as well, for example supported/taxonomy.inc sets a "vocabulary" key to avoid having to lookup the vocabulary a term belongs to.

\par can_create callback


$can_create = function callback($type);

The callback should return TRUE if the current user can create given content type and FALSE otherwise.

\par create callback


$output = function callback($type, $values, $preview);

In case of $preview == TRUE, $output should be a HTML string that shows a preview of the content the user is trying to import.

In case of $preview == FALSE, $output should be an object id of the created object. For example the nid, uid, vid, ...

user_node_import_types(), taxonomy_node_import_types().

Return value

Array ($type => $info).

See also

node_node_import_types(),

Related topics

3 functions implement hook_node_import_types()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_node_import_types in supported/node.inc
Implementation of hook_node_import_types().
taxonomy_node_import_types in supported/taxonomy.inc
Implementation of hook_node_import_types().
user_node_import_types in supported/user.inc
Implementation of hook_node_import_types().
1 invocation of hook_node_import_types()
node_import_types in ./node_import.inc
Returns a list of available content types.

File

./node_import.api.php, line 71
Explanation of the Node import hooks.

Code

function hook_node_import_types() {
}