开发者

Drupal create related node on node view

开发者 https://www.devze.com 2023-03-02 02:48 出处:网络
So if I have 2 custom content types book and review, I\'d like a user(when viewing a specific book) to be able to create/attach a review to the book.

So if I have 2 custom content types book and review, I'd like a user(when viewing a specific book) to be able to create/attach a review to the book.

I've tried a few options.

1) Created a "create review" formblock and using panels made a custom node view panel for review, but I couldn't get the relationship to work.

2) I also tried overriding comments on the book type with the node type review, the problem with this is I'd like users to 开发者_运维知识库be also be able to comment on the book and I couldn't see the ability to add multiple comment types.

This seems pretty easy to do on node edit with node reference extension so I'm hoping this isn't a big ask.


You need nodereference and nodereference_url modules.

You can simply create a nodereference field in your review content type, and configure it with nodereference_url widget.


You partially answered your own question. With the nodereference module in D6 (or just references in D7), you can create a link in the same place 'add a comment' appears (the .links div) which says "add a review". This link is because "reviews" has a field called something like "book reference" which is a noderef field. This review will automatically fill in the field with the book where the user clicked the link and, depending on how you set the field up, send you back to the referenced node (book) or the new review.


You can find an interesting screencast there that show how to use Views Attach and Node Reference URL to do what you want :

http://mustardseedmedia.com/podcast/episode37

0

精彩评论

暂无评论...
验证码 换一张
取 消