Using Content Type Type rather than Content Type Name
obscurity - March 23, 2007 - 15:00
| Project: | Addnode |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Lionfish |
| Status: | closed |
Jump to:
Description
The 'Select or Create' display is using Content Type Type rather than Content Type Name...

#1
Fixed in v1.1 (next version I'll upload).
Used the following function to get the type's human name:
<?php//This function returns the human readable name of a type (todo: Is there a drupal function that does this?)
function _get_human_type_name($type)
{
$query = "SELECT name FROM {node_type} WHERE type='%s'";
return db_result(db_query($query, $type));
}
?>
if anyone knows of a drupal function to do a similar thing (or a better way of coding it) please post below!
Thanks,
Mike.
#2
If you're in addnode.module, you should prefix your function with 'addnode'. That is, _addnode_get_human_type_name.
#3
Core contains the function node_get_types() to do this. You would call it something like
$name = node_get_types('type', $type);#4
Thanks nevets and jlinares, I've renamed my functions and am now using node_get_types.
(btw: should handlers be prefixed with an underscore?)
#5