View located in different default folder - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: View located in different default folder (/showthread.php?tid=69739) Pages:
1
2
|
View located in different default folder - c3media - 01-11-2018 Hi, I have a controller in folder APP\CONTROLLERS And view in folder THEMES\DEFAULT\VIEW When try to open page, get error: 404 page not found, what is the way as have to work function to call view from controller? Regards RE: View located in different default folder - jreklund - 01-11-2018 You can find everything you are looking for in the manual. https://www.codeigniter.com/user_guide/tutorial/static_pages.html https://www.codeigniter.com/user_guide/general/controllers.html https://www.codeigniter.com/user_guide/general/views.html If you still have any problems, you NEED to post some code and what URL you try to access. RE: View located in different default folder - c3media - 01-11-2018 (01-11-2018, 02:01 PM)jreklund Wrote: You can find everything you are looking for in the manual. Thank you jreklund, This My controller Code: PHP Code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); And my View code: PHP Code: <?php My URL: http://localhost/sma/segway It's not openning, get error: 404 page not found Attached imagen about my CI folder tree: Thank you, Regards RE: View located in different default folder - jreklund - 01-12-2018 I'm not sure what your root url really are. I guess that the picture provided are 'sma' but you are trying to load a lib folder for Javascript that's not even included in the folder... If the root folder indeed are inside 'sma' this should work. In app\config\config.php: Code: $config['base_url'] = 'http://localhost/sma/' index.php: Code: $system_path = 'system'; .htaccess: Code: <IfModule mod_rewrite.c> If it's not working or you already have this set it's your app\config\routes.php that's the problem. Can you load the default controller? http://localhost/sma/ RE: View located in different default folder - InsiteFX - 01-12-2018 You can name a different view folder location in the index.php file look in there. RE: View located in different default folder - c3media - 01-12-2018 (01-12-2018, 01:30 AM)jreklund Wrote: I'm not sure what your root url really are. I guess that the picture provided are 'sma' but you are trying to load a lib folder for Javascript that's not even included in the folder... Default controller is welcome: Ok. In app\config\config.php: Ok .htaccess: Ok $view_folder = 'themes'; when update $view_folder to absolute path show error 500. Thanks by your help RE: View located in different default folder - jreklund - 01-12-2018 Have you modified the view() function inside the Welcome controller? Generally you ignore the view_folder name, so it should look like this. PHP Code: $this->load->view('default/views/show_grid',$data); // For circle 404 page You can also change the debug/log option inside app\config\config.php to see all error messages. Logs are located in app\logs\ PHP Code: $config['log_threshold'] = 4; If you just specify $view_folder = 'themes'; it will look inside app folder after it, not the root folder. Do you have a themes folder inside app too? Can you load your site with the following URL? If so, your webbserver aren't loading your .htaccess file. http://localhost/sma/index.php/segway Can you post your app\config\routes.php RE: View located in different default folder - c3media - 01-12-2018 Can you load your site with the following URL? Not: 404 error page not found Do you have a themes folder inside app too? Not: THEMES folder it's in root folder. routes.php - code PHP Code: <?php Thanks! RE: View located in different default folder - InsiteFX - 01-12-2018 Try this: PHP Code: $view_folder = '../absolute/path/to/your/themes/folder'; RE: View located in different default folder - jreklund - 01-12-2018 Totally forgot you will need to access your Segway class this way. http://localhost/sma/segway/show_grid http://localhost/sma/index.php/segway/show_grid Codeigniter only loads the index() function on default. You can overwrite the default function by placing this in your route. PHP Code: $route['segway'] = 'segway/show_grid'; I thought you got a "real" 404 and not Codeigniters 404 messages. But had a look at my dev machine at home now. |