简体   繁体   English

如何在Drupal“创建内容”页面上对内容类型进行分类(/ node / add)

[英]How can I categorize the content types on the Drupal “Create content” page (/node/add)

How can I categorize/organize the content types on my "Create content" page? 如何在“创建内容”页面上对内容类型进行分类/组织? I'm running Drupal 6.x with CCK. 我用CCK运行Drupal 6.x. I have a lot of custom content types, and my "Create content" page has become a bit unwieldy, as it lists them all alphabetically. 我有很多自定义内容类型,我的“创建内容”页面变得有点笨拙,因为它按字母顺序列出它们。 I'd like to organize them by category, so users would see something like: 我想按类别组织它们,因此用户会看到类似的内容:

Create Content
    Reports
        Report Type A
        Report Type B
    Events
        Event Type A
        Event Type B

I don't want to mess with Core, but anything else (custom module, theming, existing module functionality) is fair game. 我不想乱用Core,但其他任何东西(自定义模块,主题,现有模块功能)都是公平的游戏。 I'm hoping I'm missing something easy, because this seems like an obvious requirement, but all I could find on the Drupal site were these unanswered questions: 我希望我错过了一些简单的东西,因为这似乎是一个明显的要求,但我在Drupal网站上找到的所有这些都是未解决的问题:

You should be able to accomplish this in a custom module, without hacking core. 您应该能够在自定义模块中完成此任务,而无需破解核心。

You'll want to implement hook_menu_alter() to take over the callback function for node/add. 您需要实现hook_menu_alter()来接管node / add的回调函数。

Something like 就像是

function mymodule_menu_alter(&$items) {
  $items['node/add']['page callback'] = 'mymodule_node_add_page';
}

should get you started. 应该让你开始。 You would then create the function mymodule_node_add_page , and you could use the original callback function as a starting point. 然后,您将创建函数mymodule_node_add_page ,并且可以使用原始回调函数作为起点。

You can also do this at the theme level by overriding theme_node_add_list() . 您也可以通过覆盖theme_node_add_list()在主题级别执行此操作。

There are some different ways to attack this problem. 有一些不同的方法可以解决这个问题。 You can overwrite the old form page or just create a new one with a custom module. 您可以覆盖旧表单页面或只使用自定义模块创建一个新表单页面。 Doing that you can in your module do whatever your want. 你可以在你的模块中做你想做的事。

Another possibility is to do the same thing using views instead. 另一种可能性是使用视图来做同样的事情。 Doing that gives you access to a lot of powerfull features, as you can do anything the views module lets you do. 这样做可以让您访问许多强大的功能,因为您可以执行视图模块允许的任何操作。 You can create different ways of sorting the content types. 您可以创建不同的内容类型排序方式。

I've heard of many who have used views to make a page like this for the create content page. 我听说很多人使用视图为创建内容页面制作这样的页面。 Which method you choose is up to you, depending on how exactly you want to do this and the data you have associated with your content types, one will be more easy than the other. 您选择哪种方法取决于您的具体操作方式以及与内容类型相关联的数据,一种方法比另一种更容易。 But without knowing the exact details, I can't say which. 但不知道具体细节,我不知道哪个。 I would advise you to start out with views, since you quickly should be able to find out, if you can use it to get what you want. 我会建议你从观点开始,因为你很快就能找到,如果你能用它来得到你想要的东西。

有一个模块可以满足您的需求, 内容类型组

I created a sandbox module some time ago which was supposed to do this: https://drupal.org/sandbox/YaronTal/1260038 我不久前创建了一个沙盒模块,应该这样做: https//drupal.org/sandbox/YaronTal/1260038

The only problem is that I wasn't able to create the admin backend with draggable interface at the time. 唯一的问题是我当时无法使用可拖动界面创建管理员后端。

I know the issue is old, but just in case someone else has the same problem... 我知道这个问题很老,但万一其他人有同样的问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM