Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Help with category dropdown

 

 


efi-revivo
User

Jan 4, 2012, 2:15 AM

Post #1 of 3 (568 views)
Shortcut
Help with category dropdown Can't Post

I try to use dropdown menu but i need help..

this is my code:

<ul>
<li>
<a href="#" target="_self"><font class="leaf">Home</font></a>
</li>
<li>
<a href="#" target="_self"><span class="branch">Company</span><!--[if gt IE 6]><![endif] --></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<li>
<a href="#" target="_self"><font class="leaf">About Us</font></a>
</li>
<li>
<a href="#" target="_self"><font class="leaf">Terms of use</font></a>
</li>
<li>
<a href="#" target="_self"><font class="leaf">Press Releases</font></a>
</li>
</ul><!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
<li>
<a href="#" target="_self"><font class="leaf">About</font></a>
</li>
<li>
<a href="#" target="_self"><font class="leaf">Contact</font></a>
</li>
</ul>


How can i do it dynamic with our category in CMS

Thanks,
Efi


Tom P
User


Jan 4, 2012, 10:13 AM

Post #2 of 3 (562 views)
Shortcut
Re: [efi-revivo] Help with category dropdown [In reply to] Can't Post

Hi efi-revivo,

I'm not absolutely clear on what you want to do but it you are using the built in category-to-menu feature of cmsb then you can use the following to create the menu:

Code
          <ul> 
<?php foreach ($allCategories as $category): ?>
<?php echo $category['_listItemStart'] ?>

<?php if ($category['_isSelected']): ?>
<b><a href="<?php echo $category['_link'] ?>"><?php echo $category['name'] ?></a></b>
<?php else: ?>
<a href="<?php echo $category['_link'] ?>"><?php echo $category['name'] ?></a>
<?php endif; ?>

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


This uses the array created by the following:

Code
list($allCategories, $selectedCategory) = getCategories(array( 
'tableName' => 'product_categories', // put the category table name here
'categoryFormat' => 'onelevel', // showall, onelevel, twolevel, breadcrumb...
));


Which should be placed above the menu in the code (normally at the start of the page).

If this isn't what you're looking for please do let me know - if you can provide a link to the site and attach the code you're using that would be helpful.

Hope this helps,

Tom


efi-revivo
User

Jan 5, 2012, 1:24 AM

Post #3 of 3 (556 views)
Shortcut
Re: [Tom P] Help with category dropdown [In reply to] Can't Post

Ok, I did it :-)
now its work great..


Code
<div id="container" class="container" dir="rtl"> 
<ul id="shita" class="shita">
<!-- version=1.0.239;name=shita;baseskin=glossy;colorscheme=shitanew;type=dropdown; -->
<?php $divToClose = false; ?>
<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php if ($categoryRecord['depth'] == 0): ?>
<?php if ($divToClose): ?>
<?php $divToClose = false; ?>
</ul></li>
<?php endif ?>
<?php if ($categoryRecord['_hasChild']): ?>
<?php $divToClose = true; ?>
<li>
<a href="#"><span class="branch"><?php echo $categoryRecord['name'] ?></span></a>
<ul>
<?php else: ?>
<li>
<a href="#"><?php echo $categoryRecord['name'] ?></a>
</li>
<?php endif ?>
<?php else: ?>
<li><a href="#"><?php echo $categoryRecord['name'] ?></a></li>
<?php endif ?>


<?php endforeach ?>
<?php if ($divToClose): ?>
<?php endif ?>
</ul>

</div>



(This post was edited by efi-revivo on Jan 5, 2012, 5:15 AM)