Integrating CMS with Accordion Menu - tips would be helpful

9 posts by 3 authors in: Forums > CMS Builder
Last Post: December 6, 2010   (RSS)

Re: [meg] Integrating CMS with Accordion Menu - tips would be helpful

By Chris - September 14, 2010

Hi meg,

(This is a really complicated accordion menu! Usually you can use a Category Menu to automatically generate nested <ul>s for you with the '_listItemStart' and '_listItemEnd' pseudo fields.)

I believe the only problem with your approach is that your last three IFs aren't doing what you expect. Instead of outputting a </ul> right away for certain record, you'll want to save that </ul> until after you've run through all the records with higher tiers.

Specifically, after finding a 2nd_tier_with_3rd_tier record, you'll want to output "</ul></li>" as soon as you run into a record that's not 3rd_tier (or at the end of the foreach.) Also, after finding a 1st_tier_drop_down, you'll want to output "</ul>" as soon as you run into the next 1st_tier record (or at the end of the foreach.)

I think your solution will end up looking something like this:

<?php $tier1_buffer = ''; ?>
<?php $tier2_buffer = ''; ?>
<?php foreach ($institutions_subcategoriesRecords as $record): ?>


<?php if(!$record['3rd_tier'] && $tier2_buffer): ?>
<?php echo $tier2_buffer ?>
<?php $tier2_buffer = ''; ?>
<?php endif ?>

<?php if($record['1st_tier'] && $tier1_buffer): ?>
<?php echo $tier1_buffer ?>
<?php $tier1_buffer = ''; ?>
<?php endif ?>



<?php if($record['top_menu_item']): ?>
<h3 class="menuheader" style="cursor: default"><a href="#" class="toc"><?php echo $record['title'] ?></a></h3><div></div>
<?php endif ?>

<?php if($record['1st_tier']): ?>
<h3 class="menuheader expandable"><a href="#" class="toc"><?php echo $record['title'] ?></a></h3>
<?php if($record['1st_tier_drop_down']): ?>
<ul class="categoryitems">
<?php $tier1_buffer = '</ul>' ?>
<?php endif ?>
<?php endif ?>

<?php if($record['2nd_tier']): ?>
<li><a href="#" class="toc"><?php echo $record['title'] ?></a></li>
<?php endif ?>

<?php if($record['2nd_tier_with_3rd_tier']): ?>
<li><a href="#" class="subexpandable"><?php echo $record['title'] ?></a>
<ul class="subcategoryitems" style="margin-left: 15px">
<?php $tier2_buffer = '</ul></li>' ?>
<?php endif ?>

<?php if($record['3rd_tier']): ?>
<li><a href="#" class="toc"><?php echo $record['title'] ?></a></li>
<?php endif ?>

<?php endforeach ?>


<?php echo $tier2_buffer ?>
<?php echo $tier1_buffer ?>


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

Re: [chris] Integrating CMS with Accordion Menu - tips would be helpful

By meg - December 1, 2010

Hey Chris,

Sorry for such a delayed reply. This client had my hands in other print materials and now I'm back to building the CMS. This menu almost works perfectly. Good job so far, BTW. You def know what you're doing. So, please compare these files and see where the problem is. If you need more info to resolve this...let me know:

Page/Menu without the CMS as it show appear:
http://www.emeritihealth.org/individuals.php

Page/Menu with the CMS - it doesn't close the second tier properly:
http://www.emeritihealth.org/individuals1.php

I promise to send you a bottle of wine if you fix this glitch for me - thank you thank you!!

Re: [meg] Integrating CMS with Accordion Menu - tips would be helpful

By Chris - December 1, 2010

Hi meg,

Can you please attach the complete PHP source code of your individuals1.php page?
All the best,
Chris

Re: [chris] Integrating CMS with Accordion Menu - tips would be helpful

By meg - December 1, 2010

Thank you!
Attachments:

individuals1.php 6K

Re: [meg] Integrating CMS with Accordion Menu - tips would be helpful

By Chris - December 2, 2010

Hi meg,

From the looks of your example URL, you're missing some </ul></li> tags to close off your 2nd_tier_with_3rd_tiers. The only way I can see this happening is if you have some records with both '2nd_tier_with_3rd_tiers' and '3rd_tier' enabled. Can you make sure you don't have any records with contradictory flags?
All the best,
Chris

Re: [chris] Integrating CMS with Accordion Menu - tips would be helpful

By meg - December 3, 2010

Of course! Thanks for pointing out my sloppy code skills. [:P] I should probably have someone QC on my end. BTW - I think your product is amazing and I want to send a gift to you all - where should I send it??

Re: [meg] Integrating CMS with Accordion Menu - tips would be helpful

Hi Meg.

Could you post your corrected code so we can all learn from it?

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [meg] Integrating CMS with Accordion Menu - tips would be helpful

By Chris - December 6, 2010

Hi meg,

That's not necessary at all, but if you're adamant, our mailing address is:

interactivetools.com, inc.
#201 - 2730 Commercial Drive
Vancouver, BC CANADA
V5N 5P4


I'm just glad you got everything working! :)
All the best,
Chris