Form a long url |
[eluser]katama[/eluser]
Hello. I have one Admin controller and one Class and one Public controller and one Class. So there is admin.php Controller. It contains Class Admin. This class contains functions index, catalog, more . How can I form such url http://code_int.loc/admin/catalog/more/2 and for example, longer.. instead of current http://code_int.loc/admin/more/2 ? Thanks.
[eluser]James McMurray[/eluser]
I don't think I understand the question, but I'll try. You can write the urls however you want them. If you use http://code_int.loc/admin/more/2, the admin controller's more function will be invoked with the first parameter set to 2. If you use http://code_int.loc/admin/catalog/more/2 the admin controller's catalog function will be invoked with the first parameter set to 'more' and the second one to 2.
[eluser]katama[/eluser]
Thank you for reply, and about what parameter do you say..? :long:
[eluser]James McMurray[/eluser]
Unless you change the default installation, codeigniter takes the first section of the url as the controller, the second as the function to call, and the remaining sections as parameters for that function (or it ignores them if there are too many). For example, assume you have the following two functions in your admin controller: Code: function more($page) { http://code_int.loc/admin/more/2 will output Quote:action: more http://code_int.loc/admin/catalog/more/2 will output Quote:more - 2 You'll probably want to define defaults for your parameters because it's possible for a user to go to http://code_int.loc/admin/catalog, which will error out if catalog's $action and $page don't have default values. So you'd instead have: Code: function more($page=1) { I highly recommend watching at least the first video tutorial. I was swimming in a world of confusion when I first came to CI: wondering why there were folders listed after our site's index.php file, what the heck all this $this->load stuff was, and more. The hello world video and the parts of the documentation it pointed me to helped immensely.
[eluser]katama[/eluser]
Thank you very much, And I will read documentation one more, I looked it fluently.. But I can't find there example of big url.. I want to do project with a long url such as Site.loc/commercial/residence/flats/buy/2321. And I was thinking about parsing url by passing segments.. then use several function in site Class and link them by another method, for example..hm, but this is assumption... hut:
[eluser]James McMurray[/eluser]
Look around the forums some for threads about routing. That might be more what you're looking for.
|
Welcome Guest, Not a member yet? Register Sign In |