0

How can I do this for Drupal 8?

I have searched for a solution but I didn't find anything yet, I hope some one here can help me.

I have this "pager.html.twig" (from the clasy theme) template in the path of my own theme, the path is "mytheme/templates/navigation/pager.html.twig" and this is rendered automatly by drupal in the views where the pager is requiered, but I have a requierement in my job that I have to place the pagination at the top and the bottom from my view.

Example:

<[1|2|3|4|5|6|7|8|9|10]> (this is the pager that I want to place on top)

content of my view content of my view content of my view content of my view content of my view content of my view content of my view content of my view

<[1|2|3|4|5|6|7|8|9|10]> (this is the drupal rendered pager automatly)

Thanks in advace for the help.

  • 1
    You can simply copy the Views template for this and duplicate the pager variable. – Kevin Jul 16 '18 at 23:35
  • But if I duplicate to "pager_top.html.twig" and print in my view for example "{{ pager_top }}" nothing happens whend I saved and clean cache, the view still showing the same whitout changes. – JASHIROU PRO TIPS Jul 17 '18 at 16:11
  • That’s not going to do anything. You need to look at the Views templates. – Kevin Jul 17 '18 at 16:40
  • Can you explainme whit an example please? I don't get at all that you said me... I have the views templates, but this in particular render automatly the pager, ins't print on the view. :/ – JASHIROU PRO TIPS Jul 17 '18 at 17:21
2

Ok, I solved it.

In my theme, I had copied all the content of classy theme because is like a copy of this.

In the theme exist an "templeate" folder, this have another folder called "views" inside this folder exist the file called "views-view.html.twig" in this file exist a few printing variables whit if conditions. All I had to do was copy the:

{% if pager %}
 {{ pager }}
{% endif %}

Condition almost at the end of the "template" and paste it where is above the content and voilà, I have my pager at the top and the bottom of my template.

I hope this be useful for anybody.

Thanks for your comments.

0

The first thing that popped into my mind, without testing, is that you can use a preprocess page function in your theme and add to variables a clone of the pager then you have to print (pager_2) in a modified page template.

  • Have I to duplicate de view first? if I have "pager.html.twig" and rename it like "pager_top.html.twig" then how can I print this varialbe? something like this {{ pager_top }}? I tried this way and nothing happens in my view, still showing the same whitout changes. :( Or I have to do something else on the core? Thanks for your answer. – JASHIROU PRO TIPS Jul 17 '18 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.