DISPLAYING LISTS based on fields
22 posts by 3 authors in: Forums > CMS Builder
Last Post: February 19, 2014 (RSS)
You can add status != "archived" to your getRecords() where clause to prevent them from showing up at all. When you post your code, I can provide an example.
I have the pages ready and the Test stallion created. I currently have "ATEST Stallion" , breed= Bayern, Status = Dressage, North American & Archived
Because my test is Status = Archived I would like it to NOT appear on any other status or breed lists: Show below:
BREED LIST: (BAYERN)
http://www.superiorequinesires.com/stallion-list8breeds.php
NORTH AMERICAN STALLION LIST:
http://www.superiorequinesires.com/stallion-north-american.php
STALLION STATUS LIST: (DRESSAGE)
http://www.superiorequinesires.com/stallion-list7status.php
THE STALLION WOULD SHOW ON THE ARCHIVES PAGE ONLY:
http://www.superiorequinesires.com/stallion-archives.php
I've attached one of the pages that Archived Stallions are not supposed to show on.
Thanks for your help!!
Hi csdesign,
I've had a look at your code in stallion-list8breeds.php, and I think you need to change lines 1 to 28 to the following:
<?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('/var/www/hosted/superiorequinesires.com/public_html/','','../','../../','../../../');
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 'stallion_list'
list($stallion_listRecords, $stallion_listMetaData) = getRecords(array(
'tableName' => 'stallion_list',
"where" => "`status` != 'Archived'",
'loadUploads' => true,
'allowSearch' => false,
));
// load record from 'stallion_roster_text'
list($stallion_roster_textRecords, $stallion_roster_textMetaData) = getRecords(array(
'tableName' => 'stallion_roster_text',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$stallion_roster_textRecord = @$stallion_roster_textRecords[0]; // get first record
if (!$stallion_roster_textRecord) { dieWith404("Record not found!"); } // show error message if no record found
?>
The line highlighted in green is the new code. It inserts a where statement into the MySQL call to the database that will only return records that do have a status of Archived.
Let me know if you have any questions, or if the code doesn't work.
Thanks!
Greg
PHP Programmer - interactivetools.com