Re: [MercerDesign] Accordian Container on a Multi Record Page
Hi,
What you'll need to do is make it so you can add your <div> tags dynamically.
What I would suggest is setting up your content in CMS Builder to be a set of nested <ul> lists. Something like this:
<ul>
<li>TITLE</li>
<ul>
<li>Content</li>
</ul>
<li>TITLE</li>
<ul>
<li>Content</li>
</ul>
<li>TITLE</li>
<ul>
<li>Content</li>
</ul>
</ul>
We can then use code to parse this list into an array like this:
$how_we_do_businessRecord['content']=str_replace("<ul>","",$how_we_do_businessRecord['content']);
$how_we_do_businessRecord['content']=str_replace("</ul>","",$how_we_do_businessRecord['content']);
$items=explode("<li>",$how_we_do_businessRecord['content']);
Finally, we can use code to output this array and add in the appropriate <div> tags:
<?php $content=0; ?>
<?php foreach ($items as $key=>$value): ?>
<?php $value=str_replace("</li>","",$value); ?>
<?php $value=trim($value);?>
<?php if($value): ?>
<?php if($content): //output content ?>
<?php $id="Accordion".($key-1)."Content";?>
<?php $content=0;?>
<div class="AccordionContent1" id="<?php echo $id;?>"><?php echo $value; ?></div>
<?php else: //output title ?>
<?php $content=1; ?>
<ul><li> <div onselectstat="return false;" onclick="runAccordion(<?php echo $key; ?>), ContentHeight=;" class="AccordionTitle"><?php echo $value; ?></div></ul></li>
<?php endif ?>
<?php endif ?>
<?php endforeach ?>
The only thing missing from this code is a value for "ContentHeight". There isn't an easy may to make this dynamic, so perhaps there is a default value you can write in there.
Give this a try and let me know if you run into any problems.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/