Forum

Thread tagged as: Problem, Runway

Template with lots of conditionals: last ones ignored

I've recently run into a problem in a template with a lot of conditionals where the last ones were ignored.

As far as I can tell there were no errors in the code. If the conditionals were moved around, the last ones would be ignored and those that were previously ignored would work now that they were at the top of the template. It's as if there was a limit to the number of conditionals within a template. After this limit, conditionals were ignored.

The issue was solved by moving the code to a page instead of a template.

Here is the template for reference

<perch:before>
<div class="download-list <perch:content id="companySlug" />">
    <div class="logo"><span class="icon-<perch:content id="companySlug" />"></span></div>
    <div id="<perch:content id="companySlug" />-accordion<perch:content id="seasonslug" />" class="panel-group" role="tablist" aria-multiselectable="true">
</perch:before>

        <perch:if id="hide" value="true" match="neq">
        <div class="panel panel-default<perch:member has-tag="<perch:content id="tag-browse" />"> <perch:else:member /> <perch:member has-tag="<perch:content id="tag-print" />"> <perch:else:member /> disabled </perch:member> </perch:member>">
            <div id="heading<perch:content id="title" urlify="true" />" class="panel-heading" role="tab">
              <h4 class="panel-title">
                <a data-toggle="collapse" data-parent="#<perch:content id="companySlug" />-accordion<perch:content id="seasonslug" />" href="#<perch:content id="title" urlify="true" />" aria-expanded="false" aria-controls="<perch:content id="title" urlify="true" />">
                    <perch:if id="lang" value="fr">
                        <perch:if exists="title_fr"><perch:content id="title_fr" /><perch:else /><perch:content id="title" /></perch:if>
                    </perch:if>
                    <perch:if id="lang" value="ja">
                        <perch:if exists="title_ja"><perch:content id="title_ja" /><perch:else /><perch:content id="title" /></perch:if>
                    </perch:if>
                    <perch:if id="lang" value="ko">
                        <perch:if exists="title_ko"><perch:content id="title_ko" /><perch:else /><perch:content id="title" /></perch:if>
                    </perch:if>
                    <perch:if id="lang" value="en">
                        <perch:content id="title" />
                    </perch:if>
                </a>
              </h4>
            </div><!-- /.panel-heading -->
            <div id="<perch:content id="title" urlify="true" />" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<perch:content id="title" urlify="true" />">
              <div class="panel-body">
                <perch:if exists="cover"><h3>
                    <perch:if id="lang" value="fr">
                        <perch:if exists="title_fr"><perch:content id="title_fr" /><perch:else /><perch:content id="title" /></perch:if>
                    </perch:if>
                    <perch:if id="lang" value="ja">
                        <perch:if exists="title_ja"><perch:content id="title_ja" /><perch:else /><perch:content id="title" /></perch:if>
                    </perch:if>
                    <perch:if id="lang" value="ko">
                        <perch:if exists="title_ko"><perch:content id="title_ko" /><perch:else /><perch:content id="title" /></perch:if>
                    </perch:if>
                    <perch:if id="lang" value="en">
                        <perch:content id="title" />
                    </perch:if>
                </h3>
                <img src="<perch:content id="CDN_HOST" /><perch:content id="cover" type="image" bucket="cover" width="247" height="247" density="2" crop="false" />" alt="" /></perch:if>
                <perch:repeater id="downloads" scope-parent="true">
                    <perch:before><ul></perch:before>
                    <perch:member has-tag="<perch:content id="parent.tag-browse" />">
                        <li><a href="/services/download.php?cat=<perch:content id="parent.upload-folder" />&season=<perch:content id="seasonSlug" />&file=<perch:content id="filename" />" download="download" class="download-link"><perch:content id="filedesc" /></a></li>
                    <perch:else:member />
                        <perch:member has-tag="<perch:content id="parent.tag-print" />">
                            <li><a href="/services/download.php?cat=<perch:content id="parent.upload-folder" />&season=<perch:content id="seasonSlug" />&file=<perch:content id="filename" />" download="download" class="download-link"><perch:content id="filedesc" /></a></li>
                        <perch:else:member />
                            <li><a href="#" download="download" class="download-link" /><perch:content id="filedesc" /></a></li>
                        </perch:member>
                    </perch:member>
                    <perch:after>
                        <perch:if id="parent.pdfdownload" value="true" match="eq">
                        <perch:member has-tag="<perch:content id="parent.tag-browse" />">
                            <li><button type="button" class="btn" data-toggle="modal" data-target="#modalDownloadRequest" data-resource="<perch:content id="parent.title" /> PDF"><perch:content id="LANG-Trendbook as PDF" /></button></li>
                        </perch:member></perch:if>
                    </ul>
                    </perch:after>
                    <perch:noresults>
                        <h3><perch:content id="LANG-Coming Soon" /></h3>
                    </perch:noresults>
                </perch:repeater>
            </div> <!-- /.panel-body -->
          </div><!-- /.panel-collapse -->
        </div><!-- /.panel -->
        </perch:if>

<perch:after>
    </div><!-- /.panel-group -->
</div><!-- /.download-list -->
</perch:after>
<perch:noresults>
    <p><perch:content id="LANG-No Downloads" /></p>
</perch:noresults>
Stéphane Mégécaze

Stéphane Mégécaze 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's no limit until you nest about 100 deep within any tag level. At that point the code figures there's a syntax error in your template and bails out before we hit an infinite loop.

With that level of complexity, my suspicion would first be:

  1. A mistake with the template, then
  2. A bug with the Members app template handler.

If it's not the first, then the second could possibly be worked around by testing for your member values on the page and passing them into the template as content vars.