antonyfal Posted July 7, 2011 Share Posted July 7, 2011 I been going about it the wrong way.. the search page is accessed in two ways using 2 different urls: // this loads the search with all the mainsites pages main url: www.xxxx.com/xxx/xxxx/xxxx/search.html then in a iframe like this: //this loads only the search page without the rest of the main page http:///www.xxx.com/xxx/xxx/xxx/search.html?tmpl=component i use this in the iframe on the main page. I need to add the following script to the search page to determin if the "tmpl=component" is in the url, if it is!? then it must continue to load it-- with this hidden input: <input type="hidden" name="tmpl" value="component"/> // but my snippets not working.. i dont need the parent url, only the current iframe url heres my code: </head> <body> <?php $url = $_SERVER['REQUEST_URI']; echo $url; $parts = explode("=", $url); If ($parts==component){ <input type="hidden" name="tmpl" value="component"/> }else{echo "";} ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/241322-get-iframe-url-into-a-if-function-on-html-page-not-working/ Share on other sites More sharing options...
micah1701 Posted July 7, 2011 Share Posted July 7, 2011 how about... <?php //$url = $_SERVER['REQUEST_URI']; // echo $url; // $parts = explode("=", $url); // If ($parts==component){ if(isset($_GET['tmpl']) && $_GET['tmpl'] == "component"){ ?> <input type="hidden" name="tmpl" value="component"/> <?php }else{echo ""; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241322-get-iframe-url-into-a-if-function-on-html-page-not-working/#findComment-1239604 Share on other sites More sharing options...
antonyfal Posted July 7, 2011 Author Share Posted July 7, 2011 Thanks, But not quite working: without all the fuss, the hidden input adds the tmpl=component to the url already-- so that i get search.html page without the rest of the index.php page.. What im trying to do is to let the search page determin weather it is called by the Iframe or not-- If its called by the iframe the url will have tmpl=component in it and it is neccesary to continue this url with the tmpl=component in it and the hidden input must be displayed-- if there is no tmpl=component in the url, then the search.html page must not load the hidden input.. So the link in the iframe == www.xxxxx.com/xxxx/xxxxx/xxxxx/search.html/?tmpl=component // so now the page know's its in an iframe and will continue to load the hidden input.. if no tmpl=component then the hidden input should not load.. The fix you gave me loaded the hidden input on both urls.. is it maybe missing something? Quote Link to comment https://forums.phpfreaks.com/topic/241322-get-iframe-url-into-a-if-function-on-html-page-not-working/#findComment-1239671 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.