Drupal and external web apps
At work I am working on building a new website. Most of it is going to be semi-static content with a few different contributors. For this reason I thought a CMS would be nice and save me some time both now and later. I chose Drupal for its flexibility, yet remaining somewhat simple unlike mambo. That and it was featured in Free Software Magazine.
Anyway, back to my original topic. I have lots of legacy code for our Members section that I don’t have time to rewrite. It is hideous code mingled with display logic. I found that I can embed PHP code in the body of a page, just like our current site does with MT 2.6. However, this code is run inside an eval. This creates problems with the crummy code and global variables.
Which leads me to my simple solution. Drupal is only called when a requested URI does not match an existing file or directory. I can bypass drupal for specific pages simply by putting it’s code in a file that maps to the URI. Dead simple.
Next comes a problem of templates. The above solution is handy, but how do I output the file into the appropriate Drupal template. With a little exploring on the Drupal website, and reading the code, I found the solution is simple. Buffer the output of your page, include some of the drupal code, and pass the buffer into the theme renderer. Super slick. Just create the directory and files that you want externally, and add this .htaccess to the directory.
My .htaccess
php_flag output_buffering on
php_value auto_append_file "../sites/default/theme.inc"
sites/default/theme.inc
Note: It will look much better if you add a link to this page into your menu.
Posted: June 16th, 2006.
Tags: Web
Comments
Comment from fungus
Time August 10, 2006 at 3:29 pm
If you use my instructions here, your only issue might be getting your paths correct.
Change the auto_append_file to the appropriate path of your drupal installation. And change the chdir(); call to ensure it goes to the proper drupal dir.
Comment from Kenneth
Time August 10, 2006 at 11:57 am
Hello,
I was reading your description about embeding web apps and was wondering whether I can use your concept on a site am working on as well. Basically, I have a drupal site setup at media.iearn.org. I want to embed an external web app (webcrossing forums, foro.iearn.org), in my drupal site and have it wrapped w/ my theme. I’d greatly appreciate any feedback that you might have.
Thanks
-Kenneth
kluguya@us.iearn.org