I am new to RoR, and I wonder how I can do a google search by using a field in view of my project, anyone know how I could do that?
I have in my application.html.haml the code :
%form#search
%input
How can i implement this?
Set the action of your form to http://www.google.com/search, the method to get, and name your input field q. Something like the following:
%form#search(action="http://www.google.com/search" method="get")
%input(type="text" name="q")
%input(type="submit")
The result will be the normal URL for google searches with the results displayed:
http://www.google.com/search?q=term1+term2
Related
I have this website of my client made by someone in prestashop which has search input, and after searching for an item it will display a list of matching products, each linking to its page with a url looking like this:
www.website.com/category/full-product-name.html?search_query=search_phrase&results=2
Where a regular url of the product page looks like this:
www.website.com/category/full-product-name.html
The problem is now the google indexes the duplicated urls as separate pages.
I've never worked with prestashop before but I've looked into the template files and found something what I'd assume is file responsible for generating the content with line responsible for the link looking like this:
<a class="product_img_link" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url">
Now as I don't know much about prestashop I don't want to blindly change stuff. How could I change it to have the links from the search results have the same structure as the normal product page urls?
Well I don't know what's the point of allowing search engines indexing search pages but the problem is here. For whatever reason the developers decided to include query string into search result links.
You can create an override of search controller (or custom search module would be even better) and throw that line out and you should have normal product links.
Good Day All
I am completely new to this type of query but is it possible to define a url on a button click on a page that populates the/a URL with information form the Google Tag stack? e.g. Campaign, Source etc?
Sorry for the vague question.
Here are the two method that you can use to create a GA Attributes tagged url
https://support.google.com/analytics/answer/1033867?hl=en
&
http://www.utm.io/
EDIT: The solution turned out to be along these lines:
public function executeIndex(sfWebRequest $request)
{
if ($request->getParameter('first_name')) {
$this->setFilters(array('first_name' => $request->getParameter('first_name')));
}
parent::executeIndex($request);
}
Hi,
So, I've just started using symfony admin generator and it's great. But, I want to know, how I can I filter the lists using a GET request? e.g. /users?name=Simon
If I try: /users/filter/action/users[name]/Simon
It complains there is no CSRF token, because usually you filter by using the filter form it generates for you.
All I want to do is create links from one list to the other. e.g. clicking "See this User's Posts" in each user list record will send you to the Posts screen but with it filtered by this user.
I wouldn't be surprised if this could actually be done by the generator.yml but I don't know how, yet.
Thanks in advance for any assistance you can provide.
My answer here explains what you need: symfony - admin module filters accessible as links
I have tried embedding the filter form of the "target" table in the main table from which you would like to be redirected hidding everything but the filter button. As you have mentioned it does not always work without the token.
Is it possible to pass a search variable into the Google Custom Search Engine that I have embedded on my website? I can get the search engine to work, but I can't pass it a term via POST (it's coming from a search button on other pages of the website)
I tried to hack the code I found here: http://code.google.com/apis/ajax/playground/?exp=search#hello_world
And this is what I have so far... ($q is the term I am passing to it)
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
function OnLoad()
{
var customSearchControl = new google.search.CustomSearchControl('***my key****');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
searchControl.execute("$q");
}
google.setOnLoadCallback(OnLoad);
</script>
Thanks
Sorry, I know it's a crappy answer, but you've actually got it right apart from referencing the wrong variable name. Oh, also, as an aside, I would also hope you're doing some kind of sanitisation on $q, in case someone posted something like this to your form: term"); alert("aha!
customSearchControl.draw('cse');
searchControl.execute("$q");
should be:
customSearchControl.draw('cse');
customSearchControl.execute("$q");
Also, thank you for the question - I was looking for how to do this myself!
This is to help anyone using PHP trying to accomplish this same goal. The example above uses...
customSearchControl.execute("$q");
to read the parameter being passes in. On a PHP site you would use...
customSearchControl.execute("<?php echo $_POST['your_paramter_name_here'];?>");
You could use $_GET or $_REQUEST if your parameter is not in the post.
Of course you should should sanitize the input first. Something like this is pretty weak but it's a start...
customSearchControl.execute("<?php echo htmlentities( trim( $_POST['your_paramter_name_here'] ), ENT_QUOTES );?>");
In case someone is looking for a bit more straight forward / simple solution. All you have to do is to pass search keywords into GET parameter named q (from your custom form into page where your GCS is), GCS will automatically use that search phrase.
Source: https://developers.google.com/custom-search/json-api/v1/using_rest
I am using Cakephp to perform a search through sphinx. I wanted to do modify the default structre of pagination links generated by cakephp
For example
From:
localhost/search/page:1/key1:google/key2:code
To:
localhost/search/key1:google/key2:code/page:1
I want the page number to appear at the end. Is there a way this can be done?
Any help appreciated
I would suggest that you modify the PaginatorHelper. I would recommend that you extend it and load it when Cake launches so that you dont modify the Cake file in cake/libs...
Then, wherever you want the output URL to be printed w/ the page number at the end, you'll need to modify the PaginatorHelper... I'd suggest you search for the page/# key/value pair. If you find it, remove it, then append it to the end of the string. Then return that value.
Edit: link to PaginatorHelper in the API - http://api.cakephp.org/class/paginator-helper