The default behaviour will display the first listed page within the folder if the folder description/content is empty (so not necessarily the ‘index’ page).
This should all still be working by default. The default code in the Folder detail 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 %}
Note, though that the 404 page call here doesn’t actually work (remains from an older version of the CMS).
You can however, adjust the logic here for your own needs.
Also, I’m not 100% sure what you meant Alex by:
I have some folders that contained content, but now it has been removed and the content sitll displays.
Do you mean the folder contents (description area) or the contents of the folder (pages within)?
As an example of customising this logic, I’ve implemented the following to display a page within the folder that has the slug of /index
, else a fake 404 page/message:
{% if this['description'] != null %}
{{this['description']}}
{% else %}
{% capture indexPage %}{% component type:"module", source:"Page", layout:"Page Detail", filterBy:"url", filterValue:"{{this.url}}/index", limit:"1" %}{% endcapture %}
{% if indexPage == null %}
<p>404: Page not found.</p>
{% else %}
{{indexPage}}
{% endif %}
{% endif %}