Multi-level Category Functions

63 posts by 17 authors in: Forums > CMS Builder
Last Post: December 19, 2011   (RSS)

thank You chris

But i don't know how to display the result [blush][blush][blush]
hi chris,

sorry i try the code but not work
i solve the problem with other way

<div class="glossymenu">

<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php if ($categoryRecord['depth'] == 0): ?>
<a href="<?php echo $categoryRecord['_link'] ?>" class="menuitem submenuheader"><?php echo $categoryRecord['name'] ?></a>
<?php $parent=$categoryRecord['num'];?>
<ul class="submenu">

<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php if ($categoryRecord['parentNum'] == $parent): ?>
<li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>

</ul>
<?php endif ?>
<?php endforeach; ?>
</div>


and thanks again for your efforts

Re: [mohabsi] Multi-level Category Functions

By Chris - December 16, 2010

Hi mohabsi,

That's a clever solution, and I'm glad you got things working. :)

Any chance you could tell me what didn't work with my approach? I'm hoping that we can provide a function like the one I posted above to help others with similar requirements.
All the best,
Chris
Chris: Is there any way to specify which category other than 0 to start with as the default?

Specifically, I want http://mywebsite.com/index.php to default to http://mywebsite.com/index.php?menu-number-five-2

Thanx

Ragi
--
northernpenguin
Northern Penguin Technologies

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

Re: [northernpenguin] Multi-level Category Functions

By Chris - December 28, 2010

Hi Ragi,

Yes, there's a 'rootCategoryNum' option which will only list categories "under" the root. For example:

list($categoriesRecords, $selectedCategory) = getCategories(array(
'tableName' => 'my_category_section',
'rootCategoryNum' => 2,
));


Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [Dave] Multi-level Category Functions

By zip222 - December 29, 2010

when using a category menu, how do I only show the sub menu items for the currently active section. example, here is a flat view of the menu I am working with...

About
- Company
- History
- Management
Products
- Product One
- Product Two
- Product Three
Services
- Service One
- Service Two
- Service Three


but what I want to do is only show the sub pages for the currently active section. and initially I only want to see the level 0 pages.

here is the code i am using for the menu shown above

<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>

Re: [zip222] Multi-level Category Functions

By Chris - December 29, 2010

Hi zip222,

I think the 'categoryFormat' => 'onelevel' option is what you're looking for:

list($categoriesRecords, $selectedCategory) = getCategories(array(
'tableName' => 'my_category_section',
'categoryFormat'=> 'onelevel',
));


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

By zip222 - December 30, 2010

Yep, that's what I was looking for. Thanks.

Re: [Dave] Multi-level Category Functions

By Maurice - January 3, 2011

Hi dave,

I was playing around with this and got it working but some where i missed some thing/code the menu dos not link to the url/ location how do i set the right url to each menu item.

for instance i added a contact menu item with
this as result categoryList.php?Contact-11 how do i make a link to the right location /contact/index.php ???

thnx
Maurice
-------------------------------------------

Dropmonkey.nl