Forum Moderators: phranque

Message Too Old, No Replies

Compulsory site wide include

include site-wide

         

WhiteRAndy

7:02 am on Nov 24, 2009 (gmt 0)

10+ Year Member



Hello folks,

Was wondering if someone could be of assistance?

I'm trying to do an include from outside the main stream of the site, so I was wondering if it was possible to force an include at the beginning of a page using .htaccess or another form?

Thanks.

Andy.

jdMorgan

1:49 pm on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What kind of site is this? PHP, or HTML with server-side includes, or other?

Please define "outside the main stream of the site."

The answer also depends on what is to be included, that is, whether it is meta-data to be added to the <head> section of your HTML pages, or content to be included in the <body> of those pages.

Jim

WhiteRAndy

2:06 am on Nov 25, 2009 (gmt 0)

10+ Year Member



It's just a site. Could be ANY coding style, but I use PHP and want to use HTML.

I use .htaccess to set the action of a file that is text/html. The thing I can't do is seem to once executed the script in the Action is to just continue to read the HTML file that was called initially.

For example, I set the ACTION in the .htaccess then load up an HTML file in the browser. That then gets passed to the file called in the ACTION which I use a PHP file. In this I can do the includes and/or other formatting for a compulary include.

Is this the best way to achieve this result?

Also, if this is a good way, how can I just exit the action and continue the reading of the initial file?

To answer your question Jim, I'm using HTML, PHP, .htaccess and includes.

Hope you can help. Thanks!

Andy.

jdMorgan

2:50 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like maybe your page design is "inside-out"; Configure your server to parse html files (.html file extension in the URL) as PHP, and then invoke PHP directives or 'includes' from inside the html pages:

<p>This is my plain HTML.</p>
<?
print("Hello world! -- Greetings from your friendly neighborhood PHP interpreter!");
?>
<p>This is more plain HTML.</p>

It appears that "Action" is a "too-specific" directive for your needs. The method you must use to declare that .html files should be parsed for PHP depends on how PHP is installed on your server, but you will almost always use either AddHandler or AddType directives to do this (See Apache mod_mime). There are several tutorials in our PHP Forum Library on this subject.

Jim