用于显示节点注释的节点的 Drupal 视图
我遇到了一个 Drupal 问题:我使用 Views 模块根据其作者的用户 ID 来渲染某种节点(实际上它是一个内容配置文件)。我希望视图显示节点的注释,就像在 node/% 中一样。我在视图或任何相关模块中找不到任何选项。我是否走错了方向,应该为此重新组织东西......?
有什么想法吗?如何实现?
问候,
拉奇
I've encountered a Drupal problem: I'm using the Views module for rendering nodes of a kind, based on the user id of it's author (it is a Content Profile actually). I want the view to show the comments for the node, just like in node/%. I could not find any option in views or any relevant module. Am I in the wrong direction and should reorganize stuff for this...?
Any ideas, how can it be done?
Regards,
Laci
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用视图确实不是最好的行动计划。您应该在主题中创建一个节点模板并对其进行自定义。如果需要,您可以在预处理函数中添加一些逻辑。它需要更多的编码,但会让你到达你想要的地方。
Using views is really not the best plan of action. You should instead create a node template in your theme and customize it. If needed you can put some logic in a preprocess function. It requires more coding but will get you where you want.
如果使用视图节点显示类型
检查它的设置显示评论
如果您使用视图字段显示类型
使用评论关系并选择您需要的字段并主题化它们
If you use view node display type
Check in it's settings show comments
if you use view fields display type
Use relationship to comments and select fields you need and theme them
我知道这是旧请求,但我只是在解决同样的问题并遇到了这篇文章。我认为分享我的解决方案会有帮助。
我正在使用 Drupal 7、Views 3 和 Display Suite。
您现在应该看到视图中每个项目下显示的注释。
I know this is old request, but I was just struggling with the same issue and came across this post. I thought it'd be helpful to share my solution.
I'm using Drupal 7, with Views 3 and Display Suite.
You should now see the comments displayed under each item in the view.
您可以创建第二个视图(使用 URL,例如
/comments/%
,其中占位符将是节点 ID,而不是评论 ID),列出给定节点的评论,并使用上下文过滤器仅根据 URL 中的 NID 显示它们。然后,将该视图添加到已有的单节点视图的页脚(作为“视图区域”)。
布局需要一些调整(内联字段等),但基本结构应该可以工作。
You could create a second view (with URL e.g.
/comments/%
where the placeholder will be the node ID, and not the comment ID) that lists comments for a given node, with a contextual filter to only show them based on the NID in the URL.Then, add that view to the footer (as a 'view area') of the single-node view you've already got.
There's some tweaking required for layout (inline fields etc.) but the basic structure should work.