Welcome Guest, Not a member yet? Register   Sign In
Manual pagination problem in CI4.
#1

Hello,

Sorry for my english

I have the following problem when paging manually,

I can't make the pager links look good.

I need the following links:

http://localhost/test_pagination/index.p...cto/list/1 <--- page
http://localhost/test_pagination/index.p...ect/list/2
http://localhost/test_pagination/index.p...cto/list/3 .... etc

in the controller
function list ($page = 1 ,,,,,,) {

And the pager gives me the following:

http://localhost/project/list/1 ....
http://localhost/project/list/2 ....
http://localhost/project/list/3 ....
With $ pager->setPath (); I can not configure the links as in ci3,

$ this-> load-> library ('pagination');
$ config = $ this-> pager_config;
$ config ['base_url'] = site_url ('project / list /');

Does anyone have the same problem?




PHP Code:
$data_db $this->proyecto_model->list_proyecto $data_search$limit$page);
$total_rows $this->proyecto_model->list_proyecto_all $data_search );
$pager = \Config\Services::pager();
//$pager->setPath();
$data ['pagination'] = $pager->makeLinks($page$limit$total_rows'paginador_bootstrap'$uri_segment); 
Reply
#2

I solved my problem but I don't know if it will be the correct way.

I have my system configured with the following path

PHP Code:
App.php
public $ baseURL 'http://localhost/test'


The $pager->setPat() function; return "localhost" only

By adding $_SERVER['PHP_SELF'] I can fill in the required url.

PHP Code:
$pager->setPat($_SERVER['PHP_SELF']) 


http://localhost/test/index.php/proyecto......?page=1..........




PHP Code:
    $page $this->request->getGet 'page' ) ? $this->request->getGet 'page' )  0

    $data_db 
$this->proyecto_model->list_proyecto $data_search$limit$page );
        
    
$total_rows $this->proyecto_model->list_proyecto_all $data_search );

    
$pager = \Config\Services::pager();

    
$pager->setPath($_SERVER['PHP_SELF']);

    
$data ['pagination'] = $pager->makeLinks($page$limit$total_rows'paginador_bootstrap'); 
Reply
#3

That is wrong your base url should be set to the root of the application.

PHP Code:
public $baseURL 'http://localhost/'

Did you try using the method setPath?

PHP Code:
$pager->setPath(base_url('test_pagination/index.php/proyecto/list/'), 'Test-group'); // Additionally you could define path for every group.

$data ['pagination'] = $pager->makeLinks($page$limit$total_rows'paginador_bootstrap'$uri_segment, , 'Test-group'); 

See if that works for you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(This post was last modified: 07-14-2020, 05:44 PM by hugoafr.)

Hello,

Thanks for the collaboration, the following instruction returns the following:

$ pager-> setPath (base_url ('test_pagination / index.php / project / list /'))---> http://localhost/http://localhost/test_paginatio ...........  localhost is duplicated in url ,,,,


the solution as you indicate is to put the following path to base_url ,,,, but it is not very elegant,

in ci2/3 it is simple

PHP Code:
this-> load-> library ('pagination');
config = $ this-> pager_config;
config ['base_url'] = site_url ('proyecto/ index/ list /'); 
Reply
#5

(This post was last modified: 07-15-2020, 08:06 AM by InsiteFX.)

Being as I see that you have index.php in there use site_url() instead.

It should work using the segment if your controller is running it all.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB