CI pagination class question |
[eluser]i_am_using_ci[/eluser]
Hi, I want to use pagination class in my controller I set: $pagination_config = array( 'base_url' = base_url . '/controller/method/page/', ... ); So my URLs looks like: http://site.com/controller/method/page/ http://site.com/controller/method/page/20 http://site.com/controller/method/page/40 The question is: How can I get page variable value from my URL?
[eluser]Xelgen[/eluser]
Why not, to use just a parameter in your controller method? Code: function method($page="") Well yes, it's not exactly a page, but number of skipped elements, but it's what you've asked if I understood you right.
[eluser]i_am_using_ci[/eluser]
[quote author="Xelgen" date="1232145223"]Why not, to use just a parameter in your controller method? Code: function method($page="") Well yes, it's not exactly a page, but number of skipped elements, but it's what you've asked if I understood you right.[/quote] My $page is being set to 'page' this way. But is there some way to have possibility of treating 'page/value' argument in URL as $page = 'value' php construction? I need to determine page variable and it's value in my method.
[eluser]Xelgen[/eluser]
[quote author="i_am_using_ci" date="1232145699"][quote author="Xelgen" date="1232145223"]Why not, to use just a parameter in your controller method? Code: function method($page="") Well yes, it's not exactly a page, but number of skipped elements, but it's what you've asked if I understood you right.[/quote] My $page is being set to 'page' this way. But is there some way to have possibility of treating 'page/value' argument in URL as $page = 'value' php construction? I need to determine page variable and it's value in my method.[/quote] Ah, my mistake. Well you can use smth: Code: function method($action, $num="") The optimal way depends solely on your system's controller/URL architecture, so anything we can tell you here, are just examples.
[eluser]ELRafael[/eluser]
you can use uri->segment(n) to get the variable from URL. remmember to use uri_segment in the config array for pagination. here the code runs smooth, no problem detected
[eluser]i_am_using_ci[/eluser]
Okay, understood both Thank you.. Problem solved, but I have theoretical question: If I have URL, for example: http://site.com/controller/method/param1...ction/post Is there anyway to derermine which is key and where's it's val? I mean If I dunno how much params I have (dynamic count) is there way to determine this?
[eluser]ELRafael[/eluser]
Is really necessary so many params in the url? Why you can't send this params in POST or another way? I don't think that GET method is the best in this case. You can use something like this: Code: $segs = $this->uri->segment_array();
|
Welcome Guest, Not a member yet? Register Sign In |