Dave3765 Posted October 23, 2007 Share Posted October 23, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74482-mind-boggling-wrapping-a-javascript-tag-around-a-php-include-function/ Share on other sites More sharing options...
dsaba Posted October 23, 2007 Share Posted October 23, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/74482-mind-boggling-wrapping-a-javascript-tag-around-a-php-include-function/#findComment-376387 Share on other sites More sharing options...
Dave3765 Posted October 23, 2007 Author Share Posted October 23, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74482-mind-boggling-wrapping-a-javascript-tag-around-a-php-include-function/#findComment-376395 Share on other sites More sharing options...
manixrock Posted October 23, 2007 Share Posted October 23, 2007 if a javascript includes a javascript file that has php in it, you can include it normally since the js file is requested from the server every time and will parse the PHP. But I think that's not what u meant.. Quote Link to comment https://forums.phpfreaks.com/topic/74482-mind-boggling-wrapping-a-javascript-tag-around-a-php-include-function/#findComment-376487 Share on other sites More sharing options...
marcus Posted October 23, 2007 Share Posted October 23, 2007 Javascript can read PHP as JS. If the file you include is *.php then it will be read as JS. Quote Link to comment https://forums.phpfreaks.com/topic/74482-mind-boggling-wrapping-a-javascript-tag-around-a-php-include-function/#findComment-376491 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.