You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在School模块视图中引入Univ模块的表单视图?

Loading Univ Module's Form View in School Module's Views

Hey there! Let's fix that view loading issue you're having. Your current attempt with $this->load->view('../univ/form'); isn't working because the relative path isn't pointing to the right place—when you're in the modules/school/views/ directory, ../ takes you up to modules/school/, so ../univ/form is looking for modules/school/univ/form which doesn't exist.

Here are the reliable ways to load the univ form view from your school module:

If your project uses Modular Extensions HMVC (a common setup for CodeIgniter modular projects), you can directly reference the module's view by prefixing it with the module name:

$this->load->view('univ/form');

This tells CodeIgniter to look for the form.php file inside modules/univ/views/ automatically, which is clean and maintainable.

2. Full Path Reference (Non-HMVC)

If you're using a standard CodeIgniter setup without HMVC, you can use the full application path to target the univ view explicitly:

$this->load->view(APPPATH . 'modules/univ/views/form');

The APPPATH constant points to your project's application/ directory, so this ensures you're always pointing to the correct file regardless of where the calling view is located.

While it's possible to fix the relative path, it's less reliable if your directory structure changes later. For completeness, here's what the correct relative path would look like:

$this->load->view('../../univ/views/form');

This jumps up two levels from modules/school/views/ to modules/, then navigates into univ/views/form.php. But again, using the module name or full path is better practice.

Pick the method that fits your project's setup—HMVC's module name approach is the most straightforward if you have that extension installed.

内容的提问来源于stack exchange,提问作者Lemures

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:52:17