internal name is returned, instead of human-readable name in some circumstances

Coyote - September 29, 2006 - 19:48
Project:ContentO
Version:4.7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

While messing about with Organic Groups, I noticed that in the list of group content, when Contento node types are used for OG group postings, that on the group home page, it lists the internal system name of the contento type, instead of the human-readable name.

Then, while fiddling with a module of my own that I'm working on, I found that getting a list of node types via node_get_types() gives an array where the key is the internal name of each node type, with the values set to the human-readable name of each node type... except for contento node types, which return the internal system name for both key and value.

CCK types return the expected labels, as do the normal drupal node types. It's just contento types that seem to be handing back the system name instead of the human-readable label. (I haven't tried it with Flexinode, as it is listed as deprecated).

Coyote

#1

Tobias Maier - November 16, 2006 - 09:19

the same issue exists for node/add
the content-types get called by their internal names

#2

Tobias Maier - November 16, 2006 - 09:28
Status:active» needs review

i think i have a fix for it
BUT it is not tested only coded theoretically
because I'm at the university...

replace the contento_type_list() function with this one:

function contento_type_list() {
  static $content_type;

  if (!isset($content_type)) {
    $content_type = array();
    $result = db_query('SELECT * FROM {content_type} nt ORDER BY nt.name ASC');
    while ($type= db_fetch_array($result)) {
      $content_type[$type['name']] = $type;
      $content_type[$type['name']]['name'] = $type['label'];
    }
  }

  return $content_type;
}

whats the problem:
hook_node_info()
asks that array('name') is the human readable name
but in our table this is the machine-name
so we have to replace it with 'label'

#3

Tobias Maier - November 19, 2006 - 12:54

the patch

AttachmentSize
contento_type_list.patch.txt 768 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.