Jump to content

MIND BOGGLING: Wrapping a Javascript Tag Around a PHP INCLUDE Function


Recommended Posts

I have a header file that is called using the php include function across my site, and it has a mix of php, html and javascript in it.

 

I am using Google website optimizer and want to test one header against another, and I thought I could just vary the include line and let Google choose a header to show to my visitors.

 

Here's the problem: Google uses javascript to vary the page elements when running a test, which is client side so I have a mind boggling problem.

 

I need to find a way to wrap a javascript tag around a php include function. The javascript tag Google uses looks like this:

 

<script>utmx_section("Header")</script>
HERE IS WHERE I THOUGHT I COULD PUT THE PHP INCLUDE.... BUT I CANT!
</noscript>

 

 

If anyone has a creative solution to this please let me know. The closest I could find to a similar situation on the web can be seen here:

http://groups.google.com/group/websiteoptimizer/browse_thread/thread/afc3a5722117e054

 

Thanks,

 

Dave

 

 

 

 

dunno if this helps but think of it this way..

js is client side

php is server side

 

you can generate js with php, but thats it

 

if you're tryign to include a page in javascript you have to inlude it IN JAVASCRIPT....

 

well it depends what you're doing...

 

answer these questions:

1. where does it need to be?

2. who needs to read it?

 

if you need to get some google script to recognize the change..well thats probably something with javascript to make it recognize this.. etc...

Hey dsaba,

 

I've looked at javascript includes and at first I thought "GREAT!", but the header file I want included has php in it, so once the javascirpt includes the header file the php won't be able to run as everything will already be on the client's browser.

 

Here are the answers to your questions:

 

1) *I think* that the Google Javascript code needs to be ideally wrapped around the php include for my header file so I can let Google choose a version to show to visitors, but we know that isn't possible.

 

2) The final page needs to be read on the client's side by regular visitors to my site and Google via the piece of javascript.

 

Any ideas? Would I have to use AJAX to re-query the database once a javascript include has called the header file, and if so would that mean heavy modification to the php in my header file?

 

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.