CMS and Spry
7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 10, 2010 (RSS)
By dccreatives - June 8, 2010
You can see a sample on this page: http://www.axislighting.com/CMS/downloadsList.php THe first one works, the rest don't because the name is looping as the same div id and it will not work. Anyone out there with an if then statement to give each panel a new name and also add it to the script to keep looping?
Thanks
Re: [dccreatives] CMS and Spry
By Jason - June 8, 2010
What you can do is have a variable that increments through each loop and is added to the id of each div. So the divs are number "CollapsablePanel1","CollapsablePanel2", etc.
On line 85, just above the beginning of your foreach loop, add this code:
<?php $index=1; ?>
Next, use this where you're outputting your <div> tag:
<div id="CollapsiblePanel<?php echo $index;?>" class="CollapsiblePanel">
<?php $index++; ?>
Give this a try and let me know if you run into any issues.
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] CMS and Spry
By dccreatives - June 9, 2010
http://www.axislighting.com/CMS/downloadsList.php If you click on the Dia Box, it will open, the rest are open and do not close as they should.
I think I also need some php to add the script tag to make them all closed Right now the first one is closed (#1) and the rest are all open.
This is the script I have now.
<script type="text/javascript">
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1",{contentIsOpen:false});
//-->
</script>
Re: [dccreatives] CMS and Spry
By Jason - June 9, 2010
Try using this for your javascript:
<script type="text/javascript">
<!--
var CollapsiblePanel<?php echo $index; ?> = new Spry.Widget.CollapsiblePanel("CollapsiblePanel<?php echo $index; ?>",{contentIsOpen:false});
//-->
</script>
Since this javascript is written for each panel, it will append the index number to the end of the javascript variable.
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] CMS and Spry
By dccreatives - June 10, 2010
Attached is the file again.
Re: [dccreatives] CMS and Spry
By Jason - June 10, 2010
One this I noticed is that you put your javascript down at the very bottom of your foreach loop, but you're incrementing your $index variable at the very top. This means you never have any javascript for the first panel, and the rest of them would be off by 1. Try taking this code:
<?php $index++; ?>
at put it at the very bottom of your foreach loop (line 186)
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/