Search Results

15 posts by 4 authors in: Forums > CMS Builder
Last Post: June 18, 2013   (RSS)

I have a page which is a search results page. 

I have items which have are assigned a type of mounting to each item from a field.

When I want to display only certain mountings, I use the following link:

http://www.axislighting.com/CMS_french/search_products.php?mounting_french=Suspension

This works for all except this one:

http://www.axislighting.com/CMS_french/search_products.php?mounting_french=Encastré

Since I also have a mounting called: Balayage Mural Encastré 

So it shows both of them. How can I get it to only show the mountings of Encastré  when I use the link above? and not show also these: Balayage Mural Encastré Mountings.

I am attaching the file which displays the results. I want the display to be only the mounting_french words I use in the url string.

By gregThomas - June 13, 2013

Hi,

I don't think search_products.php got attached to the post, would it be possible to attach it? Assuming you're using a getRecords function to return results, you should just be able to add _match to the end of your search field to return only exact matches. You can read more on search terms using the getRecords function here:

http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

I am giving the results via a link where I sort the results based on fields.

This gives me all products

http://www.axislighting.com/CMS_french/search_products.php

This give me all products with a certain mounting called Suspension

http://www.axislighting.com/CMS_french/search_products.php?mounting_french=Suspension

This gives me all products with a mounting called Encastré

http://www.axislighting.com/CMS_french/search_products.php?mounting_french=Encastré

The link above is also returning other products that have the name Encastré in their mounting names.

Where do I add the _match. Here are the 2 files that are used on this page.

Searchproducts.php  when called via the link, just serves as a page to view all items. Teh search_products_results is the table where the products are shown with their image and logo and mounting name.

By gregThomas - June 13, 2013

Thanks for the update. 

I've found out what the problem is, if you want to quickly fix the issue you just need to change your where statements to match results as opposed to looking for keywords, you need to change line 9 of search_product_results to this:

  if((@$_REQUEST['mounting_french'] != "undefined") && (@$_REQUEST['mounting_french']) ) {
     $where .= " AND mounting_french = '" . mysql_real_escape_string($_REQUEST['mounting_french']) . "' ";
  }

This will only return results with the exact match for what you've searched for.

You could also use the functionality built into the getRecords function to filter results for you, you'd need to replace up to line 39 of search_product_results.php with this:

<?php

  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  require_once "../cmsAdminFrench/lib/viewer_functions.php";

  list($itemsRecords, $itemsMetaData) = getRecords(array(
    'tableName'   => 'items',
    'allowSearch' => true,
  ));
 // load records from 'mounting'
  list($mountingRecords, $mountingMetaData) = getRecords(array(
    'tableName'   => 'mounting',
    'loadUploads' => true,
    'allowSearch' => true,
  ));
  
  // load records from 'mounting-french'
  list($mounting_frenchRecords, $mounting_frenchMetaData) = getRecords(array(
    'tableName'   => 'mounting_french',
    'loadUploads' => true,
    'allowSearch' => true,
  ));
  
?>

Once you have allow search enabled you can easily filter results by adding the the field you want to filter by to the URL, for example you could return matched results using this system with the following URL:

http://www.axislighting.com/CMS_french/search_products.php?mounting_french_match=Encastré

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Thanks Greg.

I tried option 1 and nothing showed up.

I tried option 2 which worked for the link url, but then the side search options did not work. When I cleared all, nothing showed up.

Perhaps we can just write something that says for Encastré do not show this Balayage Mural Encastré result.

By gregThomas - June 17, 2013

Hi,

If the URL search option worked for option two, then you should just need to change the name of your radio input field so that it's the same as is used in the URL:

<input name="mounting_french_match" type="radio" value="Encastré">

This will search the tables mounting_french field for exact matches too Encastre.

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

They get called from the Mounting French values and that is what they are called, so I am not sure why it is not working.

By gregThomas - June 17, 2013

Did adding the _match to the end of the radio input name not work? 

The _match on the end of the name lets the getRecords function know it should returning exact matches only, so it would still be searching the mouting_french field. This page explains the different endings you can use:

http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com