|
Posted by Richard Lynch on 04/29/05 23:30
On Thu, April 28, 2005 9:08 pm, Mark Cain said:
> What a mess this has turned out to be -- But perhaps you can help me.
>
> I have a dynamic site that pulls headers, navigation, and footers from
> text files. The content for the pages is pulled from mySQL.
>
> On each page I have a JavaScript rotating banner that displays "Upcoming
> Events." The banners rotate about every 4 seconds without the need for a
> page refresh. The names of the individual banners themselves are fed into
> JavaScript from a PHP script that reads a folder of JPG files and makes a
> decision as to which ones to show (i.e. pass to the JavaScript).
>
> This all works and it's slick seeing that I have the difficulty of dealing
> with a server side script and a client script. The browser calls a
> JavaScript file which has a php extension. When the server "sees" the php
> extension the file is executed before it is delivered to the browser.
> Since JavaScript complains about PHP functions in that file that file
> merely echo back standard JavaScript and calls another php file via
> require() that does the low level work of reading the folder and reporting
> back the JavaScript arrays. Graphically it looks like this:
It sounds to me like you really should just cut this in HALF with:
PHP script outputs header with JavaScript and then body with JavaScript.
As you have it now, every page hits the web server *TWICE* causing twice
the overhead of resources used by HTTP.
That's not real efficient.
But that's just me.
> 1) the Page calls the header
> 2) the header calls
> 3) a php generated JavaScript file which calls
> 4) a php file that reads the folder on the server and
> builds the JavaScript arrays
I mean to say:
<?php
/* Choose your JavaScript banner ads here. */
require 'header.inc'; //This outputs JavaScript to rotate selected banners
/* rest of page here */
?>
> Now I need to add a feature and I am bumping my head on this one.
>
> How do I report the file name of the file that called the header in # 4 ?
> In other words, I want the name of #1 to be reported in #4. If I use
> $_SERVER["PHP_SELF"], that variable reports the name of #4. It gets a
> little tricky because #3 is called from within a JavaScript tag.
Have you looked at $_SERVER['HTTP_REFERER']?
You may need to pass it around in a new variable <?php $source_page =
$_SERVER['HTTP_REFERER']?> from PHP to JavaScript and back again, but it's
there for you to use it.
--
Like Music?
http://l-i-e.com/artists.htm
Navigation:
[Reply to this message]
|