0

The current default pager in Views Paging Drupalgap is easily neglected.

screenshot

Can I assign it a new icon or create my own pager button? Currently, what I know is to put it at the top or the bottom using pager_pos: 'bottom', but nothing else.

  • Did you try taking over the theme_pager_link() function in your theme? api.drupalgap.org/7/global.html#theme_pager_link - For example, implement: my_theme_pager_link() – tyler.frankenstein Aug 24 '17 at 2:50
  • Thank you for your reply. I saw the theme_pager_next the text is text: '»',. Do you mean I modify that in src/modules/views/views.js? – artphys Aug 24 '17 at 17:23
  • I modified bin/drupalgap.min.js and it works, but it seems not very appropriate to change this file. Is there a place I can put my custom theme_pager? – artphys Aug 24 '17 at 17:43
  • I meant copy the contents of theme_pager_link(), and then create a new function called my_theme_pager_link() in your theme's .js file, then when it comes time to render, DrupalGap we'll see if the active theme is overriding that particular theme function, then it'll use that instead of the core one. That way you don't have to modify core. – tyler.frankenstein Aug 24 '17 at 17:58
  • thanks. by the way, in your document docs.drupalgap.org/7/Themes/Create_a_Custom_Theme, there's a typo in the footer code. 'data-position': 'b', it should be 'data-theme': 'b'. – artphys Aug 24 '17 at 19:15
0

Thanks to Tyler. I follow his suggestion and have solved this by adding the theme_pager_link() to app/themes/my_theme/my_theme.js. Here is what I added:

function my_theme_pager_next(variables) {
  try {
    var html;
    variables.page = parseInt(variables.results.view.page) + 1;
    var link_vars = {
      text: 'Next Page',
      attributes: {
        'class': 'pager_next',
        'data-icon': 'fast-forward'
      }
    };
    html = theme_pager_link(variables, link_vars);
    return html;
  }
  catch (error) { console.log('my_theme_pager_next - ' + error); }
}

function my_theme_pager_previous(variables) {
  try {
    var html;
    variables.page = parseInt(variables.results.view.page) - 1;
    var link_vars = {
      text: 'Previous Page',
      attributes: {
        'class': 'pager_previous',
        'data-icon': 'fast-backward'
      }
    };
    html = theme_pager_link(variables, link_vars);
    return html;
  }
  catch (error) { console.log('my_theme_pager_previous - ' + error); }
}

now the pager become like this: enter image description here

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.