I'm using Google Custom Search with a CustomSearchControl to display search results for a website. I can get the search results localized, and can add a localized no results string without problems. However, I cannot get the search box itself to become localized, i.e. the "Search" button and "XXX results".
The Google documentation CustomSearchControl doesn't mention any way to achieve this. Isn't this possible?
Here is the code I'm using.
google.load('search', '1', {language : 'is', style : google.loader.themes.MINIMALIST});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('MY_ID');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.setNoResultsString("Ekkert fannst.");
customSearchControl.draw('cse');
var queryFromUrl = parseQueryFromUrl();
if (queryFromUrl) {
customSearchControl.execute(queryFromUrl);
}
}, true);
Official response from Google support
I would like to update that currently for custom search element V2 code, you can change the search engine language only from the control panel->Basics->Language section. Whatever language you select it will be the same in all of your multilingual sites. You can't have different languages in different sites. Currently we don't have any parameter such as "language" in the Google Site Search code snippet to customize the language.
In your case you can consider creating different search engine for different languages and change the Language setting in Control Panel --> Setup --> Basics --> Language in all the search engine respectively and share the query quota by adding the search engine in the Business group.
Once you do that all these free search engines will share the query quota of your master GSS search engine.
After that, you can configure each search engine with respective sites/URL pattern only and implement the specific search engines on respective sites.
Please review the document below to know about Language settings
https://support.google.com/customsearch/answer/2633296?hl=en
Please review the document below know about business group:
https://support.google.com/customsearch/answer/2633350?hl=en
With the CSE Element v2, the search button becomes an icon, so there is no need to localize, if you switch to v2.
Related
My aim is to add additional fields to the searching parameters for the internal search - I have amended ExamineIndex.config to index the new property:
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/">
<IndexUserFields>
<add Name="briefing"/>
</IndexUserFields>
</IndexSet>
However, after rebuilding the internal index, it seems as though the internal search is only using the node name.
Is it possible to search multiple properties with the internal search?
You are quite right - the Content and Media searches only take into account the Node Name, along with a path restriction if the current user has a starting node specified.
Member search also includes the following additional fields:
email
loginName
As a reference, see the implementation here:
https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Editors/EntityController.cs#L227-L283
If you want to implement a custom search, you'd have to create a plugin or dashboard that would allow you to implement the search features you want.
For some ideas, checkout the MemberListView project (which uses custom examine searching to populate the list): https://github.com/robertjf/umbMemberListView
I wanted to add a new search engine to be displayed in the drop down for search bar that appears in firefox nav-bar. And set this as the default searchEngine when user sets it through my extension's preferences.
For a non-restartless extension, through XUL, we use Components to do something like this:
Cc["#mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService).addEngineWithDetails(...); //Adds a new search engine
Cc["#mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService).currentEngine = ...; //sets the current search engine value.
How can I do something similar in a restartless extension created using Firefox addon-sdk? One problem I see is that there is no stable API to get and set firefox preferences listed at 'about:config'. But even if I use the unstable preferences service documented here, I am not able to do default search engine changes through extension. Help please!
Search in Firefox has two pieces you have to worry about.
First for the Search Input
You're actually going to use the same system for setting the search engine but you'll need to load the chrome module in the SDK.
var { Cc, Ci } = require("chrome");
var SearchService = Cc["#mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
// Add your engine to the list of engines in the drop down
SearchService.addEngineWithDetails('yoursearch', 'icon', 'yoursearchalias', 'your search description', 'get', 'http://stackoverflow.com/search?q={searchTerms}');
// Set your engine as the currentEngine so it's the default engine for the search input
SearchService.currentEngine = SearchService.getEngineByName('yoursearch');
Next for the URL bar
Update: As of Firefox 23 the keyword.URL preference has no effect, the above code will change the default behavior in both areas.
If you wanted to alter the search engine that's used for the URL bar you'll have to work with the user preferences.
var preferences = require('sdk/preferences/service');
// the 'search keyword' will be appended to the url you provide so strip out the
// {searchTerms} OpenSearch identifier
preferences.set('keyword.URL', 'http://stackoverflow.com/search?q=');
// When you want to set things back just reset the value
preferences.reset('keyword.URL');
Good luck!
I am building a website where the user should have the capability of adding their School/University. I have noticed in LinkedIn, when i tried to type in my school name , it showed up a auto search box with all the schools, beginning with the letter i typed. How can i achieve the same functionality?
Do they save all the Universities in their database ? Or is there any Open webservices i can use that will show all the Schools/Universities ?
Thanks !
This feature is called "Auto Complete" and the text boxes are enabled with that. These allow you to filter the data required according to the characters you type in.
Please see this post for auto-complete feature implemented using jQuery.
Razor: Auto-complete text box inside jqGrid, How to bind values?
The example shown in that page lists all from the database. However, as a next phase, you can as well extend this feature to look for a WCF exposed service for universe of schools/colleges.
FYI" "GetSkillNameAutocomplete" is a method in the controller that takes a string parameter as an input (the search string) and gets the value(s).
Hope this helps!
i have often seen websites which are indexed in search engines with a content like: Search now for "search query" ("search query" is the word I have entered in the search engine (for example Google)). So somehow they take the search query and put it into their title. Is there a possibility to do this and if yes, does Google like it or not?
Your page would need to use the HTTP referrer header to determine what the query to the search engine was. It could then use that information to determine what words to highlight on the page, include in the title, etc.
I've seen some websites highlight the search engine keywords you used, to reach the page. (such as the keywords you typed in the Google search listing)
How does it know what keywords you typed in the search engine? Does it examine the referrer HTTP header or something? Any available scripts that can do this? It might be server-side or JavaScript, I'm not sure.
This can be done either server-side or client-side. The search keywords are determined by looking at the HTTP Referer (sic) header. In JavaScript you can look at document.referrer.
Once you have the referrer, you check to see if it's a search engine results page you know about, and then parse out the search terms.
For example, Google's search results have URLs that look like this:
http://www.google.com/search?hl=en&q=programming+questions
The q query parameter is the search query, so you'd want to pull that out and un-URL-escape it, resulting in:
programming questions
Then you can search for the terms on your page and highlight them as necessary. If you're doing this server side-you'd modify the HTML before sending it to the client. If you're doing it client-side you'd manipulate the DOM.
There are existing libraries that can do this for you, like this one.
Realizing this is probably too late to make any difference...
Please, I beg you -- find out how to accomplish this and then never do it. As a web user, I find it intensely annoying (and distracting) when I come across a site that does this automatically. Most of the time it just ends up highlighting every other word on the page. If I need assistance finding a certain word within a page, my browser has a much more appropriate "find" function built right in, which I can use or not use at will, rather than having to reload the whole page to get it to go away when I don't want it (which is the vast majority of the time).
Basically, you...
Examine document.referrer.
Have a list of domains to GET param that contains the search terms.
var searchEnginesToGetParam = {
'google.com' : 'q',
'bing.com' : 'q'
}
Extract the appropriate GET param, and decodeURIComponent() it.
Parse the text nodes where you want to highlight the terms (see Replacing text with JavaScript).
You're done!