2011-08-26 43 views
2

我真的很感謝一些幫助。Drupal 7意見3:暴露過濾器,搜索特定的領域

我想在視圖中創建兩個不同的暴露過濾器。我目前有6,000個節點,每個節點有75個字段,每個節點在一個內容類型內我在一個塊中使用一個頁面視圖和一個暴露的表單。我也安裝了更好的曝光過濾器模塊。

第一個,我想打一個文本框中搜索條件,但有它只能搜索我指定的字段。我會讓它搜索3個字段(搜索全名):名字,中間名,姓氏。他們都在不同的領域。 目前我唯一能夠搜索到的內容是內容類型爲(其中它搜索每個字段,而不僅僅是名稱)的每個TERM。我通過公開這個過濾器來實現這一點:

Search: Search Terms 
The terms to search for. 

我想要做的下一個過濾器是字段「畢業班」。這也許是最好的搜索條件(如果我可以找出如何搜索一個領域,如上),但我希望有一個選擇下拉列出每個畢業班。這個領域的這些課程範圍從1905年至1972年。當您在此框中點擊一年時,它將在當年過濾當前結果。

這聽起來很基本,但我似乎無法得到它,並會真正感謝一些幫助。

爲了您的參考(如果需要),以下是我可以添加的過濾器的類型。 (離線主題:我實際上並不確定「:」格式的文件是什麼)。對於「Content:」過濾器,我只會顯示「名稱」過濾器,因爲還有73個過濾器。許多這些過濾器是從飼料模塊,因爲這是我用來導入我的節點:

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. 

回答

2

我可能是中期的瞭解你,但你不希望使用:

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

作爲你的過濾器?

我猜你的字段是文本區域,這就是爲什麼你有:格式選項; 'format'是longtext字段類型中的另一列,因此將可用(就像'alt'和'title'可用於圖像字段類型一樣)。

+0

Doh!我想每個人都建立他們的第一個Drupal站點。 – WebMW

0

如果我正確地理解了這個問題,那麼您有三個名稱字段,並且您想要一個文本框來搜索所有三個字段。最簡單的方法是將這三個字段組合成單個字段,但不能顯示,但可以使用暴露的過濾器進行搜索。一種選擇是使用Auto Nodetitle模塊將節點標題組合爲三個名稱。 (我在人員目錄上做了很多工作,以便給定的條目顯示爲姓氏,名字)。然後,您可以在暴露的過濾器中搜索節點標題。

如果使用標題不是您項目的選項,您可以爲您的內容類型添加另一個字段,例如:full_name,然後編寫一個小模塊來實現hook_node_save,該模塊只需填寫full_name字段爲「first middle最後「每當一個節點被保存。然後從顯示中刪除full_name字段並將其用於您的暴露過濾器。

re:畢業年份:如果您使用的是「List(Integer)」字段類型,那應該沒問題。如果您使用純文本字段類型,則會使事情變得更加困難。如果您使用的是純文本,您可能需要重做該字段,以便可以製作很酷的過濾器,例如「1950年之前畢業」類型的過濾器或使用jQuery滑塊選擇畢業年限範圍。

希望有所幫助。

相關問題