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 -->
Example
Entrees

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

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

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

</li> 
<?php endif ?> 
<?php endforeach; ?> 

</ul>  
<?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.

Cheers,
Tim (toledoh.com.au)

By Damon - March 31, 2016

Hi Zicky,

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

Cheers,
Damon Edis - interactivetools.com

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

By Zicky - March 31, 2016

Tim,

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