CodeIgniter Forums

Full Version: configuration of any file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Rodrigo Alexandre[/eluser]
I created a configuration file paging (in the config folder, called paging), however, when I use $ this-> config-> load (paging) settings are not carried out, that's the way it has to be done?

El Forum

[eluser]Samus[/eluser]
More like this:

Code:
$this->config->load('paging');

But yeah..

El Forum

[eluser]Rodrigo Alexandre[/eluser]
does not work that way, I've tried

El Forum

[eluser]Samus[/eluser]
post your config code and what you're trying to do

El Forum

[eluser]Rodrigo Alexandre[/eluser]
$config['base_url'] = site_url('/profiles');
$config['total_rows'] = $all_reg;
$config['per_page'] = $amount_pag;

$config['full_tag_open'] = '<ul>';
$config['full_tag_close'] = '</ul>';
$config['prev_tag_open'] = '<li id="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li id="next">';
$config['next_tag_close'] = '</li>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li><strong>';
$config['cur_tag_close'] = '</strong></li>';

El Forum

[eluser]Samus[/eluser]
I don't think you can do pagination like that. Because you can only fetch single items when using the config class

El Forum

[eluser]Rodrigo Alexandre[/eluser]
I understand, no problem, I'll create a helper

El Forum

[eluser]Rodrigo Alexandre[/eluser]
I found the problem, the data must be passed as follows in the config file (pagination.php) within:

Code:
$config['full_tag_open']  = '<div id="pag"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['prev_tag_open']  = '<li id="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open']  = '<li id="next">';
$config['next_tag_close'] = '</li>';
$config['first_link']     = 'Home';
$config['first_tag_open'] = '<li>';
$config['first_tag_close']= '</p> </ li>';
$config['last_link']      = 'Last page';
$config['last_tag_open']  = '<li>';
$config['last_tag_close'] = '</p> </ li>';
$config['num_tag_open']   = '<li>';
$config['num_tag_close']  = '</li>';
$config['cur_tag_open']   = '<li><strong>';
$config['cur_tag_close']  = '</strong></li>';

and the controller:

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

$config['base_url']   = $url;
$config['total_rows'] = $all_reg;
$config['per_page']   = $amount_pag;

$config['num_links'] = $num_links;
$this->pagination->initialize($config);

El Forum

[eluser]Aken[/eluser]
Config file names must match the library you're loading if you want them to autoload from the config directory. Loading them through the Config class won't do anything except make the options available through $this->config->item() or config_item().

Your solution is the right way to do it. When you load the class, it will automatically pull a config file if it finds one. Then, you can use initialize() after that to add / override any options.