I need the output of a custom module to be sorted differently in different places. I can change the order by changing from sorting by weighting DESC to ASC. But sorting by my custom weighting field doesn’t have an effect. Any help appreciated.
The module insertion. Note HomeWeighting is a number field type:
{% component source: "Program", layout: "List Home", sortBy: "HomeWeighting", sortOrder: "DESC", object: "collection", collectionVariable: "program", type: "module" %}
The layout:
<section class="home-program">
<h1 class="home-program-title">Our Programs</h1>
<div class="home-program__wrapper">
{% comment %}First item is featured {% endcomment %}
<div class="home-program__items-wrapper home-program__items-wrapper--featured">
{% for program in this.items limit:1 %}
{% comment %}Select item color based on condition {% endcomment %}
{% if program['Condition'] == 'hypertrophic cardiomyopathy' %}
{% assign color = 'red' %}
{% elsif program['Condition'] == 'diastolic heart failure' %}
{% assign color = 'teal' %}
{% elsif program['Condition'] == 'systolic heart failure' %}
{% assign color = 'blue' %}
{% endif %}
<div class="home-program__item home-program__item--{{color}}">
<h2 class="home-program__title">{{program['Name']}}</h2>
{% if program['SubIndication1'] != '' and program['SubIndication1'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication1']}}</h3>
{% assign percentOfPhase = program['SubIndication1PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication1Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication1Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication1Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication1Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication1Phase']}}</p>
{% endif%}
{% if program['SubIndication2'] != '' and program['SubIndication2'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication2']}}</h3>
{% assign percentOfPhase = program['SubIndication2PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication2Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication2Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication2Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication2Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication2Phase']}}</p>
{% endif%}
{% if program['SubIndication3'] != '' and program['SubIndication3'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication3']}}</h3>
{% assign percentOfPhase = program['SubIndication3PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication3Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication3Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication3Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication3Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication3Phase']}}</p>
{% endif%}
{% if program['SubIndication4'] != '' and program['SubIndication4'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication4']}}</h3>
{% assign percentOfPhase = program['SubIndication4PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication4Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication4Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication4Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication4Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication4Phase']}}</p>
{% endif%}
{% if program['SubIndication5'] != '' and program['SubIndication5'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication5']}}</h3>
{% assign percentOfPhase = program['SubIndication5PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication5Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication5Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication5Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication5Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress home-program__progress--{{color}}" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication5Phase']}}</p>
{% endif%}
<a href="/programs#{{program['Name'] | replace: ' ', '-' | downcase}}">
<div class="home-program__detail">
<p class="home-program__detail-text">
<h2 class="home-program__title">{{program['Name']}}</h2>
{{program['ShortDescriptionHome'] | replace: "<p>", "" | replace: "</p>", "<br/>" | truncatewords: 20}}
</p>
</div>
</a>
</div>
{% endfor %}
</div>
{% comment %}Display remaning items in grid {% endcomment %}
<div class="home-program__items-wrapper">
{% for program in this.items offset:1 %}
{% comment %}Select item color based on condition {% endcomment %}
{% if program['Condition'] == 'hypertrophic cardiomyopathy' %}
{% assign color = 'red' %}
{% elsif program['Condition'] == 'diastolic heart failure' %}
{% assign color = 'teal' %}
{% elsif program['Condition'] == 'systolic heart failure' %}
{% assign color = 'blue' %}
{% endif %}
<div class="home-program__item home-program__item--{{color}}">
<h2 class="home-program__title">{{program['Name']}}</h2>
{% if program['SubIndication1'] != '' and program['SubIndication1'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication1']}}</h3>
{% assign percentOfPhase = program['SubIndication1PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication1Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication1Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication1Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication1Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress home-program__progress--{{color}}" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication1Phase']}}</p>
{% endif%}
{% if program['SubIndication2'] != '' and program['SubIndication2'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication2']}}</h3>
{% assign percentOfPhase = program['SubIndication2PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication2Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication2Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication2Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication2Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication2Phase']}}</p>
{% endif%}
{% if program['SubIndication3'] != '' and program['SubIndication3'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication3']}}</h3>
{% assign percentOfPhase = program['SubIndication3PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication3Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication3Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication3Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication3Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication3Phase']}}</p>
{% endif%}
{% if program['SubIndication4'] != '' and program['SubIndication4'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication4']}}</h3>
{% assign percentOfPhase = program['SubIndication4PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication4Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication4Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication4Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication4Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication4Phase']}}</p>
{% endif%}
{% if program['SubIndication5'] != '' and program['SubIndication5'] != null %}
<h3 class="home-program__subindication">{{program['SubIndication5']}}</h3>
{% assign percentOfPhase = program['SubIndication5PhaseComplete'] | plus: 0 | divided_by: 4 %}
{% if program['SubIndication5Phase'] == 'Preclinical' %}
{% assign percentComplete = 1 | plus: percentOfPhase %}
{% elsif program['SubIndication5Phase'] == 'Phase 1' %}
{% assign percentComplete = 25 | plus: percentOfPhase %}
{% elsif program['SubIndication5Phase'] == 'Phase 2' %}
{% assign percentComplete = 50 | plus: percentOfPhase %}
{% elsif program['SubIndication5Phase'] == 'Phase 3' %}
{% assign percentComplete = 75 | plus: percentOfPhase %}
{% endif %}
<div class="home-program__progress" style="width:{{percentComplete}}%"></div>
<p class="home-program__phase">{{program['SubIndication5Phase']}}</p>
{% endif%}
<a href="/programs#{{program['Name'] | replace: ' ', '-' | downcase}}">
<div class="home-program__detail">
<p class="home-program__detail-text">
<h2 class="home-program__title">{{program['Name']}}</h2>
{{program['ShortDescriptionHome'] | replace: "<p>", "" | replace: "</p>", "<br/>" | truncatewords: 100}}
</p>
</div>
</a>
</div>
{% endfor %}
</div>
</div>
</section>