Menu links

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 10, 2015   (RSS)

Hey Tim,

I think something like this should work:

<ul class="footerList">
  <?php foreach ($pagesRecords as $categoryRecord): ?>

    <?php echo $categoryRecord['_listItemStart'] ?>

    <?php if ($categoryRecord['_hasChild']): ?>
    <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo htmlEncode($categoryRecord['name']); ?></a>
    <?php $parentLink = $categoryRecord['_link']; ?> 
    <?php else: ?>
    <a href="<?php echo $parentLink ?>#section<?php echo $categoryRecord['num']; ?>"><?php echo htmlEncode($categoryRecord['name']); ?></a>
    <?php endif; ?>

    <?php echo $categoryRecord['_listItemEnd'] ?>

  <?php endforeach; ?>
</ul>

So if we're dealing with a top level page, we set its URL to the variable parent link. Then if we're dealing with a second level page, we use the $parentLink variable to use the parent page URL.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Perfect - thanks Greg!

Cheers,

Tim (toledoh.com.au)