douzhaocheng4533
2012-05-27 03:47
浏览 79
已采纳

Opencart模块包含自定义php文件问题?

I'm trying to create an OpenCart 1.5.1.3 module. The issue I'm having is with including a custom php script.

When I do this in the controller:

include('module/simple_html_dom.php');

or

include('simple_html_dom.php');

I'm presented with the following error:

Notice: Error: Could not load language module/simple_html_dom! in D:\xampp\htdocs\store\system\library\language.php on line 26

I suspect there's a simple explanation, but just can't work it out.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试创建一个OpenCart 1.5.1.3模块。 我遇到的问题是包含一个自定义的PHP脚本。

当我在控制器中执行此操作时:

  include(' 模块/ simple_html_dom.php '); 
   
 
 

 <代码>包括(' simple_html_dom.php'); \  n   
 
 

我遇到以下错误:

注意: 错误:无法加载语言模块/ simple_html_dom! 在 D:\ xampp \ htdocs \ store \ system \ library \ language.php 26

我怀疑有一个简单的解释,但是无法解决。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douhuitan5863 2012-05-27 13:34
    已采纳

    The reason is that you're still in theory calling from the index.php file, so need to either use a relative path from that, or use a defined variable, which you can find in the config.php file that have all the relevant paths OpenCart uses

    点赞 打赏 评论
  • douxu9707 2012-05-27 08:30

    I've found a way to include the file I wanted. I'm not sure it's the proper way of doing this but I used the following code - with OpenCart having such little documentation it's not easy to debug and/or develop for it.

    require_once(DIR_SYSTEM . 'simple_html_dom.php');
    

    DIR_SYSTEM is OpenCart's /system folder, so I placed my simple_html_dom.php file in there and voila, it worked.

    点赞 打赏 评论
  • dongran1779 2015-08-18 13:22

    I have the same problem in opencart. i have to install file i have something like

    <?php include 'i_header.tpl';?>
    

    I replace it with

    <?php include (DIR_TEMPLATE. '/module/---your module name ---/i_header.tpl');?>
    

    and it works. You can chose the correct path name which under the config file.

    ROOT/config.php
    
    ROOT/admin/config.php
    

    I hope this helps.

    点赞 打赏 评论

相关推荐 更多相似问题