CMS and Spry

7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 10, 2010   (RSS)

By dccreatives - June 8, 2010

I would like to incorporate some spry collapsible panels on my page: I was able to insert it perfectly for the first one, the problem is that when it loops and has the same name, it does not work.

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
Attachments:

downloadslist.php 6K

Re: [dccreatives] CMS and Spry

By Jason - June 8, 2010

Hi,

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

It is still not working.

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>
Attachments:

downloadsdetail.php 7K

Re: [dccreatives] CMS and Spry

By Jason - June 9, 2010

Hi,

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

Sorry to make you crazy, but now it does not work at all. the first is now open and it does not close when clicked on. Here is the page. http://www.axislighting.com/CMS/downloadsList.php

Attached is the file again.
Attachments:

downloadslist_001.php 8K

Re: [Jason] CMS and Spry

Thanks it perfect.