开发者

Drupal 7 Views 3: Exposed Filters that search specific FIELDS

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 c开发者_如何学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 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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜