0

I have made a very simple block that displays an array of strings as a list. I am achieving this by implementing hook_block_view() in my .module file. Right now the list displays ok, but I would like to paginate it so that only a few list items show at a time.

I am not getting the list from a database, I just have an array of strings as I mentioned before. I have been looking at theme_pager functions, but I am not sure how to use them to do what I need. Any help or examples would be greatly appreciated! Thanks!

Edit: I have found the following code here (Adding Pagination to to custom form block results) and I am having trouble making sense of this part of it: function latest_news() { $query = db_select('node', 'node'); $query = $query->fields('node', array('nid')) ->condition('node.status', 1) //Published. ->condition('node.type', 'auction_news'); $query = $query->extend('PagerDefault'); $result = $query->limit(20)->orderBy('node.created','DESC')>execute()>fetchAll(PDO::FETCH_ASSOC); $paging = theme('pager'); return theme('latest_news',array('data' => $result,'paging'=>$paging)); }

Could someone please explain how this part could be modified to use a simple list of strings instead of a database query? Thank you very much in advance!

2
  • You are using drupal7 or 8.I am assuming you are using drupal7 This link will help for you drupal.stackexchange.com/questions/121912/…
    – sivani
    Commented Jun 4, 2018 at 8:03
  • @sivani Thank you very much! I had seen that question before, but I had not been able to make sense of the part of it that I included in the edit to the question. Maybe you can help me understand the difference between the database query and the list of strings I have?
    – user85903
    Commented Jun 4, 2018 at 18:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.