开发者

How to add php files in drupal modules

I have a folder /sites/main_folder/modules/file_folder/file.php

I need to add file.php in the target.module file /sites/main_folder/modules/开发者_StackOverflowtarget_folder/target.module. What is the perfect code for that?

I wrote this code in my callback function to add file.php in my target.module file but nothing happened:

$path=base_path().drupal_get_path("module","file_folder")."/"; 
require_once($path."file.php");


One way to do this is to use the Libraries API module. It helps you to keep all of your included library files in one location (namely /sites/all/libraries/). If you install and enable that module it gives you a libraries_get_path() function.

So you could then move your file_folder folder to /sites/all/libraries/file_folder/. Then to include the file you would do something like

include_once libraries_get_path('file_folder') . '/file.php';

Be sure to add libraries as a dependency in your .info file

dependencies[] = libraries


You simply use module_load_include() as in the following example.

module_load_include('php', 'target', 'file');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜