Go Back > PhpDig Forums > Mod Submissions

Thread Tools
Old 06-17-2004, 03:44 PM   #1
Green Mole
Join Date: Jun 2004
Posts: 1
Apache includes in a template

Here is a quick mod that lets me put server-side includes in a template file -- it emulates the Apache <!--#include virtual= ... --> directives in server-parsed HTML files.

For example, In a template file I can put:

<phpdig:inclucde virtual="/foo.html" />
to include a file containing a block of html
<phpdig:inclucde virtual="/cgi-bin/" />
to include the output of a cgi program, in this case the output of a perl script named I haven't tried it, but I assume that you could include php output the same way.

Here is the mod to libs\function_phpdig_form.php that makes it work:

Change the lines:

PHP Code:
       if ($in_loop == 0) {

PHP Code:
       if ($in_loop == 0) {
           if (
ereg('^[ ]*<phpdig:inclucde[ ]+virtual[ ]*=[ ]*[\"\']([^\"\\']+)["\'][ ]*/>(.*)', $line, $regs)) {
               $line = $regs[2];
           print phpdigParseTags($line,$t_strings);
Note that the code above probably word-wrapped here, the ereg call with the big ugly regular expression should be all on one line. Also, I seem to be fighting the BBS software that displays these posts -- it dropped some of my \ charcters -- the middle part uf the expresion should look like [\"\ ']([^\"\ ']+)[\"\ '] but without the blanks before the single quotes.

This method only works on sites where php's virtual() function works -- that means only on Apache servers, and they must be running php as a plugin, not as a cgi program.

This mod has worked for me on:
Win/XP + Apache 2.0.45 + Php 4.3.7
FreeBSD + Apache 1.3.27 + Php 4.3.4

If you don't provide a rooted path to the included file, its path will be relative to $relative_script_path.

My implementation has some restrictions that could probably be fixed by someone with a better understanding of php and the PhpDig code:

The <phpdig:inclucde ...> tag must be at the start of line, nothing but blanks should precede it.

It can't go inside a <phpdig:results> loop.

Thanks to everyone involved with PhpDig; it looks like it will be a great addition to my website. I'd appreciate any feedback or corrections for the mod.

Steve Green

Last edited by sgreen; 06-17-2004 at 04:20 PM.
sgreen is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
apache:apache on connect.php lucite Troubleshooting 0 01-27-2007 08:02 AM
php includes template info 5wayshost Coding & Tutorials 0 12-31-2006 09:59 PM
Themes and PHP Includes Arctic Troubleshooting 3 05-07-2005 08:21 PM
Parse error with includes cherie Troubleshooting 1 12-14-2004 12:34 PM
PHP includes in Template? jirving How-to Forum 1 09-29-2003 02:37 PM

All times are GMT -8. The time now is 08:50 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.