So let’s say I have a folder named ‘Fruit’ containing 3 pages named: ‘Apples’, ‘Bananas’, ‘Oranges’. By default, a link to /fruit would take you to the Apples page (the first alphabetically listed page) because the default Page Folder layout is:
{% if this['description'] != "" %}
{{this['description']}}
{% else %}
{% capture indexPage %}{% component type:"module", source:"Page", layout:"Page Detail", filterBy:"parentid", filterValue:"{{this.id}}", limit:"1" %}{% endcapture %}
{% if indexPage == "" %}
{% component type:"module", source:"Page", layout:"Page Detail", filterBy:"name", filterValue:"404" %}
{% else %}
{{indexPage}}
{% endif %}
{% endif %}
To make the /fruit link go to the Bananas page instead, I could use the code:
{% if this['description'] != "" %}
{{this['description']}}
{% else %}
{% capture indexPage %}{% component type:"module", source:"Page", layout:"Page Detail", filterBy:"parentid", filterValue:"{{this.id}}", limit:"1" %}{% endcapture %}
{% if indexPage == "" %}
{% component type:"module", source:"Page", layout:"Page Detail", filterBy:"name", filterValue:"404" %}
{% else %}
{% component type:"module", source:"Page", layout:"Page Detail", filterBy:"name", filterValue:"Bananas" %}
{% endif %}
{% endif %}
But this isn’t a good option because the ‘Bananas’ page might get deleted or renamed in the future. So I know I need to add an elsif to check whether the ‘Banana’ page exists but my liquid skills aren’t good enough to know how to do this. How do I write this, or do you suggest a better way?