Mike Waller
asked on
if statement in php
I need to place an if, then statement in my index.php page so that if the page is /apply-online/ then it invokes some javascript on that index.php
This is a wordpress site and index.php in the root is where I had the script but I need to move it off of that home page and onto an internal page which is /apply-online/
Any ideas?
This is a wordpress site and index.php in the root is where I had the script but I need to move it off of that home page and onto an internal page which is /apply-online/
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried the following and the jquery popup loads on the home page if I set $uri to '/' but not if I set the path to /apply-online/
Any idea why?
Any idea why?
<?php
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "/apply-online/") {
echo "<link rel='stylesheet' href='js/shadowbox/shadowbox.css' type='text/css' media='screen' />
<script type='text/javascript' src='js/nav.js'></script>
<script type='text/javascript' src='js/nav.js'></script>
<script type='text/javascript' src='js/jquery-1.3.2.min.js'></script>
<script type='text/javascript' src='js/shadowbox/shadowbox.js'></script>
<script type='text/javascript'>
Shadowbox.init({
displayNav: true,
onClose:function(){
top.location.href='http://domain.com/?s=';
}
});
$(function() {
if (document.URL == 'http://domain.com/') {
setTimeout(function() {
//Shadowbox.init();
Shadowbox.open({
player: 'iframe',
content: 'test1.cfm',
displayNav: true,
width: '840',
height: '750',
modal: true
});
}, 2000);
}
});
function getCookieValue1() {
var openUrl = '';
var c_name = 'nowUrlIs';
if (document.cookie.length > 0) {
var c_start = document.cookie.indexOf(c_name + '=');
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
var c_end = document.cookie.indexOf(';', c_start);
if (c_end == -1)
c_end = document.cookie.length;
openUrl = document.cookie.substring(c_start, c_end);
setTimeout(function() {
//Shadowbox.init();
Shadowbox.open({
player: 'iframe',
content: openUrl,
displayNav: true,
width: '840',
height: '750',
title: 'Please click out side the frame to close it',
modal: false
});
}, 2000);
}
}
}
</script>";
} else {
echo $_SERVER['REQUEST_URI'];
}
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ropenner, my page broke using that.
ASKER
I need to remove those double quotes around all of my code because I think it sees it all as a string. I tried removing the double quotes but it didn't work
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tried that but it didn't work.
So I have which works from the home page and the internal page path /apply-online/ displays at the bottom just fine. Just can't get that darn popup to show up on that page.
So I have which works from the home page and the internal page path /apply-online/ displays at the bottom just fine. Just can't get that darn popup to show up on that page.
<?php
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "/") {
echo "<link rel='stylesheet' href='/js/shadowbox/shadowbox.css' type='text/css' media='screen' />
<script type='text/javascript' src='/js/nav.js'></script>
<script type='text/javascript' src='/js/jquery-1.3.2.min.js'></script>
<script type='text/javascript' src='/js/shadowbox/shadowbox.js'></script>
<script type='text/javascript'>
Shadowbox.init({
displayNav: true,
onClose:function(){
top.location.href='http://domain.com/?s=';
}
});
$(function() {
if (document.URL == 'http://domain.com/') {
setTimeout(function() {
//Shadowbox.init();
Shadowbox.open({
player: 'iframe',
content: 'test1.cfm',
displayNav: true,
width: '840',
height: '750',
modal: true
});
}, 2000);
}
});
function getCookieValue1() {
var openUrl = '';
var c_name = 'nowUrlIs';
if (document.cookie.length > 0) {
var c_start = document.cookie.indexOf(c_name + '=');
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
var c_end = document.cookie.indexOf(';', c_start);
if (c_end == -1)
c_end = document.cookie.length;
openUrl = document.cookie.substring(c_start, c_end);
setTimeout(function() {
//Shadowbox.init();
Shadowbox.open({
player: 'iframe',
content: openUrl,
displayNav: true,
width: '840',
height: '750',
title: 'Please click out side the frame to close it',
modal: false
});
}, 2000);
}
}
}</script>";
} else {
echo $_SERVER['REQUEST_URI'];
}
?>
I think WordPress may be getting in your way of understanding the PHP-related issues here. How much experience do you have in PHP (outside of WP)?
ASKER
Thanks!
ASKER