如何在 Drupal 中打印单个评论线程?

发布于 2024-10-08 12:40:15 字数 324 浏览 0 评论 0原文

我想创建一个包含单个评论及其所有回复的页面。到目前为止,没有运气:我可以在节点和所需的评论 ID 上调用 comment_render (另请参见 如何在 drupal 中打印一条评论?),但这只是给我评论,而不是回复。

深入研究注释表让我认为解决方案必须通过实现线程的 cid 和 pid 字段来破解,但我不知道如何以可以通过 pager_query 传递来处理的方式做到这一点大量回复的可能性。有什么想法吗?谢谢!

I want to make a page that contains a single comment AND all the replies to it. So far, no luck: I can call comment_render on the node and desired comment ID (cf also How do I print a single comment in drupal?), but that just gives me the comment, not the replies.

Digging through the comments table makes me think that a solution would have to hack its way through the cid and pid fields that implement the thread, but I don't see how to do that in a way that can be passed through pager_query to handle the possibility of a large number of replies. Any thoughts out there? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情稳全场 2024-10-15 12:40:15

对于未来的访问者:我得到了一些工作,我认为这实际上并不太可怕:

1:从 {comments} 中提取给定节点上的所有评论。

2:从 CID 开始遍历这些评论:遍历原始评论的回复树,并将起始 CID 和所有发现的回复组成一个数组。

3:制作一个临时表,从{comments}中仅选择NID为起始节点且CID为通过遍历树找到的那些之一的那些。

4:将此临时表交给comment_render的破解版本,该版本对临时表而不是{comments}进行操作。

5:打印结果。

6:利润!

至少看起来是这样。这可能意味着在新版本发布时跟踪 comment_render ,但我猜测/希望它现在是相当稳定的代码。
当然,欢迎对此相对智慧的思考。

For future visitors: I got something working, which I think actually isn't too terrible:

1: Pull all the comments on the given node out of {comments}.

2: Walk through those comments, starting with CID: traverse the tree of replies to the original comment and put together an array of the starting CID and all the discovered replies.

3: Make a temporary table, selecting from {comments} just those whose NID is that of the starting node and whose CID is one of those found by walking the tree.

4: Hand this temporary table off to a hacked version of comment_render, which operates on the temporary table instead of {comments}.

5: Print the result.

6: Profit!

Or so it seems, anyway. It probably means tracking comment_render as new versions are released, but I'm guessing/hoping that it's pretty stable code by now.
Thoughts about the relative wisdom of this are, of course, welcome.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文