Drupal 7 视图 3:搜索特定字段的公开过滤器

发布于 2024-12-01 19:32:52 字数 2628 浏览 1 评论 0原文

我真的很感激一些帮助。

我正在尝试在视图中创建两个不同的公开过滤器。我目前有 6,000 个节点,每个节点有 75 个字段,属于一种内容类型。我正在使用带有块中公开表单的页面视图。我还安装了“更好暴露的滤镜”模块。

第一个,我想创建一个用于搜索术语的文本框,但让它只搜索我指定的字段。我想让它搜索 3 个字段(对全名进行搜索):名字、中间名、姓氏。他们都在不同的领域。 到目前为止,我唯一能够搜索的是内容类型中的每个术语(它搜索每个字段,而不仅仅是名称)。我通过公开此过滤器来做到这一点:

Search: Search Terms
The terms to search for.

我尝试执行的下一个过滤器是针对“毕业班级”字段的。最好也为此进行搜索词(如果我能弄清楚如何搜索一个字段,如上所示),但我希望有一个选择下拉列表,列出每个毕业班级。该领域的这些班级从 1905 年到 1972 年。当您单击此框中的年份时,它会按该年份过滤当前结果。

这听起来很基本,但我似乎无法理解它,并且非常感谢一些帮助。

以下是我可以添加的过滤器类型,供您参考(如果需要)。 (题外话:我实际上不太确定“:format”到底是什么)。对于“内容:”过滤器,我将仅显示“名称”过滤器,因为还有其他 73 个过滤器。其中许多过滤器来自 Feeds 模块,因为这是我用来导入节点的模块:

Content: First Name (field_cinfo_fname)
Appears in: node:cadet.

Content: First Name (field_cinfo_fname:format)
Appears in: node:cadet.

Content: Middle Name (field_cinfo_mname)
Appears in: node:cadet.

Content: Middle Name (field_cinfo_mname:format)
Appears in: node:cadet.

Content: Last Name (field_cinfo_lname)
Appears in: node:cadet.

Content: Last Name (field_cinfo_lname:format)
Appears in: node:cadet.

Content access: Access
Filter for content by view access. Not necessary if you are using node as your base table.

Content revision: Log message
The log message entered when the revision was created.

Content revision: Title
The content title.

Content revision: Updated date
The date the node was last updated.

Content revision: Vid
The revision ID of the content revision.

Feeds item: Import date
Filter on a Feeds Item's import date field.

Feeds item: Item GUID
Filter on a Feeds Item's GUID field.

Feeds item: Item URL
Filter on a Feeds Item's URL field.

Feeds item: Owner feed nid
Filter on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.

Feeds log: Feed node id
Filter on a Feeds Source's feed_nid field.

Feeds log: Importer id
Filter on an importer id.

Feeds log: Log time
The time of the event.

Feeds log: Request time
The time of the page request of an event.

Feeds log: Severity
Filter on the severity of a log message.

Feeds source: Feed node id
Filter on a Feeds Source's feed_nid field.

File Usage: Entity type
The type of entity that is related to the file.

File Usage: Module
The module managing this file relationship.

File Usage: Use count
The number of times the file is used by this entity.

Page Title: Title
A Page Title alternative to the Node: Title field.

Search: Links from
Other nodes that are linked from the node.

Search: Links to
Other nodes that link to the node.

Search: Search Terms
The terms to search for.

I'd really appreciate some help with this.

I'm trying to create two different exposed filters in Views. I currently have 6,000 nodes with 75 fields each inside one content type. I'm using a Page View with an exposed form in a block. I also have the Better Exposed Filters module installed.

The first one, I want to make a text box for searching terms, but have it only search my specified fields. I would have it search 3 fields (to do a search on the full name): First Name, Middle Name, Last Name. They are all in different fields. The only thing I've been able to make it search so far is EVERY TERM in a content type (where it searches every field, not just name). I did that by exposing this filter:

Search: Search Terms
The terms to search for.

The next filter I am trying to do is for the field "Graduation Class." It might be best to do search terms for this too (if I can figure out how to search ONE field, like above), but I was hoping to have a select dropdown that lists every Graduation Class. These classes in this field range from 1905-1972. When you click a year in this box, it filters the current results by that year.

This sounds pretty basic, but I can't seem to get it and would REALLY appreciate some help.

For your reference (if needed), here are the types of filters I can add. (Off topic: I'm actually not so sure what the ":format" ones exactly are). For the "Content:" filters, I'll only show the "Name" ones, because there are 73 others. Many of these filters are from the Feeds module, because that's what I used to import my nodes:

Content: First Name (field_cinfo_fname)
Appears in: node:cadet.

Content: First Name (field_cinfo_fname:format)
Appears in: node:cadet.

Content: Middle Name (field_cinfo_mname)
Appears in: node:cadet.

Content: Middle Name (field_cinfo_mname:format)
Appears in: node:cadet.

Content: Last Name (field_cinfo_lname)
Appears in: node:cadet.

Content: Last Name (field_cinfo_lname:format)
Appears in: node:cadet.

Content access: Access
Filter for content by view access. Not necessary if you are using node as your base table.

Content revision: Log message
The log message entered when the revision was created.

Content revision: Title
The content title.

Content revision: Updated date
The date the node was last updated.

Content revision: Vid
The revision ID of the content revision.

Feeds item: Import date
Filter on a Feeds Item's import date field.

Feeds item: Item GUID
Filter on a Feeds Item's GUID field.

Feeds item: Item URL
Filter on a Feeds Item's URL field.

Feeds item: Owner feed nid
Filter on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.

Feeds log: Feed node id
Filter on a Feeds Source's feed_nid field.

Feeds log: Importer id
Filter on an importer id.

Feeds log: Log time
The time of the event.

Feeds log: Request time
The time of the page request of an event.

Feeds log: Severity
Filter on the severity of a log message.

Feeds source: Feed node id
Filter on a Feeds Source's feed_nid field.

File Usage: Entity type
The type of entity that is related to the file.

File Usage: Module
The module managing this file relationship.

File Usage: Use count
The number of times the file is used by this entity.

Page Title: Title
A Page Title alternative to the Node: Title field.

Search: Links from
Other nodes that are linked from the node.

Search: Links to
Other nodes that link to the node.

Search: Search Terms
The terms to search for.

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

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

发布评论

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

评论(2

牵强ㄟ 2024-12-08 19:32:52

我可能不太理解你,但你不想使用:

Content: First Name (field_cinfo_fname)
Content: Middle Name (field_cinfo_mname)
Content: Last Name (field_cinfo_lname)

作为你的过滤器吗?

我猜你的字段是文本区域,这就是为什么你有 :format 选项; “格式”是长文本字段类型中的另一列,因此可用(就像“alt”和“标题”可用于图像字段类型一样)。

I might be mid-understanding you but don't you want to use:

Content: First Name (field_cinfo_fname)
Content: Middle Name (field_cinfo_mname)
Content: Last Name (field_cinfo_lname)

as your filters?

I'm guessing your fields are text areas which is why you've got the :format options; 'format' is another column in the longtext field type so will be available (just like 'alt' and 'title' would be available for an image field type).

可爱暴击 2024-12-08 19:32:52

如果我正确理解了这个问题,那么您有三个名称字段,并且您需要一个文本框来搜索所有三个字段。最简单的方法是将这三个字段合并为一个不显示的字段,但可以使用公开的过滤器进行搜索。一种选择是使用 Auto Nodetitle 模块使节点标题成为三个名称的组合。 (我经常对人员目录执行此操作,以便给定条目显示为姓氏、名字)。然后您可以在公开的过滤器中搜索节点标题。

如果您的项目不适合使用标题,您可以向内容类型添加另一个字段,例如:full_name,并编写一个小模块来实现 hook_node_save 每当保存节点时,它都会简单地在 full_name 字段中填写“first middle last”。然后从显示中删除 full_name 字段并将其用于公开的过滤器。

回复:毕业年份:如果您使用“列表(整数)”字段类型,那应该没问题。如果您使用纯文本字段类型,那么事情就会变得更加困难。如果您使用纯文本,您可能需要重做该字段,以便可以执行很酷的过滤器,例如“1950 年之前毕业”类型过滤器或使用 jQuery 滑块选择毕业年份范围。

希望有帮助。

If I understand the question correctly, you've got three name fields and you want a single text box to search all three fields. The easiest way to do this is to combine those three fields into a single field that is not displayed but can be searched using an exposed filter. One option is to use the Auto Nodetitle module to make the node title a combination of the three names. (I do this a lot with personnel directories so that a given entry displays as Lastname, Firstname). Then you could search on a the node title in your exposed filter.

If using the title is not an option for your project, you could add another field to your content type, eg: full_name, and write a small module to implement hook_node_save that would simply fill in the full_name field with "first middle last" whenever a node is saved. Then remove the full_name field from the display and use it for your exposed filter.

re: graduation year: If you're using a "List (Integer)" field type, that should be no problem. If you're using a plain text field type, that makes things more difficult. If you are using plain text, you may want to redo the field so that you could do cool filters such as "graduated before 1950" type filters or using jQuery sliders to select a range of graduation years.

Hope that helps.

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