Help with filtering code
6 posts by 3 authors in: Forums > CMS Builder
Last Post: December 4, 2013 (RSS)
By dccreatives - December 2, 2013 - edited: December 3, 2013
I would like to exclude some items from showing on a search results page.
This page:
http://www.axislighting.com/CMS/search_products.php
It uses the file I uploaded to make the search products refine the search which filters search results based on item mounting, distribution and lamping categories
Here is the script from the search_products_results4.php page:
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
require_once "../cmsAdmin/lib/viewer_functions.php";
$where = "num=num";
if((@$_REQUEST['mounting'] != "undefined") && (@$_REQUEST['mounting']) ) {
$where .= " AND mounting LIKE '%" . mysql_real_escape_string($_REQUEST['mounting']) . "%' ";
}
if((@$_REQUEST['distribution'] != "undefined") && (@$_REQUEST['distribution']) ) {
$where .= " AND distribution LIKE '%\t" . mysql_real_escape_string($_REQUEST['distribution']) . "\t%' ";
}
if((@$_REQUEST['lamping'] != "undefined") && (@$_REQUEST['lamping']) ) {
$where .= " AND lamping LIKE '%" . mysql_real_escape_string($_REQUEST['lamping']) . "%' ";
}
list($itemsRecords, $itemsMetaData) = getRecords(array(
'tableName' => 'items',
'debugSql' => false,
'where' => $where,
'allowSearch' => false,
));
?>
Problem is that I also want to hide some items from showing in the first place, where do I add this code that it should not interfere with the search results.
'where' => "hide_from_search_page != '1'" ,
I made a checkbox in the section editor, which says hide from search page, when I add it to to the other where line below, it hides the product, but the refine search does not work.
'where' => $where && "hide_from_search_page != '1'" ,
Help with code
By Daryl - December 2, 2013
Hi dccreatives,
CMSB has a reserve field called "hidden" for hiding a record. You can just add a new checkbox field "Hidden" with a field name "hidden" and checked the records you don't want to show.
Hope this helps,
Cheers!
PHP Programmer - interactivetools.com
Help with code
I do not want to hide the record, because you need to get to that record from another page/search. I just wanted to hide it from displaying on a specific page.
Let me know if you have any ideas.
Help with code
ok, I got this, but I want to write the opposite
<?php if ($record['hide_from_search_page']): ?>
I want to write if it is not checked (as this is a checkbox).
This code after my foreach gives me what I want to hide. How do I write the opposite?
By Dave - December 3, 2013
Hi dcccreatives,
Try this (new code in red):
'where' => "hide_from_search_page != '1' AND $where",
Let me know if that works for you. Cheers!
interactivetools.com