简体   繁体   English

有关Drupal节点和视图的问题

[英]A question about Drupal Node and Views

I have created an "Add Question" content-type node which lets users ask questions. 我创建了一个“添加问题”内容类型节点,该节点可让用户提出问题。 The questions have a title, image attachment option, and the content. 这些问题具有标题,图像附件选项和内容。

I am showing the questions which have image as a block by filtering it as "Content: Photofield - list True" in Views. 我通过在视图中将图像过滤为“内容:光场-列出真”来显示将图像作为块的问题。 This way, only the questions which have images attached to the question appear in this block. 这样,只有带有图像附加在问题上的问题才会出现在此块中。 Photofield by the way is the content type. 顺便说一下,Photofield是内容类型。

I want to create a new block which only shows the questions which have no attached image. 我想创建一个新块,仅显示没有附件图像的问题。 I have done filtering this block view by keeping filters as "Content: Photofield - list False" but in vain. 我已经通过将过滤器保持为“内容:光场-列表为假”来过滤此块视图,但徒劳无功。

There's also some expose option and I did some messing around with it too without coming to the result I want. 还有一些暴露选项,我也弄乱了它,而没有得到想要的结果。

Can anyone help? 有人可以帮忙吗?

The "Content: Photofield - list" filter only applies to nodes with an attached image, because it is filtering by the value of the "List" option (which only exists if there's an image). “内容:光场-列表”过滤器仅适用于具有附加图像的节点,因为它是根据“列表”选项(仅当有图像时才存在)的值进行过滤的。 If the node has no attachment, this filter won't do anything. 如果节点没有附件,则此过滤器将不执行任何操作。

As fas as I know, you'll need to either implement hook_views_query_alter() to add an WHERE clause to the View's query or programatically test if the node have an image in a view template. 据我所知,您将需要实现hook_views_query_alter()将WHERE子句添加到View的查询中,或者以编程方式测试该节点在View模板中是否有图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM