function content_type_create in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 includes/content.crud.inc \content_type_create()
- 6 includes/content.crud.inc \content_type_create()
- 6.2 includes/content.crud.inc \content_type_create()
Make changes needed when a content type is created.
Parameters
$info: value supplied by hook_node_type()
2 calls to content_type_create()
- content_node_type in ./
content.module - Implementation of hook_node_type() React to change in node types
- content_types_rebuild in ./
content_crud.inc - Rebuild content type information from node tables.
File
- ./
content_crud.inc, line 109 - Create/Read/Update/Delete functions for CCK-defined object types.
Code
function content_type_create($info) {
content_clear_type_cache();
$type = content_types($info->type);
$table = _content_tablename($type['type'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
if (!db_table_exists($table)) {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {" . $table . "} (\n vid int unsigned NOT NULL default '0',\n nid int unsigned NOT NULL default '0',\n PRIMARY KEY (vid),\n KEY nid (nid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */");
break;
case 'pgsql':
db_query("CREATE TABLE {" . $table . "} (\n vid int_unsigned NOT NULL default '0',\n nid int_unsigned NOT NULL default '0',\n PRIMARY KEY (vid)\n )");
db_query("CREATE INDEX {" . $table . "}_nid_idx ON {" . $table . "}(nid)");
break;
}
drupal_set_message(t('The content fields table %name has been created.', array(
'%name' => $table,
)));
}
}