Hide /Show a listing in cms builder for property

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 16, 2013   (RSS)

By kitka - September 15, 2013

I am doing a property management site that requires the administrator the option to SHOW/HIDE A LISTING...

I am unclear of what code should go up at the top to produce results based on the value of the show listing being checked...Here is the sample code..

Any help would be appreciated..

Here is the sample viewer code and the field listiing below...

_______________________________________________________________________

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/services3/webpages/g/e/genedxx.com/public/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records from 'listings'
list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
'loadUploads' => true,
'allowSearch' => false,
));


the field i want to only show results is the the following if it is selected...

Hide Listing (value): <?php echo $record['hide_listing'] ?><br/>
Hide Listing (text): <?php echo $record['hide_listing:text'] ?><br/>



jim albert

By Jason - September 16, 2013

Hi

So it looks like you have a checkbox called "hide_listing" and you want to not return any records with that checked.  Is that right?

If so, you can put in a where clause to your getRecords() call like this:

// load records from 'listings'
list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
'loadUploads' => true,
'allowSearch' => false,
'where'       => "hide_listing != 1",
));


Hope this helps

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/