简体   繁体   English

如何获得Drupal 6中所有内容类型的列表?

[英]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.

相关问题 如何在Drupal的配置文件类型中将内容类型列出为复选框 - How can I list Content Types as checkbox in Profile types for Drupal 如何在Drupal 7中以编程方式获取具有特定字段的所有内容类型? - How to get all content types having a certain field programmatically in Drupal 7? 在Drupal 7中,如何获取页面上使用的所有块的列表? - In Drupal 7, how do I get a list of all blocks being used on the page? Drupal:如何创建一个显示所有内容类型的视图 - Drupal : how to create a view that displays all the content-types 如何限制Drupal搜索将所有内容类型编入索引? - How to restrict drupal search from indexing all content types? 如何在Drupal视图中设置适用于两种不同内容类型的过滤器? - How do I set up filters in a Drupal view that apply across two different content types? 如何在一个块中呈现内容类型列表? (drupal 7) - how to render a list of content-types in a block? (drupal 7) Drupal:数据库中的内容类型不在Structure&gt; Content types中的内容类型列表中 - Drupal: Content type in database not in the list of content types in Structure>Content types “内容类型”列表中的Drupal更改行权重 - Drupal change row weight in Content Types list 如果我的(Drupal 7)内容类型不需要标题,我该怎么办? - What do I do if I my (Drupal 7) content types do not require a title?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM