Hey so I am using handlebars pagination https://github.com/olalonde/handlebars-paginate
for my back end I am configuring it like that
pagination: {
page: page,
pageCount: pages.length,
active: true,
category:currentCategory
}
and on the front end I am reading it like that:
<div class="paginator">
<div class="btn-group" role="group" aria-label="...">
<nav aria-label="Page navigation">
<ul class="pagination">
{{#paginate pagination type="first"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="/blog/category/{{{pagination.category}}}/{{n}}" aria-label="First">
<span aria-hidden="true">«</span>
<span class="sr-only">First</span>
</a>
</li>
{{/paginate}}
{{#paginate pagination type="previous"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="/blog/category/all/{{n}}" aria-label="Previous">
<span aria-hidden="true">‹</span>
<span class="sr-only">Previous</span>
</a>
</li>
{{/paginate}}
<!--{{#paginate pagination type="middle" limit="6"}}-->
<!--<li class="page-item">-->
<!--<a class="page-link{{#if disabled}} disabled{{/if}}"-->
<!--href="/blog/category/all/{{n}}">{{n}}</a>-->
<!--</li>-->
<!--{{/paginate}}-->
{{#paginate pagination type="middle" limit="7"}}
<li {{#if active}}class="active" {{/if}}> <a class="page-link" href="/blog/category/all/{{n}}">{{n}}</a>
</li>
{{/paginate}}
{{#paginate pagination type="next"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="/blog/category/all/{{n}}" aria-label="Next">
<span aria-hidden="true">›</span>
<span class="sr-only">Next</span>
</a>
</li>
{{/paginate}}
{{#paginate pagination type="last"}}
<li class="page-item{{#if disabled}} disabled{{/if}}">
<a class="page-link" href="/blog/category/all/{{n}}" aria-label="Last">
<span aria-hidden="true">»</span>
<span class="sr-only">Last</span>
</a>
</li>
{{/paginate}}
</ul>
</nav>
</div>
</div>
my issue is here:
when I try to inject this variable to the url of the pagination it never shows. I tried to use {{}} and three curly {{{}}} but it never show up. I also tried to handle it like that on the back end:
pagination: {
page: page,
pageCount: pages.length,
active: true,
},
category:currentCategory
and read it but it also don't show up. how I can inject this variable to my pagination url ?
so actually in to order to do this I had to create a handlebars helper and then use it. so this was my helper:
Handlebars.registerHelper( "getCategory", function (f){
return '/blog/category/'+currentCategory + '/' + f;
});
the (f) is nothing but just to make it work! and get the links right. and then on the view I used it simple:
href="{{getCategory n}}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.