attempting to get a clear understanding of URI. |
[eluser]dottedquad[/eluser]
for an example I have: http://localhost/lsms/index.php/validate...entsgohere I would like to use $array = $this->uri->uri_to_assoc(3); to handle the URI. I've read the user guide, searched this forum, and search google for a clear example and I'm still confused. On google I've been running across pagnation examples multiple times. Can someone please point me to a clear example on how to use uri_to_assoc(). Thank You. -rich
[eluser]mddd[/eluser]
Can you explain what things you are confused about? The basic idea is very simple: instead of writing Code: /oldfashioned_script.php?search=someword&sortby=name&page=2 Code: /mycontroller/mymethod/search/someword/sortby/name/page/2 For the uri given above, you would get the following result: Code: $args = $this->uri->uri_to_assoc(); // this is the same as uri_to_assoc(3) because 3 is the default Why is this handy? Imagine you used a shorter uri like Code: /mycontroller/mymethod/someword/name/2 Now, if you wanted to see page 2 of a search for 'someword' but NOT specify a sorting order, how would you do that? You would have to think of something like Code: /mycontroller/mymethod/someword/no-sorting/2
[eluser]dottedquad[/eluser]
[quote author="mddd" date="1276095392"]Can you explain what things you are confused about?[/quote] my view code: Code: <?php When I point my browser to: http://localhost/lsms/index.php/validate...entsgohere I receive a 404 Page Not Found. When I point my browser to http://localhost/lsms/index.php/index/species/1/alias/moe/parents/undefined/gender/male/breed/No/birthdate/2010-06-09/location/4/comment/commentsgohere I no longer receive the 404, but receive a blank page. My echo also did not echo out species: The 404 error and how to use and where to place uri_to_assoc() is confusing me. -Rich
[eluser]dottedquad[/eluser]
[quote author="mddd" date="1276095392"]Can you explain what things you are confused about? [/quote] Please disregard my first response to your question. I had to read over the user guide again on the controller and views to understand the page layout. My new code is as follows: Controller code: Code: <?php View code: Code: <?php I shortened my URI so I can understand this better. Current uri: http://localhost/lsms/index.php/validate...species/1/ When I point my browser to the above address I receive a 404 Page Not Found error. Why am I receiving a 404 and how do I fix this issue? I'm looking for a quick and usable code example that I can work from. The easiest way for me to learn is by pulling code apart. Thank you in advance! -Rich
[eluser]danmontgomery[/eluser]
From the user guide, Quote:Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method. The segments in a URI normally follow this pattern: http://ellislab.com/codeigniter/user-gui...uting.html For the URL: http://localhost/lsms/index.php/validate...species/1/ CI is looking for: Controller: validate_livestock_form Function: species Parameters: 1 Which doesn't exist. You have to include index/ so it's recognized as the function, or use CI's routing feature.
[eluser]dottedquad[/eluser]
I forgot to include the function index in the URI. It all works as expected. finally :-) |
Welcome Guest, Not a member yet? Register Sign In |