3

Please bear with me, I am pretty new to Joomla, and I only have a slightly operational knowledge of web design.

So here's what I want to do; Our church streams our sermons every sunday morning from about 10:30 to about 12:30. I want to redirect all pages under our domain (with the exception of the admin page) to the live stream url. I know it's probably just a matter of throwing together a script, but I lack the proficiency to do so from scratch. If someone could just get me started, I think I could tweak whatever parameters I need to to make it do what I want.

Thanks!

1

Maybe not the most elegant solution, but you can add the following code to the beginning of your templates index.php file (located in ROOT/templates/YOURTEMPLATE/index.php):

<?php
    $hour = date('G');
    $minute = date('i');
    $day = date('w');
    $m = $hour * 60 + $minute; // Minutes since midnight.
    if(
      $day == 0 // Sunday...
      && $m >= 630 // ... after 10:30…
      && $m <= 750 // ... but before 12:30…
    ) header("Location: http://example.com");
?>

This should redirect all your visitors to http://example.com every Sunday between 10:30 and 12:30.

Keep in mind that PHP is a server side language, so you might have to compensate for timezones depending on your PHP time/date settings and your actual location.

(Code modified from this post.)

  • This is great! thank you! Time zone restriction, for the time being, should not be an issue. We may wish to change that in the future as we grow, but now we have mostly local people watching anyway, and our server is local, so we should be fine on that front. Thanks again! – user3391359 May 4 '15 at 4:29
  • @user3391359 It would probably be better to use a Javascript redirect in a module (custom HTML or some add custom script module) that can be published and unpublished as needed and does not get overwritten with template updates. Not making a separate answer since what the script does doesn't really change with moving from PHP to JS. And for all I know you know JS better than I do... – Ville Niemi May 4 '15 at 12:27
  • +1 for the answer, however I would recommend making a small plugin for this rather than editing the template's index.php. At least that way no changes will be overridden and it can easily be disable if need be ;) – Lodder May 4 '15 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.