2

In Drupal 7, I am writing PHP from inside the Front Page module, say:

$page = include_once "templates/page.php";

I put the "templates/page.php" under /sites/all/modules/front and Drupal complains about file missing. Any suggestion where best to put up the files to be included?

Then, after installing the PHP Simple HTML DOM Parser, I wrote the following

$html = new simple_html_dom();

and was complained for Class 'simple_html_dom' not found. I have tried duplicating the library file to the same folder and home, but all cases not working. How to set up the correct path?

Many thanks.

1

1 Answer 1

0

If it's a theme function, guessing from the file name you mentioned, you should use them theme() function to get the themed output.

To get the path of a module relative to the Drupal root, use drupal_get_path() function.

If you want to include or require a file, you can use module_load_include(). However, note that if the including files print anything, they will be printed to the current output buffer (which means they will be printed on user browser).

Given the above available features, I think it's theme() that you are looking for.

2
  • Indeed I move the include files to the home directory (Drupal root) and it works fine, though that might not be good practice.
    – Rising
    Jul 12, 2015 at 16:49
  • Is there some way to set up the include path so that a particular file could be found?
    – Rising
    Jul 14, 2015 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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