简体   繁体   中英

Drupal search only titles

Is there a way for the Drupal search to only search article Titles and Tags.. not the content of the article? Possibly with the Views Module?

I am using Drupal 7. I do have Views installed and Views Search does not work on Drupal 7.

Create a View to search using Title of the Content (page,story,blog,article,book)

Step 1 : Click on Administer

Step 2 : Click on views

Step 3 : Click on Add

Step 4 : Fill in details for 'View name:' , 'View type: ' select 'Node' and hit 'Next' button.

Step 5 : Select 'Page' from dropdown on first column and click on 'Add display' button.

Step 6 : Under 'Basic settings' you can Select Name click 'page' and see below change the name from 'page' to say 'Search_Content' and push the 'update' button.

Step 7 : Under 'Page settings' you can Select Path click 'None' and see below change the name from 'Path' to say 'search_content' and push the 'update' button.

Step 8 : Under 'Page settings' you can Select Menu click 'No menu' and see below select 'Normal menu entry' give 'Title:' for text-field say 'Search' and select a Menu Link: 'Primary links' and push the 'update' button.

Step 9 : Now click the '+' link near 'Fields' column.

Step 10 : Now select 'Node' under 'Groups:' and select 'Node : Title' and click 'Add' button.

Step 11 : You can remove the text from 'Label:' Text-field and make the Text-field blank.

Step 12 : Click the 'Save' button below. Note all these changes are 'temporary' till when you dont press the 'Save' button below.

Step 13 : You will see a new menu link would be created click on it and check the list of

Step 14 : Edit the Search_Content

Step 15 : Now click the '+' link near 'Filters' column.

Step 16: Now select 'Node' under 'Groups:' and select 'Node: Title' and click 'Add' button.

Step 17: Now You will see 'Expose' button and push the 'update' button.

Step 18: Click the 'Save' button below. Note all these changes are 'temprory' till when you dont press the 'Save' button below.

Step 19: Click on same button with menu links the list of Content titles will be listed with Search bar.

That should be a good start..... ref

There's no way using the views UI to search for both using the same textfield. You have to code for that.

The best result you can take with just the UI consists of exposing two different filters, one for the title and one for the tag. I suggest an autocomplete filter for both, this will give the user good flexibility.

Edit:

With the UI: you have to edit the view, add a new filter, choose "title" and then expose it. Then you have to repeat the same for tags.

With the code you have to look at the documentation as it's not trivial to write it here in a few lines of code and it's strictly related to what you're likely gonna do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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