3

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?

3

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?.

| improve this answer | |
  • 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. – jay May 4 '11 at 21:43
  • Sounds good, remember to post a patch for your port to the issue queue :) – Berdir May 5 '11 at 15:28
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.