0

Sorry if the title is not the best description, it is my first time working with Drupal. My client has a portal created on Drupal 6.22, I'm creating a concurrent website for him, and he wanted to use the same header and footer that is created on the Drupal portal on my area.

So basically I would like to know if there is a include, or reference I can add to my website that would use\compile\something that Drupal header\footer on my layout.

3

This may be fairly simple (with a couple of caveats, explained below). Treat it as though you were just going to use static files--i.e. so your site can simply include the contents of those files in the relevant *.tpl.php files in the theme.

The meat of the problem is that you'll need to convince Drupal to make those files for you. You can do this by creating two nodes in Drupal on the portal--call them something like 'header-include' and 'footer-include'. Take note of their node ids.

Then, assuming for the sake of demonstration that the two new nodes have node ids 1 and 2, copy the portal theme's page.tpl.php file twice, so that you have two files, page-node-1.tpl.php and page-node-2.tpl.php (see Drupal 6 Template Suggestions for more details). Modify any paths in these files that refer to the portal site.

That done, remove everything from one file except for the code and markup required to generate the header, and everything from the other file except for the code and markup required to generate the footer. Depending exactly how you need to do this, you may need to include the opening html tag and all the scripts etc. for the header, and similarly for the footer.

Clear the caches on the portal site, and you should now have two pages, header-include and footer-include that contain only the basic html code required for the header and footer respectively.

These can be included into the theme on the new site using PHP's file_get_contents() function.

Caveats

There are two points where this can go wrong:

1. Some paths may still be wrong

If there are paths in the header and footer includes that you generate (i.e. paths not hardcoded into the original page.tpl.php file), they will either include the domain of the portal site, or no domain at all. If there are any such, you will need to change how they're output at the portal (difficult), or add the relevant domain to the include at runtime (potentially expensive, though if the resulting pages will be cached, maybe not a huge concern...)

2. Include files may be accessible

This way of doing things makes the include files accessible to anyone on the portal site with the access content permission. How much of a problem this is is up to you and the client, but I don't know of a simple way to exclude them from search results in Drupal 6.

  • Thanks mate, awesome answer. I will try it tomorrow and see if I have any problems doing it – Yohan Leafheart Apr 16 '13 at 21:56

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.