Welcome Guest, Not a member yet? Register   Sign In
Routing issue - Pagination not working properly
#11

[eluser]Mauricio de Abreu Antunes[/eluser]
I'm still getting error!

Again: if i dont use routes, when i go for http://localhost/percutz/noticias/2 shows error 404.
My .htaccess supress index.php from my controllers.

http://localhost/percutz/index.php/noticias/ (i dont need this)

If i go for http://localhost/percutz/noticias/index/2 shows properly.

Please, help me to understand my error.
#12

[eluser]Aken[/eluser]
Post your entire controller and routes as they sit right now.
#13

[eluser]Mauricio de Abreu Antunes[/eluser]
Hi!

My routes.php
Code:
$route['default_controller']  = 'welcome';
$route['404_override']    = '';
//Route para noticias.
$route['news/(:num)']   = 'news/index/$1';

My news.php (controller)
Code:
public function index() {  
   //Retorna o segmento da página.
   $offset     = (int) $this->uri->segment(2);
   //Total de notícias para listar.
   $config['total_rows']  = $this->news_model->contaNoticias();
   $config['per_page']  = 2;
   $config['base_url']  = $this->config->item('base_url') . 'news/';
   //Inicializa a paginação.
   $this->pagination->initialize($config);  
   $dados['news']   = $this->noticias_model->listaNoticias($offset, $config['per_page']);
   $dados['paginacao']  = $this->pagination->create_links();
   //Carrega a view de dados.
   $this->load->view('news_view', $dados);
  }

My pagination.php (config)
Code:
//Primeiro e último link.
$config['first_link']  = 'First page';
$config['last_link']  = 'Last page';
//Próximo e Anterior
$config['next_link']  = '>';
$config['prev_link']  = '<';
#14

[eluser]Mauricio de Abreu Antunes[/eluser]
[quote author="Aken" date="1329264103"]No, his URLs aren't working. That's why when he's on Page 2, it acts like Page 1, unless he includes the index() method.[/quote]

I was wondering this, but what can i do?
#15

[eluser]Aken[/eluser]
Add what I recommended above in post #7 to your controller.

Also, your route doesn't need the extra stuff after news, since you aren't passing the pagination value as a parameter.
Code:
$route['news/(:num)'] = 'news';
#16

[eluser]Mauricio de Abreu Antunes[/eluser]
[quote author="Aken" date="1329268403"]Add what I recommended above in post #7 to your controller.

Also, your route doesn't need the extra stuff after news, since you aren't passing the pagination value as a parameter.
Code:
$route['news/(:num)'] = 'news';
[/quote]

It did not solve my problem.

When i go for http://localhost/percutz/noticias
It shows

1 2 > (its ok)

But when i go for

http://localhost/percutz/noticias/2

1 2 > (and i can not access 1 page anymore...)
#17

[eluser]Aken[/eluser]
Does your route actually say news, or did you translate it to noticias?

Also, a small fix to what I said about that route - you don't need the parentheses if you aren't going to reuse that segment.
Code:
$route['noticias/:num'] = 'news';

You have something small wrong somewhere. It might be worth starting from scratch and add code until you find where the problem is.
#18

[eluser]Mauricio de Abreu Antunes[/eluser]
Ok, ill recode.
Anyway, thanks.
#19

[eluser]Mauricio de Abreu Antunes[/eluser]
GOD, help me!
I can not solve this.
I just watched http://net.tutsplus.com/articles/news/co...agination/! I do the same thing and create_links is not working for me.
#20

[eluser]Mauricio de Abreu Antunes[/eluser]
Something is wrong with my URL.
http://localhost/percutz/noticias/index/2 (working)
http://localhost/percutz/noticias/2 (not working)

My .htaccess file can influence it?

Code:
DirectoryIndex index.php

RewriteEngine On
RewriteBase /percutz

#If isso é um arquivo, diretório ou link.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^.*$ - [NC,L]

#Caso contrário, controlar pelo MVC do CI.
RewriteRule ^.*$ index.php [NC,L]




Theme © iAndrew 2016 - Forum software by © MyBB