Current Version of Codefight CMS Available for Download:

            « Version 1.1.4 »

            NOTE: The code available is same as the code used for this site at the time of release.

            Codefight CMS is based on Codeigniter PHP Framework which is very easy to learn.

            It would be nice to hear back some feedback. Also you can contribute with code and helping translating language files in your language.

            You can use this CMS in anyway you want. You can modify as you like and use commercially for free.

 

Select Language.[TESTING For Next Release.]

English | नेपाली | French | German | Korean

Login | Select Language | Thu, 11 Mar 10 17:46:31 -0700

Addition Of Codeigniter Pagination To Codefight CMS

2009-03-20 18:09:40Damodar Bashyal

 

Today I would like to archive my codeigniter pagination addition into my CMS.

My page entries were increasing gradually, so the page size was increasing and it didn't look too good to have multiple entries on the same page. So i thought now its time to add pagination. I had used pagination few years back when I was working at previous company 'visiontech digital media'. But i had totally forgotten by now. So checked the userguide and followed the process as:

frontend/config/pagination.php
CODE:

1-
2-<?php
3-//The number of links you want to show before and after of current page link
4-$config['num_links'] = 2;
5-
6-//The opening tag placed on the left side of the entire result.
7-$config['full_tag_open'] = '<div class=“page_numbers“>';
8-
9-//The closing tag placed on the right side of the entire result.
10-$config['full_tag_close'] = '</div>';
11-
12-//The text you would like shown in the “first“ link on the left.
13-$config['first_link'] = '? First';
14-
15-//The opening tag for the “first“ link.
16-$config['first_tag_open'] = '<div class=“first“>';
17-
18-//The closing tag for the “first“ link.
19-$config['first_tag_close'] = '</div>';
20-
21-//The text you would like shown in the “last“ link on the right.
22-$config['last_link'] = 'Last ?';
23-
24-//The opening tag for the “last“ link.
25-$config['last_tag_open'] = '<div class=“last“>';
26-
27-//The closing tag for the “last“ link.
28-$config['last_tag_close'] = '</div>';
29-
30-//The text you would like shown in the “next“ page link.
31-$config['next_link'] = '>';
32-
33-//The opening tag for the “next“ link.
34-$config['next_tag_open'] = '<div class=“next“>';
35-
36-//The closing tag for the “next“ link.
37-$config['next_tag_close'] = '</div>';
38-
39-//The text you would like shown in the “previous“ page link.
40-$config['prev_link'] = '<';
41-
42-//The opening tag for the “previous“ link.
43-$config['prev_tag_open'] = '<div class=“previous“>';
44-
45-//The closing tag for the “previous“ link.
46-$config['prev_tag_close'] = '</div>';
47-
48-//The opening tag for the “current“ link.
49-$config['cur_tag_open'] = '<div class=“current“>';
50-
51-//The closing tag for the “current“ link.
52-$config['cur_tag_close'] = '</div>';
53-
54-//The opening tag for the “digit“ link.
55-$config['num_tag_open'] = '<div class=“digit“>';
56-
57-//The closing tag for the “digit“ link.
58-$config['num_tag_close'] = '</div>';
59-?>
60-
frontend/controllers/page.php
CODE:

1-
2-<?php
3-$menu_id = $this->uri->segment(2, 1);
4-
5-//On clicking more link of the page blurb show full text
6-$page_id = $this->uri->segment(3, 0);
7-
8-//pagination
9-$page = $this->uri->segment(4, 0);
10-/*
11- * START: Pagination config and initialization
12- */

13-$this->load->library('pagination');
14-if(!$page_id)$page_id = 'home';
15-$config['base_url'] = base_url() . “page/$menu_id/$page_id/“;
16-$config['total_rows'] = $this->page_model->get_page_count($menu_id);
17-$config['per_page'] = '5';
18-$config['uri_segment'] = 4;
19-$config['num_links'] = 2;
20-
21-$this->pagination->initialize($config);
22-//END: Pagination
23-
24-$data['pagination'] = $this->pagination->create_links();
25-//Get page content for the selected menu item.
26-$data = $this->page_model->get_page_contents($menu_id, $config['per_page'], $page);
27-?>
28-
frontend/models/page_model.php
CODE:

1-
2-<?php
3-function get_page_count($menu_id = '0') {
4-$this->db->where(array('menu_id' => $menu_id, 'pages_active' => '1'));
5- return $this->db->count_all_results('pages');
6-}
7-
8-function get_page_contents($menu_id = '0', $per_page = '5', $page = '0') {
9-$this->db->join('pages_access', 'pages.pages_id = pages_access.pages_id');
10-$this->db->order_by('pages.pages_sort', 'asc');
11-$this->db->limit($per_page, $page);
12-$query = $this->db->get_where('pages', array('pages.menu_id' => $menu_id, 'pages.pages_active' => '1'));
13-$data1 = $query->result_array();
14-
15-$data = '';
16-if(is_array($data1) && count($data1) > 0) {
17-$data['meta'] = $this->meta_fetch($data1[0]);
18-$data['content'] = $data1;
19- } else {
20-$data['meta'] = $this->defaults();
21-$data['content'] = array();
22- }
23- return $data;
24-}
25-?>
26-
frontend/views/page_view.php
CODE:

1-
2-<?php
3-if(isset($pagination)) echo$pagination;
4-?>
5-

Thanks to godbit for better tutorial than codeigniter userguide.


Bookmark and Share
 

 





Javascript must be enabled to post comments!