用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3753|回复: 6
收起左侧

[已解决] 照着分页教程,然后改了一下相关内容,报错了。。

[复制链接]
发表于 2010-4-30 16:21:55 | 显示全部楼层 |阅读模式
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader:pagination
Filename: views/defult.php
Line Number: 76


Fatal error: Call to a member function create_links() on a non-object in D:\wamp\www\ci\system\application\views\defult.php on line 76

这是什么原因。。。。
发表于 2010-4-30 16:25:11 | 显示全部楼层
无码。。。。。。。。。。
 楼主| 发表于 2010-4-30 16:28:27 | 显示全部楼层
本帖最后由 atxlin 于 2010-4-30 16:29 编辑

//分页
                function page() {
                        $this->load->library('pagination');
                        $config['base_url'] = base_url().'/custom/page/';
                        $config['total_rows'] = $this->db->count_all('custom');
                        $config['per_page'] = 5;
                        $config['uri_segment'] = 3;           
                        $config['full_tag_open'] = '<p>';
                        $config['full_tag_close'] = '</p>';
                 
                        $this->pagination->initialize($config);
        
                        $this->load->model('custom_model');
                        $data['results'] = $this->custom_model->get_books($config['per_page'],$this->uri->segment(3));

                        $this->load->view('defult', $data);
                }






//分页
                function get_books($num, $offset) {
                                $query = $this->db->get('custom', $num, $offset);        
                                return $query;
                }




$config['base_url'] = "http://localhost/ci/";

index.php我根据教程去掉了

<?php echo $this->pagination->create_links(); ?>
发表于 2010-4-30 19:56:43 | 显示全部楼层
还是老问题,你在控制器里加载了分页类,然后在视图里用,怎么可以呢???
你要在控制器里把分页缓存下来呀
$data['links'] = $this->pagination->create_links();
然后在view里直接echo $links
发表于 2010-5-1 12:27:44 | 显示全部楼层
先看到你的defult.php,应该是default吧!
 楼主| 发表于 2010-5-4 11:23:42 | 显示全部楼层
终于把分页搞定了,感谢各位帮忙
发表于 2012-12-6 10:15:03 | 显示全部楼层
想问问为什么一定要在controller下实现?VIEW不行么?

本版积分规则