[英]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? 是否有一种简单的方法来检索Drupal 6站点上可用的所有内容类型? 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. 我认为我可以解析数据库表中的名称,但是对于如此简单的需求,这似乎是一个过分的查询。
There is actually a function in the Drupal API that does this for you. 实际上,Drupal API中有一个函数可以为您完成此任务。 Take a look at node_get_types() .
看一下node_get_types() 。
If you do: <?php $content_types = node_get_types('types'); ?>
如果您这样做:
<?php $content_types = node_get_types('types'); ?>
<?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'); ?>
<?php $content_types = node_get_types('types'); ?>
返回有关内容类型的所有信息(名称,模块,描述等),或者您可以执行<?php $content_types = node_get_types('names'); ?>
<?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 <?php $content_types = node_get_types('names'); ?>
为您提供一个简单的数组,以计算机名称作为键,以人类可读的名称作为值
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_ Schema模块可以为您提供数据库结构的概述,还可以查看所有以content_type_开头的表
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. 有关完整的代码段,请访问http://www.drupaltonight.com/2012/01/drupal-6-php-snipper-to-get-list-of-all.html 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.