Expandable Categories

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 3, 2008   (RSS)

By Kenny - June 2, 2008

I am trying to use an Accordion Menu Script (http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm)

So far, I am getting shaky results.

I have:

<?php
$lastCategory = "";
foreach ($hpmenuRecords as $hpmenuRecord):
$showHeader = false;
if ($hpmenuRecord['category'] != $lastCategory) {
$lastCategory = $hpmenuRecord['category'];
$showHeader = true;
}
?>
<?php if ($showHeader): ?>
<h3 class="menuheader expandable"><?php echo $hpmenuRecord['category'] ?></h3>
<ul class="categoryitems"><?php endif ?>
<li><a href="<?php echo $hpmenuRecord['link'] ?>"><?php echo $hpmenuRecord['title'] ?></a></li>
</ul>
<?php endforeach; ?>

It is not showing up right.

The page I am working on is:
http://www.cleburnehighschool.com/index.php

A non-CMS Builder page where it works "out of the box" is:
http://www.cleburnehighschool.com/index2.html

Re: [sagentic] Expandable Categories

By Dave - June 2, 2008

Hi sagentic,

It's adding a closing </ul> after each item. We need it to add that only once after each list of items but before the next header starts. Try adding the code in red:

<?php
$lastCategory = "";
foreach ($hpmenuRecords as $hpmenuRecord):
$showHeader = false;
if ($hpmenuRecord['category'] != $lastCategory) {
$lastCategory = $hpmenuRecord['category'];
$showHeader = true;
}
?>

<?php if ($showHeader): ?>
<?php if ($lastCategory): ?></ul><?php endif; ?>
<h3 class="menuheader expandable"><?php echo $hpmenuRecord['category'] ?></h3>
<ul class="categoryitems">
<?php endif ?>

<li><a href="<?php echo $hpmenuRecord['link'] ?>"><?php echo $hpmenuRecord['title'] ?></a></li>
</ul>
<?php endforeach; ?>
</ul>


Let me know if that fixes it.
Dave Edis - Senior Developer
interactivetools.com