Sharepoint search with 'this site' suffix - html

I'm trying to create a team site (which is mostly links to other sources) in HTML with CSS. That part is going fine, but I would like to integrate a search of our SharePoint site, it includes 000s of documents that'd be great to make more accessible.
Found:
<form method="get" action="<SharePoint-search-results-page-URL>">
<input name="k" type="text" />
<input name="Search" type="submit" value="Search" />
</form>
(http://blogs.msdn.com/b/zwsong/archive/2010/02/16/how-to-create-a-html-search-box-for-sharepoint-search.aspx)
This is working, but the way our Sharepoint is setup I am actually searching the whole database of files, not just our subsite. I have tried changing the URL so that it includes the sc and u flags, this will bring me to the same results, but have a 'this site' dropdown.
How can I concatenate the search url with the correct suffix when I submit the search?
Thanks

Related

On click of search button send user to new tab showing results from another site?

I am trying to create a search box on my site. However when someone clicks "search" or presses "enter/return". I want a separate tab to open with the search results from a different site to be displayed.
Example:
My site: www.example.com
# using another answer on stackoverflow
# I have tried a lot of different action urls.
# the website url to which I want to send the search:
<form method="get" action="website.com/?searchTerm">
<input type="text" name="searchTerm"/>
</form>
When I try to demo it using the above and press enter, I simply go to the website i.e. website.com/?searchTerm not the results page.
Another approach I thought might work is to replace the searchTerm in the url of the results page of the website when Enter or button is clicked on www.example.com using a tags.
You can use the target attribute on the form tag.
Don’t forget to inform your users, including screen reader users, that the action will open a new tab.
If you use the GET method, input names and values are going to be passed as query parameters. So <input name="searchTerm" value="test"> will become ?searchTerm=test in the requested URL.
get: The GET method; form data appended to the action URL with a ? separator. Use this method when the form has no side-effects.
<form method="get" target="_blank" action="https://example.com/SearchDisplay">
<label>Search Term
<input type="search" name="searchTerm">
</label>
<button type="submit">Search (opens in new tab)</button>
</form>
The above code would not work in an interactive stack snippet, because it would be inside an iframe.
For your search to actually work with the target site
If you inspect the search form on your target website, you’ll notice they use SearchDisplay as the action. Additionally, they include a bunch of hidden fields in their form. You will need to figure out which ones to include in your form as well, for your query to not get blocked.
Beware, though, that this are implementation details of the target shop, not a stable search API like OpenSearch. So it might change at any time, and your search form will no longer work.
The form code from the target website:
<form accept-charset="UTF-8" name="CatalogSearchForm" action="SearchDisplay" method="get" id="searchForm" class="searchForm">
<div class="search-input-wrapper" role="group" aria-label="...">
<div class="search-input-field">
<input type="hidden" name="storeId" value="5451206" id="WC_CachedHeaderDisplay_FormInput_storeId_In_CatalogSearchForm_1">
<input type="hidden" name="catalogId" value="10002" id="WC_CachedHeaderDisplay_FormInput_catalogId_In_CatalogSearchForm_1">
<input type="hidden" name="langId" value="-3" id="WC_CachedHeaderDisplay_FormInput_langId_In_CatalogSearchForm_1">
<input type="hidden" name="pageSize" value="10" id="WC_CachedHeaderDisplay_FormInput_pageSize_In_CatalogSearchForm_1">
<input type="hidden" name="beginIndex" value="0" id="WC_CachedHeaderDisplay_FormInput_beginIndex_In_CatalogSearchForm_1">
<input type="hidden" name="sType" value="SimpleSearch" id="WC_CachedHeaderDisplay_FormInput_sType_In_CatalogSearchForm_1">
…

How do i make my search bar actually search pages in my site?

I put a search bar into my website but I don't know how to make it actually search pages within my site. I don't want a google search bar where you can search anything. I already have the search bar in my site, but nothing happens when you press search. Help is much appreciated.
here is the html to my search bar:
<div class="search">
<form class="form-wrapper-2 cf">
<input type="text" placeholder="Search Yacht..." required>
<button type="submit">Search</button>
</form>
</div>
A somewhat straight forward suggestion if you don't want some type of Google Searchbar would be to run a script on submission of the form that searches the text in each of the web pages in your working directory to find a match, then display a page with links to the found matches.
I will use PHP for my description of how this is done.
With this in mind, first learn how to read entire pages (i.e. webpages) into a string:
http://php.net/manual/en/function.file-get-contents.php
//YOU WILL HAVE TO LINE THIS UP WITH YOUR WORKING FILE NAMES
$home = file_get_contents('./home.php', FILE_USE_INCLUDE_PATH);
or I suppose you could just search for the actual webpage/URL like so:
$home = file_get_contents('http://www.example.com/');//IMAGINE THIS IS REALLY HOME.PHP
$homePageName = "home.php";//JUST HERE TO SHOW AN EXAMPLE
Example:
///YOUR FORM/INPUT BOX
<form action="search.php" method="post">
<input type="text" name="findMe" placeholder="Search Yacht">
</form>
Now search.php
$search = $_POST['findMe'];
//$search = "example";//THIS WOULD WORK, BUT I WAS SHOWING HOW TO USE FORM
//IF WORD FOUND IN HOME PAGE
if (stripos($home, $search) !== false) {//USING EXAMPLE.COM TO SHOW IT WORKS
echo ''.$homePageName.'';
}
Then if you want to be simplistic and not use an array to store the found pages, take the same code above and use it for every page you want searched (i.e. home, about, products, etc..).
Now a user can search your site (or the pages you want indexed), to find all pages that have matching text. If you want specific keywords to be searched, just add them to the page metadata and the process I have described will still work as it searches everything that makes up the page.
<meta name="keywords" content="keyword1, keyword2, keyword3 " />
Here's the sample HTML form code for search bar:
<form id="sarchform" class="search2" method="get" action="source.html" />
<input class="search2" id="test" type="text" name="search" size="10" maxlength="255"/>
Here's the JS code:
<script type="text/javascript">
document.getElementById('searchform').onsubmit = function() {
window.location = 'http://www.google.com/search?q=site:yourdomainname ' + document.getElementById('test').value;
return false;
}
</script>
Mention your domain name in the code above and try implementing this.

Embedding a Google search bar into a html document

I'm creating an offline HTML document to set as my browser homepage for work. I'd like to include a Google search bar at the top of the page that will allow me to search Google directly.
Google seems to make it easy to embed a Google Custom Search Engine into the page which will let me use Google to search the local page, but I need it to redirect to Google and search there.
Their code:
<!-- Use of this code assumes agreement with the Google Custom Search Terms of Service. -->
<!-- The terms of service are available at http://www.google.com//cse/docs/tos.html -->
<form name="cse" id="searchbox_demo" action="https://www.google.com/cse">
<input type="hidden" name="cref" value="" />
<input type="hidden" name="ie" value="utf-8" />
<input type="hidden" name="hl" value="" />
<input name="q" type="text" size="40" />
<input type="submit" name="sa" value="Search" />
</form>
<script type="text/javascript" src="https%3A%2F%2Fcse.google.com%2Fcse/tools/onthefly?form=searchbox_demo&lang="></script>
Testing this form returns a Google results page with no results that changes the url to: google.com/cse?cref=&ie=utf-8&hl=&q=test&sa=Search#gsc.tab=0&gsc.q=test&gsc.page=1
Surprisingly, I couldn't find any answers on SO or various search engines. I tried to create a form, use GET, and redirect to https://www.google.com/search? and https://www.google.com/search?q= with no luck. It keeps changing the url search parameter following the ?
I know I'm overlooking something simple but can't find the answer anywhere.
Simply put, is Google preventing any search queries from offline documents in an effort to fight scripts/robots?
There is a good explanation of how to use Google Search for your own site or the entire web here.
Make sure that your <form> action is
<form method="get" action="http://www.google.com/search">
Set the variable sitesearch to null. (In the link example it is a radio button. Here you can just make it a hidden input.)
<input type="hidden" name="sitesearch" value="" />
Submit the form. (When you say "offline HTML document" realize that to redirect to the Google search results page you will need an internet connection.
I do a similar thing for my projects. I create simple pages with all the links and data that I need regularly. Easy links to hand when I open the browser.
This worked for me:
<script>
function SearchQuery(val) {
document.getElementById("searchButton").href = "https://www.google.com/search?q=" + val;
}
function buttonClick(){
document.getElementById("searchBox").value = "";
}
</script>
<section>
<input id="searchBox" type="text" name="searchBox" value="" onchange="SearchQuery(this.value)">
<a id="searchButton" href="https://www.google.co.uk/" target="_blank" onclick="buttonClick()">Search with Google</p>
<section>

HTML searching issue

So, HTML newbie here and am having an issue where I have a website that just hosts files. I have a working search function on the site in two places. One on the homepage where the search works perfectly fine. Once a search is inputed (searching 'pop' for instance), the url states:
http://website.com/?op=catalogue&k=pop&ftype=
But, on the second page, when I input a search term, it seems to add to the url and doesnt go anywhere. For example:
http://website.com/e2aqev6btnnv/head.jpg?op=catalogue&k=pop&ftype=
Instead of erasing the head.jpg file in the URL and accepting the new search term, it just adds it and the page doesn't go anywhere. Please help
Here is the code I have for the search:
<br>
<Form method="GET" action="">
<input type="hidden" name="op" value="catalogue">
<input type="search" onfocus="fieldReceivedFocus()" name="k" id="search" value="">
try this:
<Form method="GET" action="http://website.com">
what will tell it what page to send the form data to, in your case it is the main page, otherwise it sends it to the current page.
You MAY need to change
<input type="hidden" name="op" value="catalogue">
to
<input type="hidden" name="op" value="search">
I don't know how the backend of your site is coded but based on what I see in the urls i think you will need to.

Submitting to a remote .cfm file using an html form

I want visitors to my website to be able to search for airport lounges offered by a company called Priority Pass. I have created the following form:
<form action="http://prioritypass.com/lounges/lounge-print.cfm" method="post">
<input type="text" id="print_airport_code" name="print_airport_code" value="MAN" />
<input type="submit" value="Submit" />
</form>
Which mirrors the form they have on their own mobile search site (here). But when I submit my form it doesnt seem like the parameters are being posted properly.
Any help would be great. Thanks.
The form on their website doesnt appear to contain any fields which I have missed?
You're pointing to the wrong URL; POSTing to /lounges/lounge-print.cfm is producing an HTTP redirect header, which is corrupting your output.
Additionally, the name of your input field is incorrect. Using someone else's form results often requires you to maintain all field names consistently as they appear on the remote site.
Change the form to:
<form action="http://www.prioritypass.com/mobile/lounges.cfm" method="post">
<input id="Airport_Code" name="Airport_Code" type="text" size="10" value="MAN" />
<input type="submit" value="Submit" />
</form>