Page 1 of 1

Issue when Changing Search Box Location

Posted: Sun Aug 13, 2017 5:37 am
by rowinzy
I am having a hard time figuring this one out. So, I duplicated the default theme in order to create a custom one. I have moved the search box from the header to a new location and the search is not working at all. It is not getting the value for the search input field. How does the search box work?

Here is my 'search.twig' file:

Code: Select all

<div id="search">
  <input type="text" name="search" value="{{ search }}" placeholder="{{ text_search }}" />
  <button type="button" class="search-btn">{{ text_search }}</button>
Here is the 'javascript' code:

Code: Select all

$('#search input[name=\'search\']').parent().find('button').on('click', function() {
		var url = $('base').attr('href') + 'index.php?route=product/search';
		var value = $('#search input[name=\'search\']').val();
		//console.log(value); //value is empty!!
		if (value) {
			url += '&search=' + encodeURIComponent(value);
		location = url;
I have no clue what might be going wrong. Why is 'var value' returning empty? Can someone please help me out?

Re: Issue when Changing Search Box Location

Posted: Tue Aug 15, 2017 12:57 am
by cyclops12
Have you copied the code for the search from the controller/common/header to your new location ?