简体   繁体   English

Drupal仅搜索标题

[英]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? 有没有办法让Drupal搜索只搜索文章标题和标签,而不是文章内容? Possibly with the Views Module? 可能使用“视图”模块?

I am using Drupal 7. I do have Views installed and Views Search does not work on Drupal 7. 我正在使用Drupal7。我确实安装了Views,并且Views Search在Drupal 7上不起作用。

Create a View to search using Title of the Content (page,story,blog,article,book) 创建一个视图以使用内容标题(页面,故事,博客,文章,书本)进行搜索

Step 1 : Click on Administer 第1步:点击管理

Step 2 : Click on views 第2步:点击视图

Step 3 : Click on Add 步骤3:点击添加

Step 4 : Fill in details for 'View name:' , 'View type: ' select 'Node' and hit 'Next' button. 步骤4:填写“视图名称:”,“视图类型:”的详细信息,选择“节点”,然后单击“下一步”按钮。

Step 5 : Select 'Page' from dropdown on first column and click on 'Add display' button. 步骤5:从第一列的下拉菜单中选择“页面”,然后点击“添加显示”按钮。

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. 步骤6:在“基本设置”下,可以选择“名称”,然后单击“页面”,然后在下面看到将名称从“页面”更改为“ Search_Content”,然后按“更新”按钮。

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. 第7步:在“页面设置”下,您可以选择“路径”,单击“无”,然后看到下面将名称从“路径”更改为“ search_content”,然后按“更新”按钮。

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. 步骤8:在“页面设置”下,可以选择菜单,单击“无菜单”,然后在下面选择“普通菜单项”,在文本字段中输入“标题:”,然后说“搜索”,然后选择菜单链接:“主链接”,然后按下“更新”按钮。

Step 9 : Now click the '+' link near 'Fields' column. 步骤9:现在,点击“字段”列附近的“ +”链接。

Step 10 : Now select 'Node' under 'Groups:' and select 'Node : Title' and click 'Add' button. 步骤10:现在,在“组:”下选择“节点”,然后选择“节点:标题”,然后单击“添加”按钮。

Step 11 : You can remove the text from 'Label:' Text-field and make the Text-field blank. 步骤11:您可以从“标签:”文本字段中删除文本,并将文本字段留空。

Step 12 : Click the 'Save' button below. 步骤12:点击下面的“保存”按钮。 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 步骤13:您将看到将创建一个新的菜单链接,单击它并检查列表

Step 14 : Edit the Search_Content 步骤14:编辑Search_Content

Step 15 : Now click the '+' link near 'Filters' column. 第15步:现在,单击“过滤器”列附近的“ +”链接。

Step 16: Now select 'Node' under 'Groups:' and select 'Node: Title' and click 'Add' button. 步骤16:现在,在“组:”下选择“节点”,然后选择“节点:标题”,然后单击“添加”按钮。

Step 17: Now You will see 'Expose' button and push the 'update' button. 步骤17:现在您将看到'Expose'按钮并按下'update'按钮。

Step 18: Click the 'Save' button below. 步骤18:点击下面的“保存”按钮。 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. 第19步:单击带有菜单链接的相同按钮,内容标题列表将与搜索栏一起列出。

That should be a good start..... ref 那应该是一个好的开始..... ref

There's no way using the views UI to search for both using the same textfield. 无法使用视图UI来使用相同的文本字段搜索两者。 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. 仅使用UI即可获得的最佳结果包括公开两个不同的过滤器,一个用于标题,一个用于标签。 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. 使用UI:您必须编辑视图,添加新的过滤器,选择“标题”,然后将其公开。 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. 使用代码,您必须查看文档,因为在几行代码中将其编写起来并不容易,并且它与您可能要做的事情密切相关。

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

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