一个 Drupal 视图,用于显示一年中每一天、每天评分最高的节点? [英] A Drupal view to show the top rated node per day, each day for a year?

查看:39
本文介绍了一个 Drupal 视图,用于显示一年中每一天、每天评分最高的节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含用户生成故事的网站.故事是节点.故事由 Fivestar 评分.

I have a site with user generated stories. Stories are nodes. Stories are rated with Fivestar.

我想创建一个日历样式视图来列出评分最高的故事 - 每年的每一天.所以最后我会有一个 365 个故事的列表.

I want to create a calendar style view to list the top rated story - every day, for the current year. So at the end I will have a list of 365 stories.

我不知道如何解决这个问题,任何帮助都会很棒.

I'm not sure how to approach this, any help would be great.

推荐答案

您可以创建一个接受日期参数的视图,您将在其中传递特定日期',并返回按 Fivestar 评级排序的结果,并限制视图到 1 个结果.

You could make a View that takes a Date argument, where you'll pass a specific day', and return results sorted by Fivestar rating, and limiting the View to 1 result.

然后在您的自定义日历中,每天和每次循环,调用视图并显示结果,这将是评分最高"的笔记.虽然这可能有点矫枉过正,但它适用于显示当今当前评分最高的 Node.js 的 Block.我实际上不会将它用于整个月甚至一年的视图.

Then in your custom calendar, loop over every day, and each time, calling the View and showing the result, which will be the 'top rated' note. Though this might be somewhat overkill, it's suitable for a Block which shows today's current top rated Node. I wouldn't actually use it for a whole month or even year view.

另一种选择可能是,每 24 小时 - 午夜过后一点 - 您使用该视图获取前一天评分最高的笔记,并将其存储或标记为评分最高的.这样,每天只会标记或存储 1 个节点,您可以构建一个视图,列出所有存储/标记的节点,按日期排序.评分在这里无关紧要,因为您在 Cron 中运行的视图已经获得了评分最高的视图.将此视图主题化为网格,并且可能带有参数 Month,并且您接近日历,例如您每天评分最高的节点的月视图.

Another option could be, that every 24 hours - and a little past midnight - you use that View to get the top rated note for the previous day, and store or flag it as the top rated. That way, only 1 Node a day will be flagged or stored, and you could build a view that lists all stored/flagged nodes, ordered by date. Rating is irrelevant here, since the View you ran in Cron already picked up the top rated one. Theme this View as a grid, and maybe with an argument Month, and you are close to a Calendar like Month view of your top rated Nodes per day.

最后一个选项是构建一个视图,它获取所有节点,并按评级对它们进行排序,并按天对它们进行分组.然后确保每组只打印 1 个,即评分最高的一个.

Last option would be to build a View, which gets all nodes, and sort them by rating, and group them by day. Then make sure you only print 1 per group, namely, the top rated one.

这篇关于一个 Drupal 视图,用于显示一年中每一天、每天评分最高的节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆