查看内容窗格“相关内容”按分类法

发布于 2024-11-29 21:09:17 字数 353 浏览 3 评论 0原文

我目前正在开发一个 Drupal 7 站点,在其中我使用页面管理器的“node_view”来自定义“文章”内容类型的布局。 因此,每当查看文章时,我想显示一个带有“相关内容”的小框。 我有一个在所有内容类型中使用的分类词汇“共享类别”。

例如,我还有一个“图库”内容类型,因此当查看带有“myTag”术语的文章时 - 我想显示一个内容窗格,其中包含“共享类别”词汇中标有“myTag”的图像。

我的问题是关于为内容窗格设置上下文过滤器。 “参数输入”应该是词汇表还是术语? - 我已经尝试了两者,但无法使其工作。

我还有另一个问题:是否可以使用内容窗格作为与面板一起显示的块? - 我想不会,因为上下文过滤器值来自页面管理器。

I'm currently developing a Drupal 7 site where I use Page Manager's "node_view" to customize the layout for my "Article" content type.
So, whenever viewing an Article I want to show a little box with "Related content".
I have a taxonomy vocabulary "Shared category" that I use in all my content types.

For example I also have a "Gallery" content type, so when viewing an article in with the "myTag" term - I want to show a Content Pane with images tagged with "myTag" from the "Shared category" vocabulary.

My question is about setting up the Contextual Filter for the Content Pane.
Should the "Argument input" be a Vocabulary or a Term? - I've tried both but can't get it to work.

Also I have another question: Is it possible to use a Content Pane as a block, that is shown with the Panel? - I guess not, sinse the Contextual filter value comes from Page Manager.

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

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

发布评论

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

评论(2

樱&纷飞 2024-12-06 21:09:17

您不想在面板中手动输入参数,因为每篇文章的参数都会有所不同。
您需要使用从节点获取 tid 的默认参数自动设置它。

要让相关内容块根据与正在查看的节点相同的术语显示内容,您需要向视图添加分类术语 id 参数。
然后,您可以尝试“设置默认参数”并使用“URL 中的分类术语”(节点选项)

如果这不起作用,您可能需要在默认参数区域中使用 php 代码从节点获取相关的 tid,其中像node_load或menu_get_object这样的东西来加载节点。

例如类似的东西

if($node = menu_get_object()){
  if(isset($node->field_shared_category[$node->language][0]['tid'])){
    return $node->field_shared_category[$node->language][0]['tid'];
  }
}

You won't want to manually input the argument in the panel, as it will vary for each article.
You'll want to set it automatically using a default argument that gets the tid from the node.

To get the related content block to show content based on the same terms as the node being viewed, you'd need to add a taxonomy term id argument to the view.
You can then try the 'Set a default argument' and use 'taxonomy term from URL' ( node option )

If that doesn't work, you may need to get the relevant tid from node using php code in the default argument area, with something like node_load or menu_get_object to load the node.

e.g something like

if($node = menu_get_object()){
  if(isset($node->field_shared_category[$node->language][0]['tid'])){
    return $node->field_shared_category[$node->language][0]['tid'];
  }
}
野却迷人 2024-12-06 21:09:17

可以通过在块视图中使用上下文过滤器来显示相关内容。该块视图将包含与用户当前查看的内容相关联的内容。

您可以转到“根据以下内容创建相关内容块视图Drupal 7”博客文章中的术语,获取创建此块视图的分步说明。

Related content can be shown by using contextual filter in block views. This block view will contain content which are associated with the current content viewed by a user.

You can goto "Create related content block view based on terms in Drupal 7" blog post to get step by step instruction to create this block view.

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