category records - Get options from database - displayed as bullets

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 17, 2011   (RSS)

By Mikey - January 15, 2011

I'm pulling category records into a single called "Products" page. I've created a list checkbox field called "Keywords" and I'm using the "Get options from database (advanced).

List Options: Get options from database (advanced)
Section Tablename: keywords
Use this field for option values: num
Use this field for option labels: name

I'm trying to make the keywords appear as a list with bullets in the code below. But it's returning all of my Keyword category records and not just those I have selected the checkbox for within Products. I also intend to use this code on other site pages as a dropdown selection menu for a few site forms for drilling down on categories. This code works, but it's just not limiting only categories that have been selected for the page it is related to and instead it reflects all category records. Can anyone shed some light on how to make this code show only category records that have been checked within the Products record?

Here's the original code generated by CMS Builder to display the keywords:
<?php echo join(', ', getListLabels('products', 'keywords', $productsRecord['keywords'])); ?>


///////////////////////////////// keywords as bulltets ////////////////////////////////////
//<?php echo join(', ', getListLabels('products', 'keywords', $productsRecord['keywords']));
list($productsBulletsRecords, $productsBulletsMetaData) = getRecords(array(
'tableName' => 'keywords',
'orderBy' => "name asc",
));
//compile products Bullet array
$currentDrill = array();
foreach($productsBulletsRecords as $record){
//if($record['depth'] < 1) { continue; };
//temporary array of elements for a particular record
$temp = trim($record['name']);
$temp = ucfirst($temp); // Returns a string with the first character of str capitalized
$temp = ucwords($temp); // Returns a string with the first character of each word in str capitalized
$temp = explode("\t",$temp);
foreach($temp as $item){
$item=str_replace("<br/>","",$item);
if(!in_array($item,$currentDrill)){ //add a new item to the array
$currentDrill[$item]=$item;
}}}
//sort $currentDrill
sort($currentDrill);

Here's my page code where the bullets will appear:

<ul><?php foreach ($currentDrill as $keywords): ?>
<li><?php echo $keywords;?></li>
<?php endforeach ?> </ul>