Secondary Controller doesn't load view |
[eluser]teomatteo89[/eluser]
Hi, I'm using CI form just a couple of week, so i'm practically a newbie of this framework. I'm having issues with my secondary controller or the routes.php configuration file - i think -, and i can't understand why. This is my routes.php: Code: $route['default_controller'] = '/view'; Basically, I'm writing a simple e-commerce site. By now, i have the main view of the site loaded from the basicViewController file. The view loaded has at the top a menu with 4 links to 4 different pages, and one of them is "controlled" from another controller file, userlist.php. Userlist.php: Code: <?php How you can see, there's also a model connected to a database: i'm trying to print every user saved. modelpizzeria.php: Code: <?php And this is how i should view all my users: Code: /* But, when write localhost:8888/Pizzeria/index.php/userlist/index or when i click the link anchored(in menu.php), the page doesn't load anything. It simply stays all white. Can someone help me to figure out what's happening? Thank you and sorry for my "not so correct" English.
[eluser]DarkManX[/eluser]
You need to set routing to the userlist or just take out the bottom rule of routing. Code: $route['(:any)'] = '/view/$1'; normally you would need to /userlist/index to get to the index-method of userlist but your last rule sends everything but /registrazione and /form to the view controller. so if you would call /userlist/index now you will be routed to /view/userlist/index - to the userlist-method of the view-controller (if you are using standard dir-structure).
[eluser]teomatteo89[/eluser]
Thanks for the reply. Unfortunately, my first post omitted part of the configuration file. Here is the routes.php: Code: $route['default_controller'] = 'basicViewController/view'; If i understood correctly how routing works, when the page "clienti" is requested, codeigniter redirect the request to the controller userlist(saved into application/controllers/) and asking for method index... But i don't see anything displayed at link "http://localhost:8888/Pizzeria/index.php/clienti". If i comment the line Code: $route['clienti'] = 'userlist/index'; (This is what i see when i comment the line: https://dl.dropbox.com/u/411738/screenshot1.png)
[eluser]InsiteFX[/eluser]
You donot need to add the index, index is the controllers default method. Code: $route['clienti'] = 'userlist';
[eluser]DarkManX[/eluser]
which controller you was led to by calling /clienti. a small hint: dont mix languages, just use english.
[eluser]teomatteo89[/eluser]
Following your advice, i just translated everything to english. (By the way, my code is hosted here: https://github.com/teomatteo89/ProgettoDatabase) about Code: $route['customers'] = 'userlist'; I double checked everything, but i really don't understand why that page is completely white. |
Welcome Guest, Not a member yet? Register Sign In |