Haywire
Haywire

Reputation: 11

How do I get a list of all Content Types in Drupal 6?

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

Answers (3)

Gokul N K
Gokul N K

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

Laxman13
Laxman13

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

PatrickS
PatrickS

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

Related Questions