Is a drupal View useful for this use case

瘦欲@ 提交于 2020-01-14 09:28:32

问题


I have a list of nodes that I want to present to the user. The user then picks 3 and I need to remember that decision so I can present them in a smaller list later (your choices list).

To present the full list of nodes, I will just use views to get all published nodes.

The question is how do I store those 3 choices so I can pull them in the "your choices list"? What structure should I use to save them? create a content type called list or use views. Not sure, or there's something more logical for this use case?


回答1:


You most definitely want to take a closer look at the Flag module. It provides a flexible system for 'flagging' (or marking) nodes, users and comments, along with good views integration.

Using this, you could create a flag 'favorite', set it as 'per user' and your users can use this to mark nodes. With the views integration, you can create custom views filtering on those flags in many ways, thus you can easily create pages and blocks that display those favorites.

I'm not sure if it supports a limitation to e.g. three flags per user out of the box, but it also comes with an API so you should be able to influence things like that (no guarantee, though ;)

You might also want to check the following, but I have no experience using them, so no idea if they are good and/or fit your bill:

  • Favorite Nodes module
  • Favorites module



回答2:


a simple and effective other approach is to add a php field in the view. In the php save the node id into the $_SESSION variable or to the database if you need longer live times.

You can make use of the powerfull arguments passing to views to make it show the nodes using the nids.

We often use it in webstores to remember the lastviewed products and such.



来源:https://stackoverflow.com/questions/3366062/is-a-drupal-view-useful-for-this-use-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!