I have a third-party PHP script that I want to integrate and use in my site. The script is quite small and comes with its own functions and array indexes. How would I be able to call the functions and have them displayed in Views or CCK nodes?
2 Answers
If this is you own script, you could simply convert it into a module. That is easy, just create a module (tons of guides to be found in the internet) and put your functions in the .module file, then they will be available to all other code running on the site.
If this is a script/library provides by someone else, you could either place it in a custom module folder and include it with module_load_include() or (better!) declare it as a library with the help of the Libraries module. You will however need to create a custom module with some code to connect the functions of your script with drupal (Usually implementing the correct hooks and calling your functions from that) for both methods.
See also How do I go about putting standalone PHP files into Drupal 6? and How do I load a library defined with hook_library() on node/edit pages?.
-
Thanks for the answer. I found out that someone already created a custom drupal module for the script however its coded with drupal 6 now I am just gonig to port it to 7.– jayCommented May 4, 2011 at 21:43
-
Sounds good, remember to post a patch for your port to the issue queue :)– BerdirCommented May 5, 2011 at 15:28
The usual way is to create a custom module that include the PHP file when required.
If the custom module integrates with Views or CCK, it is not different; it can call module_load_include() to load the file.