Welcome Guest, Not a member yet? Register   Sign In
Pagination Config file Help
#1

[eluser]mikeymayhem[/eluser]
Hi,

just a quick question, I've moved my pagination config array into a file called pagination.php and saved it in the config/ folder as described in the user gallery. As I have pagination throughout my website I was trying to figure out how to make this re_usable.
Code:
/*
|-----------------------------------------------------------------------------|
|    1 base_url                                                               |
|-----------------------------------------------------------------------------|
*/

    $config['base_url'] = $base_url;
    //IE http://www.example.com/news/

/*
|-----------------------------------------------------------------------------|
|    2 Total num of items                                                     |
|-----------------------------------------------------------------------------|
*/

    $config['total_rows'] = $total;
    //the total number of items being paginated

/*
|-----------------------------------------------------------------------------|
|    3 per page                                                               |
|-----------------------------------------------------------------------------|
*/

    $config['per_page'] = $per_page;
    //total number items to be displayed per page

/*
|-----------------------------------------------------------------------------|
|    4 uri segment                                                            |
|-----------------------------------------------------------------------------|
*/

    $config['uri_segment'] = $segment;
    //the segemnt of the url to be used in pull items
    //from the database ie www.eample.com/seg1/seg2/seg3/seg4
The above code is from my pagination config file, basically I have four variables I need to make this config file re-usable throughout my site, $base_url,$per_page,$total and $segment. How can I achieve this if it is at all possible!

Any help or suggestions would be greatly appreciated!
#2

[eluser]InsiteFX[/eluser]
Load the pagination library, it should load the pagination.php

Also you can not use the string values!

You will not need to use the $this->pagination->initialize function.

InsiteFX
#3

[eluser]mikeymayhem[/eluser]
hey thanks for the reply,

maybe i was abit unclear, im simply wondering if i can set the values of the variables shown above IE
$config['base_url'] = $base_url;

outside of the pagination.php file so i could simply have the one config file for every time i use the pagination library and make it re-usable by setting the values i need for each specific time i use pagination in the variables $base_url,$per_page etc outside of the config/pagination file.
#4

[eluser]mikeymayhem[/eluser]
hey thanks for the reply,

maybe i was abit unclear, im simply wondering if i can set the values of the variables shown above IE
$config['base_url'] = $base_url;

outside of the pagination.php file so i could simply have the one config file for every time i use the pagination library and make it re-usable by setting the values i need for each specific time i use pagination in the variables $base_url,$per_page etc outside of the config/pagination file.
#5

[eluser]InsiteFX[/eluser]
Code:
$this->config->set_item('item_name', 'item_value');

But you may need to load the pagination.php file.

InsiteFX
#6

[eluser]mikeymayhem[/eluser]
thanks alot ill give that a try! ill post my results! Thanks again!
#7

[eluser]mikeymayhem[/eluser]
hi tried out your suggestion and it worked however its probably just as much code as having the config array in the controller so i guess its a bit pointless! Thanks for the help though




Theme © iAndrew 2016 - Forum software by © MyBB