-
Notifications
You must be signed in to change notification settings - Fork 416
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
Best / recommended way to add an anchor to a generated URL #8
Comments
OK, I think I've answered this myself. I went with:
|
@MSeneadza: your example will work, but I am not sure you really have to override the The anchor segment in the URL will be maintained if it is already in the page URL. If your pagination is at: Is that working? Or do you have a different issue? |
@ddnexus That makes sense in the general case but here's my situation. Users generally enter that page via a link without the anchor. So, for example But, I'm happy with overriding Thanks for the quick response. |
So that is a static part of all your pagination links, used just to position the content in the browser window. Weird way to do it, but yeah, in that case the overriding the Just a suggestion: the |
An additional parameter for the One use case that I can think of is when one has two collections on one page, each displayed in its own Bootstrap tab. So when you navigate the second collection inside the second tab, you'll want the second tab to be shown automatically when the next page loads, which could be easily achieved with something like this:
|
Even better (and it works already): pagy @pagy_users, page: param[:custom_param_name] |
I think my comment was hard to understand. I edited the code, so it should be clearer now. |
Your example |
Its |
So no plans to enable the addition of arbitrary parameters? See my comment above or this Kaminari issue, why this would be really helpful. |
All the variables can be passed to the |
That should suffice, but how would one add an anchor via the |
@cseelus Please, create a new issue for this one, because anchor and URL manipulation could be the subject of some discussion/enhancement. Also, please, add some practical example that would require adding a new feature. Thanks |
found out that you can use |
It's not weird, sometimes you need to show additional information on a category page, like a big header + information, and then have the listings ... so when you paginate, just go to the listing and skip the initial headers. I was requested to implement something like that. |
@brusacco that's what I was thinking 6 years ago 😁 You can use |
Yes :) ... sorry I was having this issue this week. |
It wasn't a complain: no need to be sorry. I just meant to say that I was not getting the use case years ago, but pagy has |
I just discovered Pagy and I really like the performance & RAM benefits vs. Kaminari, which I've been using. I'm trying to add an anchor to my pagination links. With Kaminari I was able to do:
paginate @equities, window: 1, params: { anchor: 'results_section' }
to produce links like:
https://swingtradebot.com/equities?page=2#results_section
What's the simplest / cleanest / recommended way to do the same with Pagy? I was hoping
link_extra
would do it but I was wrong. Would overridingpagy_url_for
be the way to go?The text was updated successfully, but these errors were encountered: