Breadcrumb Problem

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

By northernpenguin - August 29, 2015

I am having a bit of a problem getting breadcrumbs to work properly on my site.  I found some code in the forum that looked like it might work, so I tried it on a test page.  I am down to one Warning, which I can't figure out how to solve.  Can anyone help?

I get the following warning message

Warning: array_combine(): Both parameters should have an equal number of elements.... (it refers to line 2 in breadcrumbs.inc below)

Below is my menu.inc

     <ul class="sf-menu">
        <?php foreach ($menuRecords as $categoryRecord): ?>
          <?php echo $categoryRecord['_listItemStart'] ?>

       <?php if ($categoryRecord['_isSelected'] && !$categoryRecord['new_page']): ?>
            <b><a href="<?php echo $categoryRecord['filename'] ?>" blank="_target"><?php echo $categoryRecord['name'] ?></a></b>
          <?php else: ?>
            <a href="<?php echo $categoryRecord['filename'] ?>"><?php echo $categoryRecord['name'] ?></a>
          <?php endif; ?>

          <?php echo $categoryRecord['_listItemEnd'] ?>
        <?php endforeach; ?>
      </ul>

    <?php if (!$selectedMenu): ?>
      No category is selected!<br/>
    <?php endif ?>

Here is the breadcrumb.inc

<?php
$categoriesRecordsByNum = array_combine(array_pluck($categoryRecord, "num"), $categoryRecord);

$lineage = explode("\t", trim(preg_replace("/:/", "\t", $selectedMenu['lineage'])));

$parents = array();
foreach ($lineage as $parentCatNum) {
$parents[] = $categoriesRecordsByNum[$parentCatNum];
}
?>


<?php foreach($parents as $parent): ?>
<ul class="breadcrumblist">
<span>&rsaquo;</span>
<?php if ($parent === $selectedMenu): ?>
<li class="breadcrumbItem">&nbsp;/&nbsp;<?php echo $parent['name'] ?></li>
<?php else: ?>
<li class="breadcrumbItem">&nbsp;/&nbsp;<a href="<?php echo $parent['_link'] ?>"><?php echo $parent['name'] ?></a></li>
<?php endif ?>
</ul>
<?php endforeach ?>

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By northernpenguin - September 1, 2015

Daryl:  Yes, it is a multiple menu record.  I tried both suggestions, and both only list the top level menu, Home.

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By Daryl - September 4, 2015

Hi Ragi,

Your code seems like it is for displaying only the top level menu or the selected parent menu.

Do you mind if I take a closer look by submitting a second level support request?

You can find the form here: https://www.interactivetools.com/support/email_support_form.php

Thanks,

Daryl Maximo
PHP Programmer - interactivetools.com