cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[2.0.x] Volt issue with if / else statement

Open borisdelev opened this issue 11 years ago • 0 comments

Hi there... i find some issure:

            {% for article in groups %}
                <li>
                    {% if article.getPictures("is_default=1")|length > 0 %}
                        {% for photo in article.getPictures("is_default=1") %}
                            {% set primary_photo = photo.details([300, 225]) %}

                            <a href="{{ url(i18n ~ '/pub/' ~ article.i18n().slug) }}" class="image">
                                <img src="{{ primary_photo.url ~ primary_photo.file }}" alt="{{ article.i18n().title|e }}" />

                                {% for kind in article.getKinds() %}
                                    <strong>{{ kind.i18n().title }}</strong>
                                    {% break %}
                                {% endfor %}
                            </a>
                        {% endfor %}
                    {% else %}
                        {% for kind in article.getKinds() %}
                            <a href="{{ url(i18n ~ '/pub/' ~ article.i18n().slug) }}" class="kind">{{ kind.i18n().title }}</a>
                            {% break %}
                        {% endfor %}
                    {% endif %}
                </li>
            {% endfor %}

So - in this volt template everything looks good, except that else statement didnt work (see first IF statement). Generated template is:

            <?php foreach ($groups as $article) { ?>
                <li>
                    <?php if ($this->length($article->getPictures('is_default=1')) > 0) { ?>
                        <?php $v38269828542iterator = $article->getPictures('is_default=1'); $v38269828542incr = 0; $v38269828542loop = new stdClass(); $v38269828542loop->length = count($v38269828542iterator); $v38269828542loop->index = 1; $v38269828542loop->index0 = 1; $v38269828542loop->revindex = $v38269828542loop->length; $v38269828542loop->revindex0 = $v38269828542loop->length - 1; ?><?php foreach ($v38269828542iterator as $photo) { ?><?php $v38269828542loop->first = ($v38269828542incr == 0); $v38269828542loop->index = $v38269828542incr + 1; $v38269828542loop->index0 = $v38269828542incr; $v38269828542loop->revindex = $v38269828542loop->length - $v38269828542incr; $v38269828542loop->revindex0 = $v38269828542loop->length - ($v38269828542incr + 1); $v38269828542loop->last = ($v38269828542incr == ($v38269828542loop->length - 1)); ?>
                            <?php $primary_photo = $photo->details(array(300, 225)); ?>

                            <a href="<?php echo $this->url->get($i18n . '/pub/' . $article->i18n()->slug); ?>" class="image">
                                <img src="<?php echo $primary_photo->url . $primary_photo->file; ?>" alt="<?php echo $this->escaper->escapeHtml($article->i18n()->title); ?>" />

                                <?php foreach ($article->getKinds() as $kind) { ?>
                                    <strong><?php echo $kind->i18n()->title; ?></strong>
                                    <?php break; ?>
                                <?php } ?>
                            </a>
                        <?php $v38269828542incr++; } ?>

                        <?php $v38269828542iterator = $article->getKinds(); $v38269828542incr = 0; $v38269828542loop = new stdClass(); $v38269828542loop->length = count($v38269828542iterator); $v38269828542loop->index = 1; $v38269828542loop->index0 = 1; $v38269828542loop->revindex = $v38269828542loop->length; $v38269828542loop->revindex0 = $v38269828542loop->length - 1; ?><?php foreach ($v38269828542iterator as $kind) { ?><?php $v38269828542loop->first = ($v38269828542incr == 0); $v38269828542loop->index = $v38269828542incr + 1; $v38269828542loop->index0 = $v38269828542incr; $v38269828542loop->revindex = $v38269828542loop->length - $v38269828542incr; $v38269828542loop->revindex0 = $v38269828542loop->length - ($v38269828542incr + 1); $v38269828542loop->last = ($v38269828542incr == ($v38269828542loop->length - 1)); ?>
                            <a href="<?php echo $this->url->get($i18n . '/pub/' . $article->i18n()->slug); ?>" class="kind"><?php echo $kind->i18n()->title; ?></a>
                            <?php break; ?>
                        <?php $v38269828542incr++; } ?>
                    <?php } ?>
                </li>
            <?php } ?>

... there is no else in first if clause :/ Not sure is it bug or something... just want to report it. Sorry if i wrong something.

Greetings.

borisdelev avatar May 28 '15 20:05 borisdelev