views:

36

answers:

2

hi,

how can I include a custom library in Drupal ?

For example I need to insert this statement somewhere, to use the dompdf library:

require_once("dompdf_config.inc.php");

Once the this file is included, i can trigger custom php code from my drupal back-end custom actions.

thanks

A: 

2 Places to do it would be

  • In a module's .module file, if you always want it included
  • Wrapped in a function that you can call, if you manually want to include it.
googletorp
+2  A: 

You want to include it, in order to use it, not? If so, just include it at the place where you are going to use it. E.g. in your own dompdf.module.

. That module would then distribute the dompdf funcitonality trough your Drupal site.

Another, common route is to place the include in /sites/all/libraries/ and then to include it from your dompdf.module. libraries in /sites/all/libraries/ are often libraries that will be used in more then only your module: probably in your theme too, or in other modules too.

berkes
well, if I include it at the place where I'm going to use it, I'm going to invoke this line all the time i invoke the function. Is that ok ? I mean including it multiple times ? (This is more php question)
Patrick
h, yes. to include files in Drupal, you have several options depending on the version. Drupal6?
berkes
yes drupal6. Anyway now it works. If I can keep the require statement inside my PHP snippet, it is fine for me
Patrick
beware: those snippets have many downsides. But that is a whole different post.
berkes

related questions