Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#12 | node_get_types-338402-12.patch | 2.13 KB | drupal_was_my_past |
#10 | node_get_types-338402-10.patch | 2.13 KB | drupal_was_my_past |
#6 | 338402.patch | 2.25 KB | jhodgdon |
Comments
Comment #2
joachim CreditAttribution: joachim commentedA 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'.
Comment #3
casey CreditAttribution: casey commentednode_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.
Comment #4
joachim CreditAttribution: joachim commentedFixing the docs on 6 might still be a good idea; 6 will be supported for some time yet.
Comment #5
jhodgdonhttp://api.drupal.org/api/function/node_get_types/6 if anyone wants to look at the function doc.
Comment #6
jhodgdonHere's a patch to fix up this function doc.
Comment #7
jhodgdonGracious this is old.
The patch needs a reroll and a review. Reroll is good project for a novice contributor...
Comment #8
jhodgdonComment #9
drupal_was_my_past CreditAttribution: drupal_was_my_past commentedWorking on this at BADCamp.
Comment #10
drupal_was_my_past CreditAttribution: drupal_was_my_past commentedRe-rolled patch from #6.
Comment #11
jhodgdonThere 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!
Comment #12
drupal_was_my_past CreditAttribution: drupal_was_my_past commentedOoo bummer. I even proof read this and totally missed that typo. Here is a re-roll.
Comment #13
jhodgdonLooks good to me now, thanks! Typos are one reason that we have people review patches -- happens to everyone. :)
Comment #14
Gábor HojtsyThanks, committed, pushed.