Welcome Guest, Not a member yet? Register   Sign In
Pagination Config (Autoload)
#1

[eluser]Kunzilla[/eluser]
Hi,

i tried to autoload the pagination libary with an extra config file (/application/config/pagination.php), but it didnt work for me.

Code:
$autoload['libraries'] = array('database', 'session', 'email', 'form_validation', 'encrypt', 'pagination');

Code:
$autoload['config'] = array( 'pagination' );

/application/config/pagination.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['base_url'] = 'page/';
$config['total_rows'] = '200';
$config['per_page'] = '20';

The controller "user" looks:

Code:
class User extends CI_Controller {

    function index() {

        $this->load->model('admin/user_model');
              
        $data['results'] = $this->user_model->get_all();

        $this->pagination->total_rows = count( $data['results'] );


        $data['main_content'] = 'user/index';
        $this->load->view( 'admin/includes/template', $data );
    }

In the view i use this code:

Code:
<?=$this->pagination->create_links()?>

I want to put that stuff into a config file for global use. But i cant set the "base_url" without overwriting the $config['base_url] in the /config.php.

Can anyone help me?

Thanks
#2

[eluser]InsiteFX[/eluser]
You should not be autoloding the pagination config file, the pagination class will autoload it from application/config !

InsiteFX
#3

[eluser]Kunzilla[/eluser]
Ok, but how can i Set the Default values globaly?
#4

[eluser]InsiteFX[/eluser]
What are you trying to make global?

Any time you load the pagination class were you need it it will load your pagination configuration file!

InsiteFX
#5

[eluser]Kunzilla[/eluser]
Yes, that is what i Want. But i couldnt Set base_url for example. It will overwrite the application base URL.
#6

[eluser]InsiteFX[/eluser]
It will not over write your base_url because you are not using a set command on the config!

This is the only way it will change your base_url!
Code:
$this->config->set_item('item_name', 'item_value');

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB