Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Addon] Twitter Typeahead Autocomplete Search for osC 2.3.4 (BS and nonBS)


auzStar

Recommended Posts

Hi Dom

 

Couldn't edit the above post.

What I noticed was that if I typed only 2 letters in the search box the  > show all results appeared as did the > advanced search, if I typed 3 letters then only the >Go to advanced search appeared.

I guess this maybe what is supposed to happen.

 

Cheers

 

Grandpa

Link to comment
Share on other sites

@@grandpaj

 

Hi John,

 

"> go to advanced search" always appears (unless you're actually at the "advanced search" page).

 

"> show all results" will only appear if the number of results found is more than the "Max Items in Autocomplete List" that you set in admin for the add-on.

(it's not just dependant on the number of characters you type, it depends on how many results are found in relation to what you type)

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

example:

 

If you type some characters and only 6 results display in the list, but the "Max Items in Autocomplete List" is set to 10, then "> show all results" will not appear, and it will say "Products found: (showing total of 6)" at the top of the list.

 

If on the other hand the number of results found is 18, then "> show all results" will appear, and it will say "Products found: (showing 10 of 18)" at the top of the list. Hence only 10 items will appear in the list, but to view all results you click "> show all results" which then re-directs you to the normal search results page which shows all 18 items. 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

You can adjust the setting "Max Items in Autocomplete List" depending on how many items you want to appear in the list. There is no need to increase this to a huge number if the "Sort List" option is set to "true" so that "the closest matching results are at the top". 

 

 

cheers

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

@auzStar

 

Nice addon but I have one problem.

when I type 2 letters ill see 12 products found.

now when I'm clicking on show all result nothing will show up.

it says no product are found??

 

b.t.w. I'm testing it on localhost

Edited by dinopacha
Link to comment
Share on other sites

@auzStar

 

Problem is gone in the real shop everythings ok. :thumbsup:

 

@@dinopacha

 

Must have been something wrong with your localhost setup as it did work for me on a localhost. :thumbsup:

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

Hi,

 

Could you help me with the accent problem ?

 

@@presentemusical

 

I haven't as yet come up with a solution to this. So for the moment I'll have to say that the add-on currently doesn't support accented characters.

 

Maybe it will in the next release.

 

cheers

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

@@auzStar

 

Dom...I'm wondering if you can point me in the right direction.  I was just trying to install your Twitter Typeahead Autocomplete Search addon and ran into a slight snag.   I have a number of sites and store all my images in one location which means that I needed to change your line 57 in autocomplete.php from ...

$results_array['img'] = tep_image(DIR_WS_IMAGES . $results['products_image'], NULL, '40', '');

to

$results_array['img'] = tep_image(DIR_WS_PRODUCT_IMAGES . substr($results['products_image'],2), NULL, '40', '');

This gives me the correct path for the image but the search results outputs the word "false" in the drop down list where the image is suppose to appear. I assume you have a check/test to see if the image exists in the javscript routine that fails but for the life of me I can't seem to pick that out.

Can you point me in the right direction?

Dan
 

Link to comment
Share on other sites

I assume you have a check/test to see if the image exists in the javscript routine that fails but for the life of me I can't seem to pick that out.

 

Hi Dan,

 

No there is no such check that would return false, only a check to make sure that the image space appears blank if there is no image.

i.e. <style>img[src='']{display: none;}</style>

 

At a quick glance, I suspect that false maybe being returned by the tep_image() function.

 

Can I ask why are you getting only part of the image string -> substr($results['products_image'],2) ?

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

 

Can I ask why are you getting only part of the image string -> substr($results['products_image'],2) ?

 

@@auzStar

 

There are a couple of leading .. before the actual location of the image...it is needed for an older version of osC that is still running on one of my sites. The image urls look something like ../skus/subdirectory/image.jpg.   I'm just stripping the .. off. 

 

I'll take a look at the tep_image function.

 

Dan

Link to comment
Share on other sites

@@auzStar

 

Got it...I had a slight spelling issue in my DIR_WS_PRODUCT_IMAGES define.  Sometimes I think I'm dyslexic.

 

Dan

Link to comment
Share on other sites

:thumbsup:

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

@@auzStar

 

Now that I have it functioning I've been testing it a bit and noticed that on the first page load when visiting my site I get "no matches" but if I go to another product category and repeat the same search it pulls up the results you'e expect.   I checked this behavior on your demo site and it works from the get go.  I wondering if this is caused by one of the scripts not be loaded early enough? Any ideas?

 

Dan

Link to comment
Share on other sites

@@John W

 

It is on a different site John and I looked at the output via the firefox inspector and it seems to be a Cross-Origin Resource Sharing issue.  I also noticed that whether it's a problem or not depends on how I access the site.  The limited reading I've done suggests that I might need to add...

 

header("Access-Control-Allow-Origin: *");

 

to sort it out but since I'm not sure what consequences of that are I need to do some more research first.

 

Dan

Link to comment
Share on other sites

It is on a different site John and I looked at the output via the firefox inspector and it seems to be a Cross-Origin Resource Sharing issue.  I also noticed that whether it's a problem or not depends on how I access the site.

 

Dan,

 

I haven't been able to reproduce this issue. Can you elaborate on "I also noticed that whether it's a problem or not depends on how I access the site". Also, are you able to provide a link to your site?

 

I have noticed though that there are some inconsistencies with the href links in the script in regards to SSL mode. 

 

Try changing the href links (only the bold part, as per this example) to "tep_href_link('blah_blah', 'blah=blah', $request_type, false)" inside the ht-twitter-typeahead.js.php file (note: there are 2 to change, one is already like this).

 

There is also one in this file autocomplete.php.

 

This will at least make them all consistent with the quick search module's href link.

 

cheers

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

@@auzStar

 

Dom...I don't think it is anything you need to worry about...I'm running a bit of a unique site set up with a bunch of domains, rewrites etc and I'm fairly sure the issue is related to my setup.  On a standard install it shouldn't be an issue.

 

Dan

Link to comment
Share on other sites

  • 3 weeks later...

Hi auzStar,

 

Thank you very much for this Add-On. It works perfectly.

 

Now I am looking for a possibility to implement the German special characters: Ä, Ö, Ü, ä, ö, ü, ß.... etc. Does anybody have an idea ? 

 

Thanks in advance. 

 

Regards, Zoltan

Link to comment
Share on other sites

@@auzStar, @@Zoltan,

 

I found the following workaround for special characters.

It is not pefect native utf-8 support. It just replaces all special characters by standard characters. Search results are ok, but it doesn't distinguish between "a" and ä" for example. So if you search for "Bänd" you may get "Band" and" Bänd" in the results.

 

In: ext/modules/header_tags/twitter_typeahead/autocomplete.php

 

below:

require('includes/application_top.php');

add:

function cleanString($text) {
    $utf8 = array(
        '/[áàâãªä]/u'   =>   'a',
        '/[ÁÀÂÃÄ]/u'    =>   'A',
        '/[ÍÌÎÏ]/u'     =>   'I',
        '/[íìîï]/u'     =>   'i',
        '/[éèêë]/u'     =>   'e',
        '/[ÉÈÊË]/u'     =>   'E',
        '/[óòôõºö]/u'   =>   'o',
        '/[ÓÒÔÕÖ]/u'    =>   'O',
        '/[úùûü]/u'     =>   'u',
        '/[ÚÙÛÜ]/u'     =>   'U',
        '/ç/'           =>   'c',
        '/Ç/'           =>   'C',
        '/ñ/'           =>   'n',
        '/Ñ/'           =>   'N',
        '/–/'           =>   '-', // UTF-8 hyphen to "normal" hyphen
        '/[’‘‹›‚]/u'    =>   ' ', // Literally a single quote
        '/[“”«»„]/u'    =>   ' ', // Double quote
        '/ /'           =>   ' ', // nonbreaking space (equiv. to 0x160)
    );
    return preg_replace(array_keys($utf8), array_values($utf8), $text);
}

3 lines below replace:

  $search_term = tep_db_prepare_input($_GET['term']);

with:

  $search_term = tep_db_prepare_input(cleanString($_GET['term']));

Source: http://stackoverflow.com/questions/14114411/remove-all-special-characters-from-a-string

 

 

@@auzStar, In Github I found this info:

https://github.com/twitter/typeahead.js/issues/1278

<<Check your connector settings.
As far my experience typeahead works quite well with special chars (utf8 encoded).>>

 

So there might be some setting missing to get native utf-8 support.

 

I tried something in twitter.typeahead.bundle.modified.js

 

Lines 589-596:

        _.mixin(Prefetch.prototype, {
            _settings: function settings() {
                return {
                    url: this.url,
                    type: "GET",
                    dataType: "json"
                };
            },

Tried to apply  the changes explained here:

https://github.com/twitter/typeahead.js/issues/1236

 

without success. Maybe you are more successful.

 

regards

Rainer

Link to comment
Share on other sites

@@raiwa

 

Thanks Rainer.

I'll have a look at it as soon as I get a chance.

 

@@Zoltan

@@presentemusical

Can you please test Rainer's workaround above please and let me know results.

 

I'll look into the github issues and see what I can do in the meantime.

 

If we can get something working satisfactorily I'll add an option to also test for special (accent) characters to the package.

 

cheers

My Add-ons
Advanced Cache Control Tool for osCommerce 2.3.x (non-bootstrap) Download Support
Ajax Product Listing for osC 2.3.4 (bootstrap) Download Support
Category New Products Carousel for osC 2.3.4 (bootstrap) Download Support
Category Popular Products Carousel for osC 2.3.4 (bootstrap) Download Support
Customer Testimonials for osCommerce 2.3.4 (bootstrap and non-bootstrap) Download Support
Front Page New Products Carousel for osC 2.3.4 (bootstrap) Download Support

Index Nested - Product Listing for osC 2.3.4 (bootstrapDownload Support
Match Categories in Search Results for osCommerce versions 2.3.x (non-bootstrap) Download Support
Modular Category Page for osC 2.3.4 (bootstrap)
Download Support

NEW Australia Post Shipping Modules for osCommerce 2.3.x (non-bootstrap) Download Support
NEW Equal Height Module for osC 2.3.4 (bootstrapDownload Support
Products Low Stock Report for osC 2.3.x (bootstrap and non-bootstrap) Download Support
Twitter Typeahead Autocomplete Search for osCommerce 2.3.4 (bootstrap and non-bootstrap)
Download Support

Upcoming Products Modules for osC 2.3.4 (bootstrap) Download Support

 
Assisted Add-ons
Scroll Boxes for osCommerce 2.3.x (bootstrap and non-bootstrap) Download Support
 
Bootstrap Add-ons created by other members
osCommerce Bootstrap Addons and Code

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...