Accordian Container on a Multi Record Page
8 posts by 4 authors in: Forums > CMS Builder
Last Post: June 3, 2010 (RSS)
By MercerDesign - May 28, 2010
If you click on Profession etc you will see what I mean.
Re: [MercerDesign] Accordian Container on a Multi Record Page
By gkornbluth - May 28, 2010
I'm not sure what you mean by multiple records. Where should the other records be showing up?
Could you describe what you're trying to accomplish in more detail?
I'm assuming that the html site is the existing one and that there's a php version in the works.
If you could attach your php code (no personal information) that would help.
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Accordian Container on a Multi Record Page
By Perchpole - May 30, 2010
Perch
Re: [MercerDesign] Accordian Container on a Multi Record Page
By Jason - May 31, 2010
I've tried to take a look at the link you posted, but get a 404 error. If you could attach the file you're working with, along with the exact nature of the problem you're facing, I can take a look at it for you.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Accordian Container on a Multi Record Page
By MercerDesign - June 1, 2010
It would be good however to be able to do it so the code is not in the content area for my client to mess up.
Re: [MercerDesign] Accordian Container on a Multi Record Page
By Jason - June 1, 2010
If you could attach the actual .php file and let me know exactly what you want this page to do that it isn't currently, I can take a closer look for you.
Thanks.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Accordian Container on a Multi Record Page
By MercerDesign - June 3, 2010
http://www.horatioinvestments.com/how_horatio_investments_do_business.php
I want it so the code is not in there for the client to mess up but on the actual template page.
Re: [MercerDesign] Accordian Container on a Multi Record Page
By Jason - June 3, 2010
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/