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

Add limit and offset parameters to nav tag #1127

Closed
jasonvarga opened this Issue Nov 25, 2016 · 10 comments

Comments

Projects
None yet
6 participants
@jasonvarga
Member

jasonvarga commented Nov 25, 2016

No description provided.

@sebszocinski

This comment has been minimized.

sebszocinski commented Mar 23, 2017

+1

@beeldr

This comment has been minimized.

beeldr commented Aug 2, 2017

I'm having the same issue as this guy, is there any progress on this issue?

@rickysalsberry

This comment has been minimized.

rickysalsberry commented Sep 18, 2017

+1 – this would be useful. Thanks!

@mrkaluzny

This comment has been minimized.

mrkaluzny commented Sep 25, 2017

+1 Still not done? Wow.

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Sep 25, 2017

It doesn't really make sense to have this on the nav tag. If you want to just list and filter and control your pages, you can use the Pages Tag. The Nav tag is meant to output your structured nav. You start throwing away your structure arbitrarily with limit/offset and it can lead to totally unexpected results if someone decides to rearrange some pages.

@mrkaluzny

This comment has been minimized.

mrkaluzny commented Sep 25, 2017

@jackmcdade It makes sense if you have a custom menu that's divided into different segments. Limit makes it easier for people working with Statamic's backend to set the nav the way they want. The structured nav works well with "classic" navbars, but something more complicated and it's really hard to create a flexible and editable nav + you can't use nav variables ;)

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Sep 25, 2017

What about the Pages tag though? Wouldn't that let you grab things however you want?

@mrkaluzny

This comment has been minimized.

mrkaluzny commented Sep 25, 2017

@jackmcdade I can do that, but the problem with checking which link still persists. The more optimal way to do that would be limiting with the nav tag.

{{ nav from="/" exclude="/in-person|/services|/contact|/blog" }}
  <li class="nav-item {{if is_current}} active {{endif}}">
    <a class="nav-link" href="{{ url }}">{{ title | lower}}</a>
  </li>
 {{ /nav }}

That's my current solution which isn't optimal at all. With limit property, anyone can easily reorder pages in the nav but not completely (excluded one's will always be excluded), but the is_current is probably worth the tradeoff. But maybe I'll switch to Pages tag after all...

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Sep 25, 2017

You could make that less brittle by just adding a toggle fieldtype and then filtering those pages out. Something like hide_from_nav.

{{ nav from="/" hide_from_nav:isnt="true" }}
...
{{ /nav }}
@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Sep 25, 2017

All things considered though, who are we to judge? It'll be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment