Post by Tallowman » Thu Oct 20, 2011 10:50 pm

Hi all.

Have a done a few themes myself, but in this new one, thought I'd get fancy. I have put in a jquery slider div on the left side of the screen that contains the currency changer and the search box. You know the type, little tab, you click on it and a div slides out nicely from the side of the screen with loads of goodies on it.

Only problem is, the search function has stopped working. Currency is fine.

Pressing enter after entering a search term and nothing happens. Click on the search icon and it tries to take me here:

undefinedindex.php?route=product/search&filter_name=hello

After searching the forums for a while, it does seem that there are a few problems with moving the search function. I tried a module that allows me to put the search function anywhere, but i can't put it in my custom slide-in div.

I would have thought that it might be an issue with the javascript not finding the element prorperly? But then I don't see any errors in my console.

Bit baffled. Any help appreciated. I'm on opencart 1.5.1.3

Cheers.
Last edited by Tallowman on Fri Oct 21, 2011 4:47 pm, edited 1 time in total.

Newbie

Posts

Joined
Thu Oct 06, 2011 7:14 pm

Post by JAY6390 » Fri Oct 21, 2011 1:26 am

Chances are whatever is undefined is set in the header controller, and you're using it outside of the header template. is that the case?

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Tallowman » Fri Oct 21, 2011 4:41 am

Unfortunately not, still in the header template, but outside the header div. I put the slide-in div straight after the body tag, before the header.

Worryingly though, when I put the Search chunk of code back where it was, it's still not working. So I removed the js that's been added, and still not working.

Gah. How does the search function work? Trying to get to the bottom of it, but can't see where it sources in the link... Will have a good look at the header controller though. Good place to start again!

Newbie

Posts

Joined
Thu Oct 06, 2011 7:14 pm

Post by JAY6390 » Fri Oct 21, 2011 4:44 am

Generally the search is just a call to the product/search route, and the query is passed along to the page. Do you have a link to the site?

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Tallowman » Fri Oct 21, 2011 4:03 pm

That's what I don't get about it breaking - I imagine that the search route is called by some js somewhere as it's not in the html, but without being familiar with the opencart js structure, there's a lot to look through!

Lin k to site - 'fraid not, it's on my xampp set up. I think I'm going to back it out and then put back in slowly, see where it breaks. If still don't get anywhere then will put live I reckon, see if anyone can make anything of it :-\

Newbie

Posts

Joined
Thu Oct 06, 2011 7:14 pm

Post by Tallowman » Fri Oct 21, 2011 4:25 pm

Nearly Solved...

I forgot to echo out the base href, so that explains why it was going to the wrong place. Now it doesn't work after pressing return, only when I click on the icon. No great shakes, sure I'll figure it out.

cheers,
Tallowman

Newbie

Posts

Joined
Thu Oct 06, 2011 7:14 pm

Post by uksitebuilder » Fri Oct 21, 2011 4:30 pm

look in catalog/view/javascript/common.js

you should have the following or similar

Code: Select all

	$('#header input[name=\'filter_name\']').keydown(function(e) {
		if (e.keyCode == 13) {
			url = 'index.php?route=product/search';
			 
			var filter_name = $('input[name=\'filter_name\']').attr('value')
			
			if (filter_name) {
				url += '&filter_name=' + encodeURIComponent(filter_name);
			}
			
			var myString = filter_name.replace(/^\s+|\s+$/g, '');
			if (myString.length > 1) {
				location = url;
			}
		}
	});	
If you have moved the search to a different div, try changing #header to the id of your div where it now resides.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Tallowman » Fri Oct 21, 2011 4:46 pm

Was just coming back to say I'd found the js! Cheers UKSB, that's exactly what I've done and it works perfectly now.

:)

Newbie

Posts

Joined
Thu Oct 06, 2011 7:14 pm

Post by eleven28 » Wed Mar 14, 2012 8:26 am

@uksitebuilder

You mean after all that, all I needed to do was change one little word in the common.js file!? <weak smile>

Ah well, it works now. Thanks.

User avatar
Newbie

Posts

Joined
Fri Jan 27, 2012 6:41 am
Location - Australia
Who is online

Users browsing this forum: Majestic-12 [Bot], Semrush [Bot] and 109 guests