Show field from linked category section

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 1, 2010   (RSS)

Re: [videopixel] Show field from linked category section

By Jason - August 31, 2010

Hi,

What you need to do is to create an array of categories that you can then access when you're outputting your links records. Exactly how you do this will depend on exactly how you're linking your categories to your links (ie, what is the value field of the dropdown?). In this example, it's assuming you're using the num field in the links_category table.

example:

You can put this code up where you're selecting your records
list($categoryRecords,$categoryMetaData) = getRecords(array(
'tableName' => 'links_category',
'allowSearch' => false,
));

$categoryNumToRecord=array();
foreach($categoryRecords as $category){
$categoryNumToRecord[$category['num']]=$category;
}


The variable $categoryNumToRecord is an array of category records, using their 'num' field as an index.

You can then get at the correct category record when outputting your content like this:

<?php foreach ($linksRecords as $record): ?>

<?php $categoryRecord = $categoryNumToRecord[$record['category']];?>

<?php echo $record['title'] ?>
<?php echo $record['url'] ?>
<?php endforeach ?>


You can now use the variable $categoryRecord to output any information stored in that category record.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Show field from linked category section

I don't need an 'array' to see my category, because that code is already generated in the code generator of CMSB.

It's the 'icon' (upload) that i want to see from my categories...


Thanks anyway!

Re: [videopixel] Show field from linked category section

By Jason - September 1, 2010

Hi,

The array for the category is not just the category name, but the whole category record, this would include the icon field. Your other record will just have the category name, but no other information about the category.

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/