简体   繁体   English

Drupal View在此用例中有用吗?

[英]Is a drupal View useful for this use case

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). 然后,用户选择3,我需要记住该决定,以便稍后将它们显示在较小的列表中(您的选择列表)。

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? 不确定,还是该用例更合乎逻辑?

You most definitely want to take a closer look at the Flag module . 您绝对希望进一步了解Flag模块 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 eg 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 ;) 我不确定它是否支持例如每个用户三个标志的限制,但是它还带有一个API,因此您应该能够影响类似的事情(尽管不能保证;)

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: 您可能还需要检查以下内容,但是我没有使用它们的经验,因此不知道它们是否不错和/或是否适合您的账单:

a simple and effective other approach is to add a php field in the view. 一种简单有效的其他方法是在视图中添加一个php字段。 In the php save the node id into the $_SESSION variable or to the database if you need longer live times. 在php中,将节点ID保存到$ _SESSION变量中,如果需要更长的生存时间,则保存到数据库中。

You can make use of the powerfull arguments passing to views to make it show the nodes using the nids. 您可以利用传递给视图的功能强大的参数来使用nids显示节点。

We often use it in webstores to remember the lastviewed products and such. 我们经常在网上商店中使用它来记住最近浏览过的产品等。

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

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