Jump to content
Jack_mcs

Site Search Plus

Recommended Posts

You're welcome. I'm glad they are useful. To fix these errors, in includes/functions/site_search.php, find this code

		   if ($languageDir === end(explode("/", $filePath))) {
			  CheckFileContents($filePath, $searchTerm, $fileList, $languageDir);
		   }
	    } else {
		   $fileName = end(explode("/", $filePath));
		   if (end(explode(".", $fileName)) == 'php') { //NOTE: fails if there's an extenstion such file.php.old

and replace it with

		   $tmp = explode('/', $filePath);
		   if ($languageDir === end($tmp)) {
			  CheckFileContents($filePath, $searchTerm, $fileList, $languageDir);
		   }
	    } else {
		   $tmp = explode('/', $filePath);
		   $fileName = end($tmp);
		   $tmp = explode(".", $fileName);
		   if (end($tmp) == 'php') { //NOTE: fails if there's an extension such file.php.old

Share this post


Link to post
Share on other sites

Hi, Thanks for this contribution- I am using Site Search Plus and smart suggest it seems to work perfectly;

Just one small issue -
That if someone searches for example 'dresses' and i have products listed by name of 'dress' , the results appear as 0;

Could you please help me sort it that even if a part of the word that is 'dress' from 'dresses' is included in product name then the search results are displayed for the customers.
Awaiting your earliest help and response....

Share this post


Link to post
Share on other sites

I haven't ran the two addons together so I can't say what the problem might be. But on my site, where just this addon is installed, a search for partial words returns all results that contain them. So it seems there is either a conflict with the two addons running together or the other addon has a problem. 

Share this post


Link to post
Share on other sites

@@Jack_mcs

Thank you for your response;
I cross checked all the code for Site search plus is intact it is no where conflicting with smart suggest;
Could you please guide me about what code should be looked at further to check this...

Share this post


Link to post
Share on other sites

No, I'm sorry but I can't support edited code due to the vast number of possibilities. You can install this addon by itself into a clean shop to see if the problem goes away. If not, then I should be able to help with that.

 

But I just reread your original post and I think I misunderstood it. The search code can only find full or partial words, not words longer than full. So, for example, if you have a product named "my dress" the search will find things like

 

my

dress

dre

ss

 

But it won't find something like "dressing" because that word does not exist in "my dress".

Share this post


Link to post
Share on other sites

Yes, it will. Though there aren't instructions for that version but if you use a compare program like WinMerge you should be able to figure it out. Don't upload the files as is though. 

Share this post


Link to post
Share on other sites

A new version has been uploaded with these changes:

 

  • Added autocomplete code to store and check words searched for.
  • Added an exclude list for files that shouldn't show in the results, like checkout_process.
  • Added code to handle pages from the Information Pages addon.
  • Created code for the bootstrap version.
  • Changed name used for Article Manager search so articles are found.
  • Changed css code for the display so the links are more uniform.
  • Changed code in includes/functions/site_search.php to remove strict warnings (found by member mhsuffolk).

I did not have time to update the install file so you will need to use a compare program, like WinMerge, to make the changes. They are clearly marked so it should not be difficult. Please post here if you run into any problems.

Share this post


Link to post
Share on other sites

I got this error in my error log. Everything is working fine, but this strange (to me) error appears. What does this mean?

 

[sun Dec 27 08:56:40 2015] [error] [client 84.241.194.246] PHP Strict Standards:  Only variables should be passed by reference in /storage/web/public/sites/www.muisjesensitief.nl/includes/functions/site_search.php on line 65, referer: http://www.muisjesensitief.nl/

Share this post


Link to post
Share on other sites

In includes/functions/site_search.php, find

foreach ($matches as $filePath) {

and change it to

 $tmp = $matches;                     
 foreach ($tmp as $filePath) { 

Share this post


Link to post
Share on other sites

@@Jack_mcs

 

thank you for your answer, but it doesn't solved the problem. the error log is still being written with some 40 lines of errors like these (lines 65 and 66 are repeated almost 40 times):

 

[Fri Jan 15 20:03:58 2016] [error] [client ##.###.###.###] PHP Strict Standards:  Only variables should be passed by reference in /storage/web/public/sites/www.muisjesensitief.nl/includes/functions/site_search.php on line 61, referer: https://www.muisjesensitief.nl/index.php

[Fri Jan 15 20:03:58 2016] [error] [client ##.###.###.###] PHP Strict Standards:  Only variables should be passed by reference in /storage/web/public/sites/www.muisjesensitief.nl/includes/functions/site_search.php on line 65, referer: https://www.muisjesensitief.nl/index.php
[Fri Jan 15 20:03:58 2016] [error] [client ##.###.###.###] PHP Strict Standards:  Only variables should be passed by reference in /storage/web/public/sites/www.muisjesensitief.nl/includes/functions/site_search.php on line 66, referer: https://www.muisjesensitief.nl/index.php

Share this post


Link to post
Share on other sites

@@Jack_mcs
 
Solved the problem. The problem is, that 'end' requires a reference, because it modifies the internal representation of the array.
 
To solve this, find:
 
if ($languageDir === end(explode("/", $filePath))) {
 
and replace this with:
 
$temp = explode("/", $filePath);
if ($languageDir === end($temp)) {
 
and find:
 
$fileName = end(explode("/", $filePath));
if (end(explode(".", $fileName)) == 'php') {
 
and replace this with:
 
$temp = explode("/", $filePath);
$fileName = end($temp);
if (end($temp) == 'php') {

Share this post


Link to post
Share on other sites

Thanks for posting the fix but it was already mentioned on the previous page.

 

Anywhere in the code, of any addon, where a reference is part of the function being called will cause a warning under strict standards. I don't know why the php developers decided to make strict standards the default but that's the way it is. Until everyone, including myself, gets in the habit of using a temp variable for such functions, the warnings will continue to show up. But, in my code at least, if I need the variable altered by the function I always make sure it exists first. In the case sited here, it doesn't make any difference. I don't see it in my local setup since I don't code with strict standards set. Maybe I will start doing that.

Share this post


Link to post
Share on other sites

I have added this but have a problem. I have gone back a few times and started over to make sure I did all the changes. The error I get is:

 

1054 - Unknown column 'p.pages_name' in 'field list'

select pd.pages_id, p.pages_name from pages p left join pages_description pd on p.pages_id = pd.pages_id where ( pages_title like '%-s%' or pages_body like '%-s%' ) and language_id = 1

[TEP STOP]

 

It appears to be related to the second set of code in advanced_search_result.php file  If that code is not added the error goes away although then I am guessing I am really missing some functionality? 

 

FIND (around line 136)

  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));

ADD ABOVE
 
  /************** BEGIN SITESEARCH CHANGE ****************/
  require(DIR_WS_FUNCTIONS . FILENAME_SITE_SEARCH);
  $dir = DIR_WS_LANGUAGES;
  $searchTerm = $keywords;
 
  $articlesList = array();
  $fileList = array();
  $pagesList = array();
  if (tep_not_null($keywords)) //only check for words
  {
    CheckAllPages($dir, $searchTerm, $fileList, $articlesList, $pagesList, $languages_id);
  }   

  /************** END SITESEARCH CHANGE ****************/

Share this post


Link to post
Share on other sites

The code that is causing that is looking for the Page Manager table.  That is an addon that uses a defined name of TABLE_PAGES. I'm not aware of any other addon that uses a table named pages but it is possible. If your site uses that table but it is not from Page Manager, then in the includes/functions/site_search.php file, find this line

if (defined('TABLE_PAGES')) {

and change it to

if (false && defined('TABLE_PAGES')) {

If you do have Page Manager installed, then it is a different version than what this addon will work with so you would need to change the name being loaded in. Or you can make the above change and just disable it.

Share this post


Link to post
Share on other sites

Thank you. I never would have found that. I am using an add on called EXTRA PAGES INFOBOX VERSION 4.60  and that's where the TABLE_PAGES is coming from.

 

Thank you again,

 

Dan

Share this post


Link to post
Share on other sites

That addon, I think, is an earlier or later version of Page Manager. I think the difference was something like page_name being used instead of page_title, or vice-versa. If you want to get the code to work for that addon, you just need to change the MySQL statement in the code I mentioned.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×