如何在包含的节点上显示NodeQueue块? [英] How to just show NodeQueue block on included nodes?

查看:237
本文介绍了如何在包含的节点上显示NodeQueue块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的博客上,我有一系列关于我想链接的常见问题的帖子连同一个通用的导航块,使读者可以轻松地向前或向后跳过这个系列。

On my blog I have a series of posts on a common subject that I'd like to link together with a common navigation block, so that readers can easily jump forwards or backwards through the series.

我已经使用了 NodeQueue 按顺序收集所有的博客条目。将关联的块放在我的侧边栏中给我我想要的导航,但是该块出现在我网站的每一页上。

I've used NodeQueue to collect all the blog entries together in sequence. Putting the associated block in my sidebar gives me the navigation that I want BUT the block appears on every page of my site.

我想做的是限制可见性该块,使其仅出现在包含在队列中的页面上。我如何做到这一点?

What I want to do is limit the visibility of the block so that it only appears on pages that are included in the queue. How can I do this?

我知道NodeQueue使用视图,所以我想答案可能更多的是使用Views而不是NodeQueue。如果有一个模块可以做到我所需要的,那会是很棒的。如果答案需要PHP(比如说配置块可见性),那么我需要一些手持。

I know that NodeQueue creates it's blocks using Views, so I guess the answer might be more to do with using Views than NodeQueue. If there's a module that does what I need, that'd be great. If the answer requires PHP (say, for configuring block visibility) then I'll need some handholding.

博客正在Drupal 6.19上运行,我有一个测试实例

The blog is running on Drupal 6.19 and I do have a test instance I can try things out on before touching the live site.

推荐答案

确定这个稍微长一点,虽然我觉得优雅的解决方案。我希望它不会吓到你 - 它真的不复杂,但不同于代码,它很难在文本中解释。这是很有趣的。此回答适用于Views 2或更高版本。本质上解决方案结合了两个模块:

Ok this is a slightly lengthly though I think elegant solution. I hope it doesn't scare you off -- Its really not complex but unlike code its difficult to explain in text. It was fun figuring this out. This answer works in Views version 2 or higher. Essentially the solution combines two modules


  1. Views attach( http://drupal.org/project/views_attach

  2. Nodequeue(最具体的分类排序队列)

请继续阅读关于视图附件。视频附件最好由此视频 http://mustardseedmedia.com/podcast/episode37 解释。

Please read about Views attach before proceeding further. Views attach is best explained by this video http://mustardseedmedia.com/podcast/episode37

分类排序只不过是在词汇表中为每个分类术语自动创建的节点队列。假设我们有一个名为我的列表的分类结点队列。让我们说你有一个名为系列的词汇,它有3个术语: Apache Solr教程系列 CSS Tips and Techniques Series Drupal Views Tips Series 。而如果我的列表使用系列作为其分类源,则将创建3个子队列 - 每个子队列

A Taxonomy Queue is nothing but a Nodequeue that is automatically created for each taxonomy term in a vocabulary. Let say we have a taxonomy nodequeue called My Lists. Lets say you have a Vocabulary called Series and it has 3 terms: Apache Solr Tutorial Series, CSS Tips and Techniques Series, Drupal Views Tips Series. And if My Lists uses the Series as its taxonomy source then 3 sub-queues will be created -- one for each term.

在您的博客上,您将拥有多个系列文章(您将其称为通用主题)。每个系列将独立于另一系列。每个系列将包含2个或更多博客的列表。重要的是要注意,在我提出的解决方案中,只有一个博客才能成为1系列的一部分 - 我希望是可以的。我们正在使用基于Nodequeue的解决方案,因为您要求系列中的博客列表的顺序很重要,必须保留。

On your blog you will have multiple series of articles (you call it articles with a "common subject"). Each series will be independent from another series. Each series will contain lists of 2 or more blogs. It is important to note that in my proposed solution it will only be possible for a blog to be part of 1 series -- I hope that is ok. We are using a Nodequeue based solution because of your requirement that order of listing of the blogs in the series is important and has to be preserved.

首先,您需要创建一个词汇(让我们称之为系列)。每次创建一系列新的博客时,您将创建一个新的分类术语,例如 Apache Solr教程系列 CSS提示和技巧系列等。确保系列词汇适用于您的博客内容类型。

First you will need to create a vocabulary (lets say we call it Series). Every time you create a new series of blogs you will create a new taxonomy term e.g. Apache Solr Tutorials Series, CSS Tips and Techniques Series etc. Make sure that the Series vocabulary is applicable to your blog content type.

您现在需要创建分类排队。只需在模块列表中启用 Smartqueue Taxonomy 。它附带标准的Nodequeue模块。单击内容管理>节点队列>分类法队列。命名队列我的列表。确保您选择系列作为词汇。您可以将队列的长度保持为 0 (无限制),因为每个系列的博客都可以有任意数量的博客。现在:

You now need to create taxonomy queue. Simply enable Smartqueue Taxonomy in the modules list. It comes with standard Nodequeue module. Click on Content Management > Nodequeue > taxonomy queue. Name the queue My Lists. Make sure you select Series as the Vocabulary. You can leave the length of the queue to be 0 (unlimited) because each series of blogs can have any number of blogs in it. Now:


  1. 链接添加到队列文本: put 添加到%subqueue

  2. 链接从队列文本中删除: put 从%子队列中删除

  1. Link "add to queue" text: put Add to %subqueue
  2. Link "remove from" queue text: put Remove from %subqueue

这是一个方便的事情。它将为每个博客节点的底部提供链接,以从相应的分类法队列中添加或删除。因此,如果博客文章已经获得了分类术语 CSS Tips and Techniques ,它将在完整节点页面的底部获得链接(甚至是预告片视图),因此可以将 CSS Tips and Techniques subqueue添加到我的列表 nodequeue中。

This is sort a convenience thing. It will give you links at the bottom of each blog node to add or remove from the appropriate taxonomy queue. So if a blog article has got the taxonomy term CSS Tips and Techniques it will get a link at the bottom of the full node page (or even teaser view) so it can be added it to the CSS Tips and Techniques subqueue in the My Lists nodequeue.

完成分类排队的设置。

This completes the setup for taxonomy queues.

现在我们来看看附件。请在启动视图附件模块之前启用。基本上视图附加在节点末尾附加一个视图。在我们的例子中,我们的观点将是其他文章的列表(只有博客是系列的一部分)。

Now we get to Views attach. Please enable the views attach module before proceeding. Essentially Views attach attaches a view at the end of the node. In our case our view will be a listing of other articles in the series (only if the blog is part of a series).

我们基本上需要通过节点的分类术语到视图。此分类术语将在我的列表 nodequeue中选择适当的子队列。该子队列中的所有项目将按照您指定的确切顺序(通过标准Nodequeue界面)显示。

We will essentially need to "pass" the taxonomy term of the node to the view. This taxonomy term will select the appropriate subqueue in the My Lists nodequeue. All items in that subqueue will be shown in the exact order as specified by you (via the standard Nodequeue interface).

进行视图的步骤。


  1. 让我们调用视图 display_other_blogs_in_series

  2. 添加节点内容(启用视图附加后可用)的显示。这是一个显示器,就像块和页面显示一样,但具有将其自身附加到节点的特殊功能。

  1. Lets call the view display_other_blogs_in_series.
  2. Add a display of type Node Content (available after enabling Views attach). This is a display just like block and page displays but with special ability of attaching itself to the node.

在节点内容显示

Make the following settings in the Node Content Display

Node content settings
Node types: blog
Build modes: Teaser, Full node
Arguments: token
Show title: No

您应该选择在视图附加到的参数的参数下使用令牌。令令牌为 [term-id] 这是顶级分类术语的ID。这个非常重要!!本质上,您将要从系列词汇表(例如CSS Tips and Techniques)中将博客节点的分类术语作为参考。为了实现这一点,系列词汇必须具有最低的权重。 (见 http://groups.drupal.org/node/11788#comment-38332)。如果它具有最低的权重,则分类词汇将是您节点编辑表单分类法部分的第一个词汇。

You should select Use tokens from the node the view is attached to under Arguments. Let the token be [term-id] This is the "ID of top taxonomy term". This is very important!! Essentially you are going to be passing the taxonomy term of the blog node from the Series vocabulary (e.g. CSS Tips and Techniques) as an argument to the view. For this to happen the Series vocabulary must have the lowest weight. (See http://groups.drupal.org/node/11788#comment-38332). If it has the lowest weight, the taxonomy vocabulary will be the first vocabulary in the taxonomy section of your node edit form.

现在我们需要告诉我们的视图来获取项目仅从我的列表队列。添加关系 Nodequeue:Queue 。确保 [x]需要此关系被选中。确保 [x]以我的列表作为队列选择限制到一个或多个队列

Now we need to tell our View to take items only from the My Lists queue. Add a relationship Nodequeue: Queue. Make sure [x] Require this relationship is selected. Make sure [x] Limit to one or more queues is selected with My list as the queue.

添加参数 Nodequeue:Subqueue Reference 。确保关系是 queue ,即我们上面定义的关系。这个参数将是系列词汇表中的分类术语。此参数将导致选择正确的子队列。

Add an argument Nodequeue: Subqueue Reference. Make sure the Relationship is queue i.e. the relationship we defined above. This argument is going to be the taxonomy term from the Series vocabulary. This argument will cause the correct subqueue to be selected.

添加您感兴趣的字段,例如节点:标题。确保 Node:Title 通过点击链接到超级链接将该字段链接到其Node

Add the fields you are interested in e.g. Node: Title. Make sure the Node: Title is made into a hyperlink by ticking Link this field to its Node

添加 Nodequeue:Position 作为排序条件。确保排序顺序升序,并确保使用关系 queue

Add Nodequeue: Position as the sort criteria. Make sure the sort order is ascending and make sure the relationship queue is used.

在过滤器中,确保您添加 Node:Type = blog 作为过滤器。

In filters, make sure you add Node: Type = blog as your filter.

所以这个视图将要做的是: p>

So what this view is going to do is:


  1. 从当前正在查看的节点中的系列词汇表中取出分类术语

  2. 将其作为参数传递给视图 display_other_blogs_in_series

  3. 视图将使用该参数来选择我的列表中的适当子队列队列

  4. 子队列中的项目将按照您指定的顺序逐个列出

  5. 在每个特定系列的博客中都会正确显示

  1. Take the taxonomy term from the Series vocabulary in the Node that is currently being viewed
  2. Pass that as argument to the view display_other_blogs_in_series
  3. The view will use that argument to select the appropriate subqueue in the My Lists queue
  4. The items in the subqueue will be listed one by one exactly in the order you have specified
  5. This will appear correctly in every blog that is part of a particular series

Postscript:
如果您使用的是Views 3(目前在撰写本文时为alpha3) 你想要一个块(现在是关联的) d文章来到节点主体的末尾),您可以按以下方式执行:

Postscript: If you're using Views 3 (currently at alpha3 at the time of writing) and you want a block (right now the related articles come at the end of node body) you can do it in the following fashion:


  1. 忘记关于视图附加...它的需要

  2. 添加块视图。它应该包含与节点内容显示的上述说明相同的参数,关系,字段和过滤器。

  3. 您需要修改参数的设置 Nodequeue:Subqueue Reference 只是稍微:如果参数不存在,采取的动作:选择 [x]提供默认参数。从URL 中选择 [x]分类标准ID。现在请确保 []从术语页面加载默认参数被取消选择,并且 [x]从节点页面加载默认参数,这对于相关的分类模块是非常有用的。 另外 [x]通过词汇限制术语,并选择系列词汇表。

  4. 确保您命名该块并将其放在适当的区域。

  1. Forget about views attach... its not required
  2. Add a block view. It should contain the same arguments, relationships, fields and filters as the instructions above for the Node Content display.
  3. You need to modify the settings for the argument Nodequeue: Subqueue Reference just slightly: Under Action to take if argument is not present: choose [x] Provide Default Argument. Choose [x] Taxonomy Term ID from URL. Now make sure [] Load default argument from term page is unselected and [x] Load default argument from node page, thats good for related taxonomy blocks. Also [x]Limit terms by vocabulary and choose the Series vocabulary.
  4. Make sure you name the block and put it in the appropriate region.

这篇关于如何在包含的节点上显示NodeQueue块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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