Reputation: 11
Is there a simple method for retrieving all of the Content Types available on a Drupal 6 site? This seems like a simple issue but I can't seem to find a relatively simple way to handle it.
I think I could parse across the database tables for the names but that seems like an overkill query for such a simple need.
Upvotes: 1
Views: 1596
Reputation: 2458
If you also want the fields within the content types, you can use this functions.
$fields = $fields['content types'][$content_type]['fields'];
Check http://www.drupaltonight.com/2012/01/drupal-6-php-snipper-to-get-list-of-all.html for the full snippet.
Upvotes: 0
Reputation: 5211
There is actually a function in the Drupal API that does this for you. Take a look at node_get_types().
If you do: <?php $content_types = node_get_types('types'); ?>
all info about content types is returned (name, module, description, etc), or you can do <?php $content_types = node_get_types('names'); ?>
that gives you a simple array with the machine names as the keys and the human-readable names as the values
Upvotes: 3
Reputation: 9572
Typically, you would go to :
yoursite/admin/content/types
The Schema module could give you an overview of your database structure, you could also look at all the tables prefixed content_type_
Upvotes: 2