I’ve been working on some Contribute templates for a client. I noticed that repeatable regions weren’t working right. Instead of adding a new item to the region when clicking the plus (or deleting when clicking the minus), the “cursor” would simply move to the next item. The only other reference I could find to the problem was some random, unresolved thread on some website I’ve never heard of.
After a lot of digging around in the code, I figured out the problem. If your template includes another file that has repeatable regions, the repeatable regions in your main template will stop working when you edit the page again. As described, the cursor will move up and down the existing regions instead of adding new regions.
For example, I have a navigation template that has repeatable regions.
1 2 3 4 5
<ul id="nav"> <!-- TemplateBeginRepeat name="Navigation" --> <li><!-- TemplateBeginEditable name="Nav Item" --><a href="#">Home</a><!-- TemplateEndEditable --></li> <!-- TemplateEndRepeat --> </ul>
I included that file via the standard PHP include
. When editing, Contribute seemed to get confused about the repeatable regions in the navigation when Contribute manually imported the navigation file.
The fix is either to not use repeatable regions in your include files (not an option) or to trick Contribute into not trying to include the included file. Contribute is at least smart enough to know how to do the standard PHP includes. So, I had to break a rule and use
eval like this:
<?php eval("include('./nav.php');"); ?>
evals the string and ultimately includes the file. Contribute doesn’t understand the code and does nothing, which removes the problematic code and causes repeatable regions to work as expected.