Created
March 10, 2015 14:25
-
-
Save markgoodyear/045c2cbe6a4f23ec0a65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Get the IDs of all the sections #} | |
{% set currentSectionId = entry.id %} | |
{% set allSectionIds = craft.entries.section('myStructure').level(1).ids() %} | |
{# Define var before loop #} | |
{% set sectionNumber = '' %} | |
{# Loop through all section IDs and find the one that matches the current #} | |
{% for key, sectionId in allSectionIds if sectionId == currentSectionId %} | |
{# Use array key to calculate the section's position #} | |
{% set sectionNumber = key + 1 %} | |
{% endfor %} | |
{# Credit: http://craftcms.stackexchange.com/questions/1779/display-number-based-on-position-in-structure-hierarchy/1781#1781 #} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment