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
Description

The 'Select or Create' display is using Content Type Type rather than Content Type Name...

#1

Lionfish - April 29, 2007 - 13:47
Assigned to:Anonymous» Lionfish
Status:active» fixed

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

jlinares - April 29, 2007 - 14:15

If you're in addnode.module, you should prefix your function with 'addnode'. That is, _addnode_get_human_type_name.

#3

nevets - April 29, 2007 - 14:32

Core contains the function node_get_types() to do this. You would call it something like

$name = node_get_types('type', $type);

#4

Lionfish - May 3, 2007 - 08:20

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

Anonymous - May 17, 2007 - 08:33
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.