0
votes

I'm trying to use a php include of a header on a Drupal page. I have a file called 'ss_header.php' with the following HTML in it:

<div class="ss-header-container">
<div class="ss-header"><a class="btn btn-extra btn-red" href="">Register</a></div>
<div class="ss-nav cf">
<a href="#">Register</a>
<a href="#">Agenda</a>
<a href="#">Hotel</a>
<a href="#">FAQ</a>
<a href="#">Shop</a>
<a href="#">Hat District</a>
<a href="#">Download</a>
</div>
</div>

I am trying to add the following code within the body of a page that I am creating:

<?php include 'ss_header.php';?>

None of this is working. I'm getting the following error: * warning: include(ss_header.php): failed to open stream: No such file or directory in /var/www/vhosts/redhatsociety.com/includes/common.inc(1808) : eval()'d code on line 4. warning: include(): Failed opening 'ss_header.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/vhosts/redhatsociety.com/includes/common.inc(1808) : eval()'d code on line 4.*

1
the header is working, but the file isn't where you think it is. check what the script's working directory (getcwd()) is, drupal may have changed it to something else.Marc B

1 Answers

0
votes

If the file you are attempting to add is within a module within your Drupal site, use the module_load_include function Drupal 6 API module_load_include

For example, if the file is located within your 'mymodule' module directory under a sub-directory 'otherfiles' (assuming your file is called ss_header.php) then you could do the following:

module_load_include('php', 'mymodule', 'otherfiles/ss_header');

Alternatively, if this is located in your theme, you can use the path_to_theme() function to get the current theme path.

Note: From the details you've mentioned, what you're trying to do doesn't sound like a normal Drupal way. Unfortunately from the little detail provided it's not really possible to make any other suggestions. In case it helps, you may want to look further into the Drupal template system to see if there's a better way to achieve what you want (Details on how to override themable output which may help as a starting point) and also looks at preprocess hooks (D6 hook_preprocess) if you're trying to add custom content to a page from your module or template.