Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Why dont work conditions?

<div class="container-fluid">
{% if pics %}
    {% for pic in pics %}
        {% if loop.first %}
            <div class="text-center"><img src="/pics/products/{{ pic.picL }}" class="well image-round product-photo-primary"></div>
            <ul class="product-photo-box row">
        {% endif %}
        <li data-src="/pics/products/{{ pic.picL }}" class="col-lg-2 col-md-2 col-sm-2">
            <img src="/pics/products/{{ pic.picL }}" class="well image-round">
        {% if loop.last %}
        {% endif %}
    {% endfor %}
{% else %}
<div class="text-center"><img src="/pics/products-face/{{ product.picL }}" class="well image-round product-photo-primary"></div>
{% endif %}

Hey guys!

Tell me please, why first condition (if pics) dont work? I tried to to change the "pics is iterable" but still it did not help.

pics - array(data of model) or false:

$productPics = ProductPics::find('pid = ' . $product->id );
$this->view->pics = $productPics ? $productPics : false;

Please help me! (And sorry for a bad dialect english, it's not my lang)


Model::find return object. Object can't be false. You can set

$this->view->pics = $productPics->toArray() ? $productPics : false;

to check empty result. But this isn't good idea or (bad idea also)

$this->view->pics = $productPics->count() ? $productPics : false;

or just in view

{% if pics.count() %}

spasib Oleg :) It's work!