Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nav entry and iterator variable in loops #1283

Open
littleAmused opened this issue Dec 12, 2024 · 0 comments
Open

Nav entry and iterator variable in loops #1283

littleAmused opened this issue Dec 12, 2024 · 0 comments

Comments

@littleAmused
Copy link

littleAmused commented Dec 12, 2024

Unfortunately, when trying to display a recursive navigation structure in somewhat more complex HTML, you quickly reach the limits with the Antlers tags.

I particularly miss loop variables, such as those provided by Twig for example. Specifically, something like {{ iterator }}, {{ is_first }} and {{ is_last }} would be useful here.

In addition, custom antler variables in the magic variable {{ *recursive children* }} are not taken into account, i.e. a manual counter is also not possible recursively - could this possibly be a bug?

{{ counter = 0 }}

<ul>
  {{ nav:my_handle }}
    <li>{{ counter }}: <a href="{{ url }}">{{ title }}</a></li>

    {{ if children }}
      <!-- counter will not be incremted, if *recursive child* is called -->
      {{ counter = counter + 1 }}

      <ul>{{ *recursive children* }}</ul>
    {{ /if }}
  {{ /nav:my_handle }}
</div>

It would also be helpful if a {{ nav:collection:pages }} tag could also be assigned with an offset parameter so that, for example, only the subpages can be output recursively, or a page tree starting from any point (e.g. current page or parent page). The current examples in the documentation only shows snippets for one level, but not recursively.

Please let me know what you think.

Best regards, LA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant