CakePHP include external php file in plugin
I'm making a main app in CakePHP 1.3.10 that has a couple of plugins. In one of the开发者_Python百科m, I need to use a very big array ($array_test
) populated "manually".
The way I have it now (which works perfectly) is that I declare the array in the controller of the plugin that I want to use it in (plugin1_home_controller.php for example), doing something like var $array_test = array(1,2,3,4,5...)
, and I can access it perfectly from the views in that controller.
The thing is that I would prefer having the array declared somewhere else in the plugin, since it's too big, and then load it when I need it.
So I'm trying to create a array_test.php file with the array declared in it, put in /app/plugins/plugin1/webroot/php/array_test.php, and then load it from the view using include "/php/array_test.php"
(I also tried include "/plugin1/php/array_test.php"
as the CakeBook says in the plugins assets section), but none of them work.
How can I get the right path? Or is there any good alternative to what I want to do? Thank you so much in advance!
If your plugin is in the app's directory use:
APP_PATH.'plugins'.DS.'plugin1'.DS.'webroot'.DS.'php'.DS.'array_test.php'
If your plugin is installed in the common cake directory:
CORE_PATH.'plugins'.DS.'plugin1'.DS.'webroot'.DS.'php'.DS.'array_test.php'
精彩评论