I have an image grid for my articles, and its sorted by the type of articles. So all the articles of a certain type is all put in the same item grid, but I want to sort it after the brand aswell by having my image grid sort under a logo of the brand. So if I have 2 different brands of 1 type of article, I want 2 image grids on the same page, neatly sorted under their respective logo.
This is what I have so far:
<div class="widewrapper weak-highlight">
<div class="container content">
{% for entry in entry.children %}
{% if entry.type=="lift" and entry.liftMerke=="nifty" %}
<div class="image">
<img class="img-responsive" src="/uploads/images/logo-brand1" alt="">
</div>
<div class="row">
{% for entry in entry.children %}
{% if entry.type=="lift" and entry.liftMerke=="nifty" %}
<div class="showroom-item col-sm-4 col-md-3 col-lg-3">
<div class="image">
{% set bilde = entry.bilde.one() %}
{% if bilde %}
<img class="img-responsive" src="{{ bilde.geturl('fremsideKnapper') }}" alt="">
{% endif %}
<a class="overlay" href="{{ entry.url }}">
<i class="glyphicons search"></i>
<div class="name"><p>{{ entry.title }}</p><p>Arbeidshøyde: {{ entry.arbeidshoyde }}</p></div>
</a>
<a
href="{{ entry.url }}"
class="btn btn-default btn-gantic btn-xs btn-block">
<h3>{{ entry.title }} | {{ entry.arbeidshoyde }}</h3>
</a>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endfor %}
<div class="clearfix"></div>
</div>
So this gives me just a whole bunch of logos whitch is not what I want. Is there something I can do to make it search through the entry.children articles, and do something only once(print logo) if something is true for either one of the articles? Really appreciate any help!
EDIT:
So I have been playing around with this abit now, but I cant really get it to work. I forgott to mention something inportant in my post aswell, I am using craft3 beta.
So I am abit unsure if the errors I am encountering are me not really understanding what I am doing or if it is related to differences between craft 2 and 3.
I created a catogory group(liftmerker) and two catogories(denka, nifty). I added a image field(image field is called "bilde") to the catogories where I uploaded the logos.
This is what the code looks like at the monent:
<div class="widewrapper weak-highlight">
<div class="container content">
{% set entries = entry.children | group( 'entryCategory.one().title' ) %}
{% set brands = craft.categories.group( 'liftmerker' ).titles %}
{% for brand in brands %}
{% set brandEntries = entries[ '' ~ category ] | default( [] ) %}
{% if brandEntries | length %}
<div class="image">
<img class="img-responsive" src="{{ brand.bilde.first.url }}" alt="{{ brand.first.title }}">
</div>
<div class="row">
{% for entry in brandEntries %}
...
{% endfor %}
</div>
{% endif %}
<div class="clearfix"></div>
{% endfor %}
</div>
This gives me an error that I dont really understand:
TypeError
Argument 1 passed to craft\web\twig\Extension::groupFilter() must be of the type array, object given, called in /home/vagrant/Code/Gantic/Gantic3/storage/runtime/compiled_templates/c3/c383e9d48f1c478076ea5c1b97037f5aa9b4242fb3b6dcb877a0488b0b8b32b7.php on line 114
Any suggestions for what I can do different or what line in the code is causing the error?