See http://api.drupal.org/api/function/node_get_types/7

It says:
"Builds a list of available node types, and returns all of part of this list in the specified format."
and:
"$op The format in which to return the list. When this is set to 'type', 'base', or 'name', only the specified node type is returned. When set to 'types' or 'names', all node types are returned."

So... what's the difference between 'types' and 'names'?
What about 'base'? What does that do?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

A number of modules are using this function incorrectly and showing a badly sorted list of node types to admin users, eg: Nodequeue (http://drupal.org/node/347272, and also Views.
So this really needs a fix.

From what I can tell:

'names' gets you an array of the form 'machine name' => 'human name' and it's sorted so the order looks right.
'types' (the default) gets you a list sorted the same as the query (so module weight?). A lot of modules are using this, then filtering the resulting array to get 'machine name' => 'human name' when they should be using 'names'.

casey’s picture

Status: Active » Fixed

node_get_types() is renamed to:

node_type_get_types()
node_type_get_names()
node_type_get_type($node)
node_type_get_name($node)
node_type_get_base($node)

Those functions have pretty clear comments.

joachim’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Active

Fixing the docs on 6 might still be a good idea; 6 will be supported for some time yet.

jhodgdon’s picture

http://api.drupal.org/api/function/node_get_types/6 if anyone wants to look at the function doc.

jhodgdon’s picture

Status: Active » Needs review
FileSize
2.25 KB

Here's a patch to fix up this function doc.

jhodgdon’s picture

Issue tags: +Novice

Gracious this is old.

The patch needs a reroll and a review. Reroll is good project for a novice contributor...

jhodgdon’s picture

Status: Needs review » Needs work
drupal_was_my_past’s picture

Assigned: Unassigned » drupal_was_my_past

Working on this at BADCamp.

drupal_was_my_past’s picture

Status: Needs work » Needs review
FileSize
2.13 KB

Re-rolled patch from #6.

jhodgdon’s picture

Status: Needs review » Needs work

There is a typo in the first line: I think the 1st "of" should be "or":
" and returns all of part of this list. "

Other than that, the patch looks good,... of course it would probably look good to me, since I wrote the original a while back... gracious, I hope someone else reviews it sooner than a year this time!

drupal_was_my_past’s picture

Status: Needs work » Needs review
FileSize
2.13 KB

Ooo bummer. I even proof read this and totally missed that typo. Here is a re-roll.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me now, thanks! Typos are one reason that we have people review patches -- happens to everyone. :)

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed, pushed.

Status: Fixed » Closed (fixed)
Issue tags: -Novice

Automatically closed -- issue fixed for 2 weeks with no activity.