This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
wesley19118
Hi, here's the json data on page: {% set
allPlans = {
'plan-j':{
url:'plans'|page({tab:'plan-j'}),
txt:'Plan J',
active: true
},
'plan-k':{
url:'plans'|page({tab:'plan-k'}),
txt:'Plan K',
active: false
},
'plan-l':{
url:'plans'|page({tab:'plan-l'}),
txt:'Plan L',
active:true
}
}
%}
I want to do is something like:
{% if allPlans[this.param.tab]['active'] or ### length of allPlans items that active = false > 1 ### %}
<section class="more-plans">
Old Plans:
{% for key, plan in allPlans if tab.active==false %}
{{ loop.index !=1 ? ' | ' }}<a href="{{'plans'|page({plan:key})}}" target="_top">{{ key |replace({ 'plan-':''})}}</a>
{% endfor %}
</section>
{% endif %}
how do I do this? I don't find from the document.
Thanks for help in advance.
Last updated
wesley19118
after studying the Twig page, done with a stupid way:
{% set oldPlanNum = 0 %}
{% for plan in allPlans if plan.active==false %}
{% set oldPlanNum = oldPlanNum+1 %}
{% endfor %}
{% if allPlans[this.param.tab]['active'] or oldPlanNum>1 %} ..... {% end if %}
Last updated
1-2 of 2