How to change the extension in view using codeigniter 3?

强颜欢笑 提交于 2020-01-03 03:18:08

问题


Here's my problem I setup Codeigniter 3 in my local and use an thirdparty (MX thing) now that I have adjusted the file path, I wanted to change the file extension that is being fetch the controller.

$this->load->view('welcome_message');

I change the file in views from:

welcome_message.php

to this

welcome_message.html

Now I get this error

An Error Was Encountered
Unable to load the requested file: welcome_message.php

but I wanted to use the .html extension becuase the folder path that I will be using will only contain html/js/css (template folder) files only (i will separate the php files to template folder). How can this possibly happen?

Any help is greatly appreciated, Thanks guys!


回答1:


You don't need to change extension to html, you can use html in a php file, just don't open php tag.

EDIT :

If you really have to change the ext, just do :

$this->load->view('welcome_message.html'); 



回答2:


You can try to change it using route configuration in application/config/routes.php

Then, you can use:

$route['[your controller]/welcome_message'] = '[your controller]/welcome_message.html';

For for information about routes, you can check official documentarion here:

http://www.codeigniter.com/user_guide/general/routing.html

Or you can use Static pages:

http://www.codeigniter.com/user_guide/tutorial/static_pages.html

Regards.



来源:https://stackoverflow.com/questions/35205056/how-to-change-the-extension-in-view-using-codeigniter-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!