在 Drupal Views 参数中,如何获取节点队列中的节点总数?
我正在一个网站上工作,该网站是数千张唱片的数据库,并试图创建一个“每日专辑”块。我的解决方案是创建特定记录的节点队列,创建一个将一年中的当前日期作为参数传递的视图,然后使用该值调用具有相同编号位置的节点队列项。我通过在“Nodequeue: Position”参数设置中提供“默认参数”作为 PHP 代码来实现此目的。这是我使用的代码:
$nodequeueTotalNodes = 120;
$dayOfTheYear = date("z");
$nodeQueuePosition = $dayOfTheYear % $nodequeueTotalNodes;
return $nodeQueuePosition;
上面的代码使我满意,但我的问题是每次在节点队列中添加或删除项目时,我都必须手动更改 $nodequeueTotalNodes 的值。
有没有办法从我的队列中提取节点总数来替换上面代码中的“120”?
I'm working on a site that is a database of thousands record albums and am attempting to create an "album of the day" block. My solution has been to create a nodequeue of specific records, create a view that passes the current day of the year as an argument, and then uses this value to call the nodequeue item with that same numbered position. I do this by providing a "Default Argument" as PHP code in the "Nodequeue: Position" argument setting. Here's the code I use:
$nodequeueTotalNodes = 120;
$dayOfTheYear = date("z");
$nodeQueuePosition = $dayOfTheYear % $nodequeueTotalNodes;
return $nodeQueuePosition;
The above code works to my satisfaction but my problem is I have to manually change the value of $nodequeueTotalNodes every time I add or remove an item from my nodequeue.
Is there a way to pull the total number of nodes from my queue to replace the "120" in my code above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
nodequeue_nodes 表保存队列中的所有节点。像这样的事情应该可以解决问题,其中 qid 是队列 id:
如果您使用子队列,则可以使用名为 sqid 的列。
The nodequeue_nodes table holds all the nodes in your queues. Something like this should do the trick, where qid is the queue id:
If you're using a subqueue there's a column called sqid which you can use.