Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

pagination not working with get

Open edenchen123 opened this issue 9 years ago • 2 comments

My client wants to exclude some tags at index.hbs page So I added below code to index.hbs, the filter works perfect, however the pagination doesn't work any more

 {{#get "posts" filter="tag:-'new-connections'"}}
      {{> "loop"}}
{{/get}}              

loop.hbs

{{#foreach posts}}
  ....
{{/foreach}}
{{pagination}}

also I tried move {{pagination}} outside of get, no lucky

Is it related to the limitation of get? https://themes.ghost.org/docs/get#section-limitations

Technical details:

  • Ghost Version:0.11.9

edenchen123 avatar Sep 14 '17 04:09 edenchen123

Is it related to the limitation of get?

Yes.

From https://themes.ghost.org/docs/get#section-limitations:

{{pagination}} won't output anything sensible when used inside {{#get}} block - because the get helper can only fetch existing data, it doesn't create a /page/2/ version of the data you are fetching. If you're looking for something like this, you're probably looking for channels (coming soon).

You have to wait for the channels feature, which is coming soon, to be able to filter the posts for a whole page.

The only way to use the get helper with pagination is {{#get "posts" page=pagination.page}}, but with this you can't filter by tag, because the result of the get query and the result from the pagination (e.g. /posts/2) is different. Furthermore if you want to use pagination.page for scrolling, the value would stick to the initial value when you've loaded the page. The {{pagination}} helper only provides a form to show prev/next pages based on all your published posts.

If you have any further questions, please swing by our slack community and ask anything you want in the #themes channel.

kirrg001 avatar Sep 14 '17 11:09 kirrg001

I have added pagination in a separate page other than index.hbs, but the pagination is not working , the prev and next button links to the same page URL. Reference code-

                {{#get "posts" include="authors" filter="featured:false" limit="9" as |more_posts| }}

                    {{#if more_posts}}
                        {{#foreach more_posts}}
                            <div class="col-lg-4 col-md-6 offset-md-0 col-12 mt-2 mb-3">
                                {{> "post-card"}}
                            </div>
                        {{/foreach}}
                        {{pagination}}
                    {{/if}}
                {{/get}}

abhinavaa01 avatar Jan 14 '23 04:01 abhinavaa01