Displaying value & label for related table list items on Category Menu page

6 posts by 3 authors in: Forums > CMS Builder
Last Post: December 17, 2025   (RSS)

Hi Deborah,

It looks like in your code, you're only iterating over the ":labels" of the related businesses, and that the $value variable you're using isn't being defined anywhere.

CMSBuilder actually creates two parallel arrays for list fields:
$record['business_directory_num:values'] for the "num" values.
$record['business_directory_num:labels'] for the "business_name" values.

To get both, you can iterate over each of the ":values" instead, and then use their $index to grab the corresponding label and display it too:

<?php foreach ($record['business_directory_num:values'] as $index => $value): ?>
	<?php $label = $record['business_directory_num:labels'][$index]; ?>
	<li><a href="/business/directory/index.php#biz-<?php echo $value; ?>"><?php echo $label; ?></a></li>
<?php endforeach; ?>


So that'll loop through each of the "num" values, then grab the associated "business_name" from the labels array using the $index, and display them both together.

Christine Finlay - Senior Developer
interactivetools.com

Hello, Christine.

I was unaware of the "two parallel arrays possibility". That works perfectly!

Thanks so much for your help.
Deborah

By Dave - December 17, 2025

And I'll just add that you can always use our convenience showme() function to see what fields are available:

<?php showme($record); ?>
Dave Edis - Senior Developer



interactivetools.com

Hi Dave — thanks for the reminder about showme().

It’s a really handy tool, and I did use it here, but I wasn’t sure how to display both the values and the labels in this related use case.

Christine helped point me in the right direction, and I’ve now saved a working snippet in my CMSB library for future reference.

Appreciate the great support!

~ Deborah

By Dave - December 17, 2025

Hi Deborah, 

Oh, of course.  Sorry, I scanned that post a bit too quickly.  

Glad it's worked now! :-)

Dave Edis - Senior Developer



interactivetools.com