Welcome Guest, Not a member yet? Register   Sign In
create_links() making a fatal error
#1

[eluser]Märt[/eluser]
I'm trying to use paginate class but one function is causing a error. If I write a following thing: $this->paginate->create_links() then I get following error:
Fatal error: Call to a member function create_links() on a non-object in...
Everything else is working when I remove that line.

I use it in model:
$page = array('posts_listing' => $posts_page,
'make_links' => $this->paginate->create_links());

If more details are needed then I can give them. Hopefully someone can help me.

Thank You!
#2

[eluser]therealmaloy[/eluser]
mart

kindly check the loading of your pagination library.

and to use it, it might be something like this:

Code:
$this->load->library('pagination');

....

$this->pagination->create_links();

let us know what happen. Smile
#3

[eluser]Märt[/eluser]
Paginate library is loaded correctly, because I tested it by entering offsets manually to url: blog/index/5 for example (when I'm not using create_links function).

If I use create_links() function then I get this fatal error. Everything else is working.

This is my controller that loads module:
Code:
function index()
    {
        $this->load->model('Blog_posts', 'blog');
        echo $this->blog->load_posts();
    }

This is my model:

Code:
<?php
class Blog_posts extends Model {

    function Blog_posts()
    {
        parent::Model();
    }

    function load_posts()
    {
    $this->load->database();
    $this->load->helper('url');
           $this->load->library('parser');
           $config['base_url'] = base_url().'blog';
           $config['uri_segment'] = 3;
           $config['total_rows'] = $this->db->count_all('posts');
           $config['per_page'] = '5';
           $config['full_tag_open'] = '<p>';
           $config['full_tag_close'] = '</p>';
           $list = $this->db->get('posts',$config['per_page'],$this->uri->segment(3));
           $posts_page = '';
           foreach ($list->result_array() as $item)
           {
               $array = array(
                'post_id' => $item['id'],
                'post_title' => $item['post_title'],
                'post_body' => $item['post_body'],
                'meta' => $item['date']);
        $posts_page .= $this->parser->parse('blog_post', $array, TRUE);
           }
           $this->load->library('pagination');
           $this->pagination->initialize($config);
           $page = array('posts_listing' => $posts_page,
              'make_links' => $this->paginate->create_links()); //if i remove $this->paginate->create_links() then everything is working (except I do not have links)
           $this->parser->parse('blog_posts_listing',$page);
    }
}

Hopefully you understand what I'm trying to say.
#4

[eluser]therealmaloy[/eluser]
Mart

change this:

Code:
$page = array('posts_listing' => $posts_page,
              'make_links' => $this->paginate->create_links());

to this:

Code:
$page = array('posts_listing' => $posts_page,
              'make_links' => $this->pagination->create_links());


check out the $this->pagination not $this->paginate, remember you loaded a pagination class not paginate class, as i've stressed on my first post...

try this again and let us know...
#5

[eluser]Märt[/eluser]
Sorry, I didn't noticed that at yours first post. That worked nicely. I guess I need to read more carefully :lol:
Anyway. Thank you!




Theme © iAndrew 2016 - Forum software by © MyBB