PLEASE HELP with page redirect!
Permalink
Hello! I posted a week or so ago, but did not get a good answer to my question. I know everyone volunteers their time, so I am truly appreciative; however...if anyone might be able to give me a step-by-step process on what to do I would really appreciate it--ALOT! Here is my question:
"I have a certain page in my website that has a streaming XML player on it. It plays previously recorded shows. I want this page to redirect automatically at a specific time and day every week to another page in my site for approx. 1 hour. Is this possible to automate? I know it is...I just need a step-by-step process for it in terms I can understand. I am not new to web design...but dealing with things on this level...I am a newB.
Thank you everyone...SO SO Mucho!!
Dennis
"I have a certain page in my website that has a streaming XML player on it. It plays previously recorded shows. I want this page to redirect automatically at a specific time and day every week to another page in my site for approx. 1 hour. Is this possible to automate? I know it is...I just need a step-by-step process for it in terms I can understand. I am not new to web design...but dealing with things on this level...I am a newB.
Thank you everyone...SO SO Mucho!!
Dennis
Thanks, jbx/Jon! Well...is this what you are talking about? [below]. There seems to be another way; what about just adding the php to the header before content?
<?php
$hour = date('G');
$minute = date('i');
$day = date('w');
$m = $hour * 60 + $minute; // Minutes since midnight.
if(
$day == 6 // Saturday...
&& $m >= 735 // ... after 12:15...
&& $m <= 1035 // ... but before 17:15...
) header("Location: saturdayafternoon.php");
else if(
$day == 4 // Wednesday...
&& $m >= 1155 // ... after 19:15...
&& $m <= 1335 // ... but before 22:15...
) header("Location: wednesdaynight.php");
?>
or something like this.....placed in the header of the page itself??
<?php $b = time () ;
$day = date("D",$b) ;
switch($day){
case "Sat": header( 'Location:http://new_page_example.com'... ) ;
}
?>
Is this code even correct?
<?php
$hour = date('G');
$minute = date('i');
$day = date('w');
$m = $hour * 60 + $minute; // Minutes since midnight.
if(
$day == 6 // Saturday...
&& $m >= 735 // ... after 12:15...
&& $m <= 1035 // ... but before 17:15...
) header("Location: saturdayafternoon.php");
else if(
$day == 4 // Wednesday...
&& $m >= 1155 // ... after 19:15...
&& $m <= 1335 // ... but before 22:15...
) header("Location: wednesdaynight.php");
?>
or something like this.....placed in the header of the page itself??
<?php $b = time () ;
$day = date("D",$b) ;
switch($day){
case "Sat": header( 'Location:http://new_page_example.com'... ) ;
}
?>
Is this code even correct?
Or this....
<?php
$day = date("D"); //returns "Mon" "Tue"
$time = date("Hi"); //returns HoursMinutes
if( ($day == "Sat" && $time >= "1930" && $time < "2030") ||
($day == "Sun" && $time >= "0830" && $time < "1330") )
{
header("Location: REDIRECT URL");
exit;
}
?>
<?php
$day = date("D"); //returns "Mon" "Tue"
$time = date("Hi"); //returns HoursMinutes
if( ($day == "Sat" && $time >= "1930" && $time < "2030") ||
($day == "Sun" && $time >= "0830" && $time < "1330") )
{
header("Location: REDIRECT URL");
exit;
}
?>
I would think any of those would work!
101 ways to check if it's the correct time and day.
Looks like you're on the right track :)
You need to put it in a controller though, else it will trigger on every page.
Just create a php page with the same name as your page inside /controllers. Then add the following code:
where 'mypage' is also the name of your page...
Jon
101 ways to check if it's the correct time and day.
Looks like you're on the right track :)
You need to put it in a controller though, else it will trigger on every page.
Just create a php page with the same name as your page inside /controllers. Then add the following code:
where 'mypage' is also the name of your page...
Jon
Great! Thanks...just to put it all together now...if that's okay, Jon...
1- Create file in /controller in file directory named "mypage.php" where "mypage" is the page I want visitors redirected to.
2- Insert this code in the page first:::
<?php defined('C5_EXECUTE') or die('Access Denied.');
class mypageController extends Controller {
public function on_before_render() {
// your date checking code
}
}
3- In the line "//your date checking code, enter the code examples I replied...
<?php
$day = date("D"); //returns "Mon" "Tue"
$time = date("Hi"); //returns HoursMinutes
if( ($day == "Sat" && $time >= "1930" && $time < "2030") ||
($day == "Sun" && $time >= "0830" && $time < "1330") )
{
header("Location: REDIRECT URL");
exit;
}
?>
4- Upload the file to /controller in file dir.
Please tell me if I'm missing something, or putting it together wrong..??
Also, I have attached the completed file ..if you want to take a look at it. Although I think I may have the time wrong...So basically, I guess I still don't understand how to declare the first url that will end up redirecting visitors??
THank you SO SO SO much JON!!!!
1- Create file in /controller in file directory named "mypage.php" where "mypage" is the page I want visitors redirected to.
2- Insert this code in the page first:::
<?php defined('C5_EXECUTE') or die('Access Denied.');
class mypageController extends Controller {
public function on_before_render() {
// your date checking code
}
}
3- In the line "//your date checking code, enter the code examples I replied...
<?php
$day = date("D"); //returns "Mon" "Tue"
$time = date("Hi"); //returns HoursMinutes
if( ($day == "Sat" && $time >= "1930" && $time < "2030") ||
($day == "Sun" && $time >= "0830" && $time < "1330") )
{
header("Location: REDIRECT URL");
exit;
}
?>
4- Upload the file to /controller in file dir.
Please tell me if I'm missing something, or putting it together wrong..??
Also, I have attached the completed file ..if you want to take a look at it. Although I think I may have the time wrong...So basically, I guess I still don't understand how to declare the first url that will end up redirecting visitors??
THank you SO SO SO much JON!!!!
Okay, Jon...can you please give me a quote...I am having trouble understanding what to do here. Please let me know what it would cost...
"I want "page1" to be be visible to visitors every day of the week except Saturdays from 11:00 am-12:00 noon (EST). At that time, I want visitors to automatically be redirected to "page2". After that time (noon)- it reverts back to "page1".
Please let me know what you (or anyone else who wants in on this) would charge...I thought it would be easier to do this, and I guess it is for someone like you. We are not all that gifted (yet) :)
"I want "page1" to be be visible to visitors every day of the week except Saturdays from 11:00 am-12:00 noon (EST). At that time, I want visitors to automatically be redirected to "page2". After that time (noon)- it reverts back to "page1".
Please let me know what you (or anyone else who wants in on this) would charge...I thought it would be easier to do this, and I guess it is for someone like you. We are not all that gifted (yet) :)
Okay, please help me with this simple task. I will pay...i just need it done. Anyone?? I just need a simple redirect at a certain time/day each week from one page to another...and then back again to the first page (after an hour, or even day). PLEASE HELP ME!
If your page is called /mypage, then create a controller for it in /controllers called mypage.php. Then create a method in their called on_before_render() (I think that's correct) that checks the time and redirects if required.
If you don't understand how to create controllers or write the php to check the date and perform the redirect, then unfortunately, a step-by-step guide would equate to actually building this for you, which isn't really the job of the community. I would post it up as a job, or send me a private message and I'll quote on it for you.
Jon