By monil-dupe on
I am changing a module from Drupal 6 to 7. In the old code, there is this code:
$types = node_get_types();
I changed it to below code but it doesn't work well.
$types = node_type_get_types();
And i also changed it to:
$types = node_type_get();
And finally i changed it to :
node_type_clear();
$types = node_type_get_types();
But none of above codes work. Please tell me what should i write instead of below code to work fine in Drupal 7?
$types = node_get_types();
Comments
More information
When no parameter is supplied Drupal 6's node_get_types returns :
Drupal 7's node_type_get_types returns :
I assume the problem you are having relates to the "keyed by" aspect of the returned array. If so you will need to make adjustments after the quoted code to adjust for this difference. It may help if you could be more explicit about why it "doesn't work well". My reading of this is that it works but differently.
code snippet to help debug
D6 - node_get_types():
D7 - node_type_get_types()
This should make things easy to read, so you can check for differences between versions. Use it in your module, or a page/block with PHP filter enabled.
Another thing to check is the function(s) you are using $types with. Perhaps it expects different parameters in D7?
I made a php block in Drupal
I made a php block in Drupal 7 and wrote the code you wrote above to be shown in each node and i got these codes. Now what should i do?
Next Steps
Next, I would do the same thing for Drupal 6, and compare the two. The main thing is to see if the keys are the same. In this case, the keys are [article] and [page].
Besides that, if you can give some more information, I'll try to help:
1. What are you trying to accomplish? Just so I have some context for your problem.
2. In Drupal 6, after you set up $types, what did you do with it?
3. In Drupal 7, what were you expecting to happen, and what did happen?
Thanks a lot. The problem is
Thanks a lot. The problem is solved now by comparing them.