Filtering getCategories using a checkbox = 1 or Yes

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 31, 2016   (RSS)

By Zicky - March 23, 2016

I have a category section editor which has a checkbox for meals which are vegan.

Vegan meals come from various parent and child categories throughout the menu records created.

I need to filter all the records of the category section editor - based on the "vegan checkbox = 1 or Yes", so that all the records shown on a page are only vegan related food items.

I tried this, but it didn't work:

     // load menu
  list($menuRecords, $selectedCategory) = getCategories(array(  
    'tableName'           => 'menu',  
    'selectedCategoryNum' => '',         // defaults to getNumberFromEndOfUrl()  
    'categoryFormat'      => 'showall',  // showall, onelevel, twolevel  

<?php foreach ($menuRecords as $categoryRecord): ?> 
<?php if ($categoryRecord['depth'] == 0): ?>
<?php if ($categoryRecord['vegetarian_menu_item'] = '1'):?>

<!-- parent menu category content goes here -->

<?php $parent=$categoryRecord['num'];?> 

<?php foreach ($menuRecords as $categoryRecord): ?> 
<?php if ($categoryRecord['parentNum'] == $parent): ?> 

<!-- children of the menu category items content goes here -->
Vegetable Kabab
Mixed Grill
Veggie Plate

<?php endif ?> 
<?php endforeach; ?> 

<?php endif ?>
<?php endif ?>
<?php endforeach; ?>

Anyone has any suggestions on filtering getCategories using a checkbox, so that only meals with the checkbox checked for vegetarian_menu_item appear?

Thanks, Zicky

By Toledoh - March 24, 2016

Hey Zicky.

Rather than equal to something, have you tried something like the following - which in my way of thinking says... if record is not blank.

<?php if ($categoryRecord['vegetarian_menu_item'] ):?>

BTW.  I'm interested in what you're building.  I've got a project in the to-do pile that's a menu builder for a restaurant.  Let me know if it's something you can discuss. tim at toledoh dot com dot au.

Tim (

By Damon - March 31, 2016

Hi Zicky,

Just following to see if you and Tim were able to come up with something.

Damon Edis -

Hire me! Save time by getting our experts to help with your project.

By Zicky - March 31, 2016


Once I finished getting the menu built I'll pass on what I have worked up.