Creating a Dynamic Menu

3 posts by 2 authors in: Forums > CMS Builder Community
Last Post: November 29, 2016   (RSS)

By depdesign - November 27, 2016

I would like to create a dynamic menu where "Categories" that relate to "Sections" change an <li> class and list the categories. If anyone has a snippet code for this I would greatly appreciate it.

Here is what I have:
    list($sectionsRecords, $sectionsMetaData) = getRecords(array(
    'tableName'   => 'sections',
    'loadUploads' => true,
    'allowSearch' => false,
    'where'     => "createdByUserNum = '" . $accountsRecord['num'] . "'",
    list($categoryRecords,$categoryMetaData) = getrecords(array(
    'tableName'     => 'categories',
    'allowSearch'   => false,
    'loadCreatedBy' => false,
    'where'     => "createdByUserNum = '" . $accountsRecord['num'] . "'",

The Category table has a "section" field that list related sections.

I would like to have any Category that the "section" field matches the record num of a Section to appear like this:
<li class="dropdown">
    <a href="#" class="dropdown-toggle" href="#"> Section Title </a>
        <ul class="dropdown-menu">
        <li><a href="#">Related Category Title</a></li>
        <li><a href="#">Related Category Title</a></li>  

If a Category "section" field does not match the record num of a Section it should appear like this:
    <a href="login" class="dropdown-toggle" href="#"> Section Title </a>

Dan Perez

By ross - November 29, 2016

Hi there.

Thanks for posting.

Do you have a sense of how many records we'll be working with here?

Also, could you attach a copy (please don't just paste the code) of each schema to a reply here so I can review how your sections are setup?


Ross Fairbairn - Consulting

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: