[solved] CI loads not the right view after upgrading |
[eluser]SPeed_FANat1c[/eluser]
Hi, I upgraded the site from 1.73 to 2.0.1 but when going to http://localhost/ubagynasCI2/ I get an error: A PHP Error was encountered Severity: Notice Message: Undefined variable: content Filename: views/info_page_view.php Line Number: 2 and I see it loads not the right view, here is the controller code. Code: function index($offset = 0) you see there is line Code: $this->display('home_view'); So it should load the home_view, not the info_page_view The MY_Controller: Code: class MY_Controller extends CI_Controller{ In routes.php there are such lines: Code: $route['default_controller'] = "home"; In CI 1.73 it loads the right view. But it looks like it is not calling the index function in home controller. And calls home/info instead of it. Why could that be?
[eluser]InsiteFX[/eluser]
Did you change all Controllers to CI_Controller and all Models to CI_Model ? You need to also use the CI 2.0.X index.php file Also this was added to application/config/routes.php Code: $route['404_override'] = ''; InsiteFX
[eluser]SPeed_FANat1c[/eluser]
Quote:you change all Controllers to CI_Controller and all Models to CI_Model ? Yes, actually for controller I only needed to change in MY_Contoller class, becasue controoller extend this. For model changed alse. Quote:You need to also use the CI 2.0.X index.php fileThe one in the root directory? Changed it. Quote:Also this was added to application/config/routes.php cannot see this in user_guide, but now added that line. After the $route['default_controller'] = "home"; And commented out $route['scaffolding_trigger'] = ""; But still the same.. Edit: forget to tell - when I go to http://localhost/ubagynasCI2/home then it works well. So it simply does not reroute to that funciton when I go http://localhost/ubagynasCI2/
[eluser]InsiteFX[/eluser]
Message: Undefined variable: content I do not see this variable in any of the code you posted? Where is variable conent? This may be the problem here! You do not need this here place it right into the views <head> Code: $this->data['meta'] = array( InsiteFX
[eluser]SPeed_FANat1c[/eluser]
Quote:Message: Undefined variable: content that is in another home controllers funciton: Code: function info($url_title) Quote:This may be the problem here! You do not need this here place it right into the views <head> I could put inside the <head> instatnly, but I need such array anyway, because when I extend the MY_Conroller as you can see from function info I use the data['meta'] with more indexes, in some controllers I add keywords metadata to that array. And if I comment out it in constructor, then I get error A PHP Error was encountered Severity: Notice Message: Undefined variable: meta Filename: views/header_view.php Line Number: 7 A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: views/header_view.php Line Number: 7 of, course I could do checking if meta isset but I don't thing that the problem is in here somehow. But the main problem that the function "info" is called when I go to http://localhost/ubagynasCI2/ - the index function should be called instead. Edit: found one more thing: when I comment out this line in routes.php: Code: $route['((?!admin|admin_|galerija|home|test).*)'] = "home/info/$1"; then there is no error when I go to http://localhost/ubagynasCI2/ so the problem is with routing. But I need this line because otherwise I cannot go to urls like this: http://localhost/ubagynasCI2/contact that line helps to reroute to function "info"
[eluser]InsiteFX[/eluser]
Well a lot of the Routing has changed in CI 2.0.X, so I would start looking there then. I know a lot of users have had problems with setting the protocol in the config.php file some work and some do not work! InsiteFX
[eluser]SPeed_FANat1c[/eluser]
Quote:I know a lot of users have had problems with setting the protocol in the config.php file some work and some do not work! changed uri_protocol from auto to $config['uri_protocol'] = "QUERY_STRING"; and now home page works but don't understand, there is now query strings in my urls. Now I need some testing if other things work Edit: thanks for helping
[eluser]InsiteFX[/eluser]
No problem! Try the other ones until you find one that works for you. InsiteFX
[eluser]SPeed_FANat1c[/eluser]
tried all of them, and only QUERY_STRING works. Maybe you know what possible problems might be when I use QUERY_STRING ? At least for now I don't see any, other controllers work, ajax functions also work.
[eluser]InsiteFX[/eluser]
Old saying! If it works leave it alone LOL InsiteFX |
Welcome Guest, Not a member yet? Register Sign In |