Welcome Guest, Not a member yet? Register   Sign In
Pagination inquiry for this n00b!
#1

[eluser]stevefink[/eluser]
Yay, I'm officially labeling myself a n00b. :-)

I appreciate the time anyone who enters a thread with 'paginatin' in the topic as well. :-)

Either way, here it is plain and simple. My controller's constructor looks like this:

Code:
function inventory()
    {
        parent::Controller();
        $this->load->model('Autodb_model', 'autodb');
        $this->load->library('session','pagination');
    }

and within the controller, is my method for displaying an inventory:

Code:
function client_side()
    {        
        // client side inventory view.
        // This is VERY similar to the live() method
        // which retrieves the data we need for current
        // live vehicles. Let's grab this data.
        $data['opts'] = $this->autodb->get_vehicle_options();
        
        // config params for pagination
        $config['base_url'] = 'http://'.base_url().'/inventory/client_side';
        $config['total_rows'] = count($data['opts']);
        $config['per_page'] = '10';
        $config['uri_segment'] = 2;
        
        $this->pagination->initialize($config);
        
        $this->load->view('client/inventory_view', $data);
    }

[/code

Then within my view I execute the following code:

[code]

                &lt;!--<h5><a href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">Next</a> <a href="#">>></a></h5>--&gt;
                &lt;?= $this->pagination->create_links() ?&gt;

Any idea why the pagination class isn't properly being loaded?
---

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Inventory::$pagination

Filename: controllers/inventory.php

Line Number: 67

Thanks for looking, folks!

- sf
#2

[eluser]stevefink[/eluser]
Well, it works fine when I put:

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


into the method, not sure why I can't use $this->load->library('session','pagination'); in the constructor. Would love to learn if anyone feels like schooling me. :-)
#3

[eluser]Michael Wales[/eluser]
The library method of the Loader class accepts parameters as the second parameter. Therefore this line:
Code:
$this->load->library('session','pagination');
Is loading the session library and passing it a parameter of pagination.

You got your helper() and library() methods a bit confused - it happens to me all the time.
#4

[eluser]stevefink[/eluser]
Thanks Michael! How're ya doing btw? Just finishing up http://www.f1autoimports.com before I submit it as my first completed CI project. (few things on the CSS side I need to fix up) but I'm almost there.

Got pagination working btw, thank you greatly to also CodeOfficer on IRC. :-)

http://www.f1autoimports.com/inventory

Still haven't started my next project. I'm still contemplating between CI/EE or ZenCart for my shopping cart... aaaaah!!! The decision is KILLING ME! I so want to stay with this community, :-( Just hard to avoid a product that caters to a cart specifically...
#5

[eluser]Michael Wales[/eluser]
Check out EE's addons/plugins - I'm sure there is a cart module available.

I've been thinking of switching to EE Core for my blog... just to learn my way around the system as I am considering using EE for a future project of mine.
#6

[eluser]gunter[/eluser]
yes, you meant this:
Code:
$this->load->library(array('session','pagination'));




Theme © iAndrew 2016 - Forum software by © MyBB