简体   繁体   English

drupal多个内容类型参考

[英]drupal multiple content type reference

Drupal has content types set as: Drupal的内容类型设置为:

- Book
- Contributor

Custom CCK fields are added to above content types. 自定义CCK字段已添加到上述内容类型。

Contributor has type id set as: 参与者将类型ID设置为:

- Author
- Seller
- Reader

The above contributor type id is to be added (currently with node reference) to "Book" with Author and contrition typpe "Seller". 将使用作者和贡献类型“卖方”将上述贡献者类型id添加到“ Book”(当前带有节点引用)。

example: 例:

Book                    Contributor     Contributor Type
--------------------------------    --------------  ---------------
Act Like a Lady, Think Like a Man   Steve Harvey    Atuhor
Act Like a Lady, Think Like a Man   Steve Harvey    Seller
The Alchemist               Paulo Coelho    Reader
The Happiness Project           Gretchen Rubin  Atuhor
The Happiness Project           Gretchen Rubin  Seller

What would the best approach to achieve this. 什么是实现这一目标的最佳方法? With current setup we are able to add contributor id, how to add "contributor type" with it as well. 使用当前设置,我们能够添加贡献者ID,以及如何添加“贡献者类型”。

If I understand you correctly 如果我理解正确

  1. You have 2 content types. 您有2种内容类型。 Book and Contributor BookContributor
  2. The Book content type has a node reference field which points to nodes of type Contributor Book内容类型具有一个节点引用字段,该字段指向Contributor类型的节点
  3. There can be three kinds of contributors: Author, Seller and Reader 可以有三种类型的贡献者:作者,卖方和读者
  4. From the Book content type you want to be able to select the contributor (via Node Reference) and mark the the contributor type as reader, seller, author etc. (In some ways you want to add an "attribute" to the Node Reference or "describe" the Node Reference) 您希望从Book内容类型中选择贡献者(通过Node Reference),并将贡献者类型标记为读者,卖方,作者等。(以某种方式,您希望在Node Reference中添加“属性”或“描述”节点参考)
  5. Also this way its possible for a contributor to be in more than 1 category. 同样,以这种方式,贡献者可以属于多个类别。 eg A contributor can be an author and seller also. 例如,贡献者也可以是作者和卖方。

Actually your question, if I have understood correctly is a good one. 实际上,如果我理解正确,那么您的问题就是一个好问题。 The answer is not trivial.You need to somehow "group" the node reference field with a select list. 答案不平凡。您需要以某种方式将节点引用字段与选择列表“分组”。 This way every time you make a node reference, you also select the contributor type. 这样, 每次您创建节点引用时,您还可以选择参与者类型。 What you're asking for essentially is "Multigroup" feature. 您实际上要求的是“多组”功能。 Its available only in CCK version 3.You cannot do this with CCK Version 2 series which is what you're probably using. 它仅在CCK版本3中可用。您可能无法使用CCK版本2系列执行此操作。 Unfortunately a stable version 3 of CCK is still not available. 不幸的是,CCK的稳定版本3仍然不可用。 However a development is available at http://drupal.org/node/484068 . 但是,可以从http://drupal.org/node/484068进行开发。 As of today, a lot people are using this version already (see http://drupal.org/project/usage/484068 ) and from what I've read, its quite stable already. 到今天为止,已经有很多人在使用此版本(请参阅http://drupal.org/project/usage/484068 ),据我所读,它已经相当稳定。

So in summary: 因此,总而言之:

  1. Install CCK 3.x-dev from http://drupal.org/node/484068 in your sites/all/modules folder. http://drupal.org/node/484068在您的sites/all/modules文件夹中安装CCK 3.x-dev。 Remove the CCK 2.x folder if it exists there. 删除CCK 2.x文件夹(如果存在)。 Please take backups etc. of your site -- just in case something breaks. 请备份您网站的备份等,以防万一。
  2. Enable the Multigroup module (under the CCK module listing) 启用多组模块(在CCK模块列表下)
  3. Create a Multigroup lets call it MG . 创建一个Multigroup称为MG You can do this under Manage fields -> Add a New group (Select Multigroup from the dropdown) 您可以在管理字段->添加新组下执行此操作(从下拉列表中选择Multigroup组)
  4. Create a Node Reference field to Contributor Nodes, lets call it Link to Contributor . 创建一个指向Contributor节点的Node Reference字段,将其称为Link to Contributor Make sure the parent of Link to Contributor is MG (you can achieve this by grabbing the anchor and moving the field to the right, just like you do for a hierarchical taxonomy tree. 确保“ Link to Contributor的父级是MG (您可以通过抓住锚点并将字段向右移动来实现此目的,就像处理分层分类法树一样。
  5. Create a contributor type select list field with three options (Seller, Reader, Author). 创建具有三个选项(卖方,读者,作者)的参与者类型选择列表字段。 Lets call the field Contributor Type . 让我们称为字段Contributor Type Again, make sure the parent is MG . 再次,确保父母是MG
  6. Now test this by trying to create nodes of type Book . 现在,通过尝试创建Book类型的节点来进行测试。 You will be able to select the Contributor and the Contributor Type. 您将能够选择贡献者和贡献者类型。 To add more Contributors to a book , simply press the Add More Values in the Node Edit Form. 要将更多贡献者添加到book ,只需在“节点编辑”表单中按“ Add More Values ”即可。
  7. For Views integration you need to install Views version 3.0-alpha3 or higher. 对于Views集成,您需要安装Views 3.0-alpha3或更高版本。 You will need to add a filter under under the Content Multigroup group. 您将需要在“内容多组”组下添加一个过滤器。

And BTW since I found your question interesting, I've tried it out and it seems to work correctly for me! 顺便说一句,因为我发现您的问题很有趣,所以我尝试了一下,看来它对我来说是正确的!

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

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