Combo code Hierarchical List

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 29, 2013   (RSS)

By esupport - April 26, 2013

Hi,

I create a "Category Menu" section and generat a combo code.

Here is the left site of the Combo code

<?php foreach ($ec_km_listRecords as $listRecord): ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>
<a href="<?php echo htmlencode($listRecord['_link']) ?>"><?php echo htmlencode($listRecord['name']) ?></a><br/>
<?php if ($isSelected) { print "</b>"; } ?>
<?php endforeach ?>

<?php if (!$ec_km_listRecords): ?>
No records were found!<br/><br/>
<?php endif ?>

How can I create it as a Hierarchical List item?   

Thanks!

Jac

-Jax H.

Hi Jac,

Here is an example of how you can create a hierarchical menu system using a category section:

<?php
  // load records from 'animal_category'
  list($categories, $categoryMeta) = getCategories(array(
    'tableName'   => 'category_menu_section_name',
  ));
?>
<ul>
  <?php foreach($categories as $category): ?>
    <?php $isSelected = ($category['num'] == @$detailRecord['num']); ?>
    <?php echo $category['_listItemStart']; ?>
      <?php if ($isSelected) { echo "<b>"; } ?>
        <?php echo $category['name']; ?>
      <?php if ($isSelected) { echo "</b>"; } ?>
    <?php echo $category['_listItemEnd']; ?>
  <?php endforeach; ?>
</ul>

This is example code, so you'll have to make a few changes to get it working, specifically you'll have change category_menu_section_name to the name of your category menu section.

So I've used the getCategories function to retrieve the category menu items. This function will automatically generate list item start and end tags using the meta field _listItemStart and _listItemEnd

I've also integrated the $isSelected variable, so the current menu item should be highlighted in bold.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By esupport - April 26, 2013

Hi Gerg

I found the Hierarchical List combo code solution:

<ul>
<?php foreach ($categoryRecords as $categoryRecord): ?>
     <?php echo $categoryRecord['_listItemStart'] ?>
        <?php if ($categoryRecord['_isSelected']): ?>
          <b><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></b>
          <?php else: ?>
       <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
     <?php endif; ?>
   <?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>

Thanks a lot for your help!

Jac

-Jax H.

By esupport - April 26, 2013

Hi Gerg

sorry again!

I have setted correct List Page Url & Detail Page Url on my cmsAdmin Viewer Urls.

I found I couldn't get the detail page for my combo code.

The attachment is my code.

Please kindly help.

Thanks!!

Jac

-Jax H.
Attachments:

categorylist_008.php 3K