I have a small problem with adding pagination. I wrote my own dedicated module for news and i want to add a pagination on news list site. On template i have:
{exp:news:show_list} html here with news list {exp:news:show_list}
and next i need a paginations controls. Function “show_list” returns an array with all entries for module.
[…] foreach ($query->result_array() as $id => $row) { $variables[$id] = array( ‘news_id’ => $row[‘news_id’], ‘added_date’ => $row[‘added_date’], ‘title’ => $row[‘title’], ‘short_content’ => $row[‘short_content’], ‘url’ => ”, //TODO: create url ‘hide_date’ => $row[‘is_date_hidden’] ); if($row[‘image’]) { $variables[$id][‘image’] = BASE_URL.’system/public/news/’.$row[‘image’]; $file = explode(‘.’, $row[‘image’]); $fileExt = array_pop( $file ); $variables[$id][‘image_thumb’] = BASE_URL.’system/public/news/’.implode(‘.’, $file).’_thumb.’.$fileExt; } } $output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables); return $output;
So, how i can add a pagination for it? Should i work with template or with PHP function?
Moved to Development and Programming by Moderator
You can add pagination inside of your module.
Here is a little push in the right direction: http://ellislab.com/codeigniter/user-guide/libraries/pagination.html
Also take a look at create_pagination method in the Channel module file (mod.channel.php).
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.