自定义克隆搜索 [英] Customize Plone search

查看:95
本文介绍了自定义克隆搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个较小的Intranet中使用了Plone 4.3,搜索过程使我感到很烦. 实时搜索工作正常,但按Enter键时,搜索将显示不同的结果.可以通过在文本末尾添加""来获得结果,然后显示与实时搜索相同的结果. 所以我问,是否有可能在pushin输入键时自动插入""以达到与livesearch相同的结果?

I'm using Plone 4.3 in a little intranet and the search fiel makes me feel annoying. Live search works fine but when you push enter, the search shows different results. The results can be obtained by adding a "" top the end of the text and then it shows the same results as livesearch. So I ask, is ti possible to insert automatically a "" when pushin enter key in order to achieve the same results as livesearch?

谢谢

pd:对不起,我的英语不太好

pd: my english is not very good, sorry

推荐答案

由于实时搜索在用户输入字母时显示结果,因此使用开头的所有单词进行查询是有意义的当前术语(例如,如果您输入了"car",则结果中包含单词"car"但也包含小心",因为我们尚无法确定您是否已完成字母输入). 在高级搜索中,当您搜索汽车"时,系统会知道您对汽车"的结果感兴趣,而不是对小心"的结果感兴趣. 因此,这两个搜索的工作原理有所不同.

As live search is displaying results as the user is entering letters, it makes sense to perform a query for all words starting with the current term (for instance if you have entered "car", you get results containing the word "car" but also "careful", because we cannot tell yet if you have finished typing letters). In the advanced search, when you search for "car", the system knows you rae interested in results about "car", not about "careful". So that's why the 2 searches work differently.

Plone假设在实时搜索中按Enter键时,我们已经完成了要查找的单词的输入,因此它将使用我们输入的确切搜索词重定向到高级搜索页面.

And Plone assumes that when we press Enter in the livesearch, we have finished entering the word we are looking for, so it redirects to the advanced search page using the exact search term we have entered.

它是在搜索框视图中实现的,您可以在plone.app.layout/plone/app/layout/viewlets/searchbox.pt中找到代码,并且可以看到,它是一种非常基本的形式,将"SearchableText"输入提交到"@@ search".

It is implemented in the searchbox viewlet, you will find the code in plone.app.layout/plone/app/layout/viewlets/searchbox.pt, and as you can see it is a very basic form submitting the "SearchableText" input to "@@search".

对我来说,最简单的自定义方法是在您的皮肤中的某个地方添加一个像这样的小JS:

To me, the easiest way to customize it is to add a small JS like this somewhere in your skin:

$('#portal-searchbox form').submit(function(e) {
    var input = $('#portal-searchbox input[name="SearchableText"]');
    input.val(input.val() + '*');
});

这篇关于自定义克隆搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆