Welcome Guest, Not a member yet? Register   Sign In
Routes URL and pagination problem
#1

[eluser]Geneous[/eluser]
:ohh: Hello I have one problem with routes.php - when i am using

$route['text/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/text1/(:num)/(:num)/(:num)'] = 'text/text1/$1/$2/$3/$4/$5/$6';
here $6 parameter is used for pagination.But initially this will be 0.For this it wont work.However if you edit URL and write any number den it works.I am also using the redirection in following way -

$page=$this->redirection->pagination_redirection($config,'text1/'.$r_catname.'/'.$r_subcatname.'/'.$r_esname.'/text2/'.$category.'/'.$es_id,'$page');

Can anyone help me to sort out this one.I am really new to codeigniter.
#2

[eluser]mddd[/eluser]
Two options I can think of:
1) Create a seperate route for the case that no page is given. Put it before this one, and CI will use it if there is no page number.
2) Rewrite the route so that it matches the url wether or not there is the optional page number. Something like:
/(:num)/(:num)(/(:num))? for the end of the route. This should make it work if there are only two numbers at the end,
but also when there are three.
It could be that, because there is a double set of ( ) in the last part, you have to use $7 in stead of $6, my knowledge of regex's is not that perfect.
#3

[eluser]Geneous[/eluser]
Hi mddd
Thanks for your fast reply.

I have followed your 1st way. And really works for me.

I have written these two cases.so if pagination number is not there then route will map URL to first case.and if pagination number is there then it matches to 2nd case.

1) //When Pagination number is not there
$route['text/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/text1/(:num)/(:num)'] = 'text/text1/$1/$2/$3/$4/$5';

2) //When pagination number is there
$route['text/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/text1/(:num)/(:num)/(:num)'] = 'text/text1/$1/$2/$3/$4/$5/$6';

So it worked for me.

Thanks a lotz. :-)




Theme © iAndrew 2016 - Forum software by © MyBB