I have multiple web-apps running on a server using different technologies.

  • java
  • php (wordpress)
  • python (trac)

They are all front-ended with Apache 2.2. My question is does anyone know a good way to wrap all these web apps with a common template (header/footer).

I was looking into mod_layout, but the documentation is quite limited and I was unable to get even the simplest example to work.

I also looked at mod_include, but I'm not sure if that is a good idea.

link|improve this question
I just got a simple example of mod_layout working, the problem was mod deflate had to be disabled – delux247 Aug 20 '09 at 18:41
One more thing that I figured out is that if you want your header/footers to be java servlets then you need to use mod_jk and JkEnvVar to pase the mod_layout environment variables. - musc.edu/webserver/mod_layout.html#_1_15 - tomcat.apache.org/connectors-doc/reference/apache.html – delux247 Aug 21 '09 at 14:57
feedback

migrated from stackoverflow.com Aug 21 '09 at 22:22

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 2 down vote accepted

You can force all pages of a certain extension to include a header and footer by setting it out in the httpd.conf of the server, or just in the .htaccess of each particular directory/site with the append and prepend directives like so:

<FilesMatch "\.html$">
php_value auto_prepend_file /path/to/header.html
php_value auto_append_file /path/to/footer.html
</FilesMatch>

The above will match .html pages and will force include /path/to/header.html before the page content as well as /path/to/footer.html after the page.

Just remove the FilesMatch lines if you want to force it on all pages.

link|improve this answer
feedback

Use similar templates for all your applications. Simply slapping extra HTML onto the beginning and end of a page will give you nonconformant output, which is likely to break layout within applications.

WordPress and Trac both have highly capable theming systems. Use them.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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