Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2006
    Location
    Barnhart, MO
    Posts
    285

    Display content for Scheduled dates

    I have been asked to work include some content on a website starting December 1st and to remove it at the end of the month.

    To manually input this and remove it is all too easy. I am looking for a reference or an example to input this content ahead of time and have it displayed for the one month durration automatically.

    The website is coded in .shtml.

    Any advice appreciated.
    Atech St. Louis - Web Hosting - Website builder - 24/7 Support
    Dads In Distress - Dads helping Dads in Distress

  2. #2
    Join Date
    May 2009
    Posts
    766
    Quote Originally Posted by atechstl View Post
    The website is coded in .shtml.
    Are you serious?

    You need to start by understanding what SSI even is (quite often, just a gateway to another server-side scripting technology)...

    http://en.wikipedia.org/wiki/Server_Side_Includes
    http://httpd.apache.org/docs/1.3/howto/ssi.html

    This is extremely simple to do in any programming language, however it does not sound like you understand the basic concepts at play here. What you want to do is possible using strictly SSI (I think), however you could really benefit from a scripting language here.
    Last edited by mattle; 11-13-2009 at 12:09 PM.

  3. #3
    Join Date
    Oct 2002
    Location
    State of Disbelief
    Posts
    22,951
    PHP would do this. Something like this might do it:
    PHP Code:
          <?php
       
    if (time() >= strtotime('December 1, 2009') && time() < strtotime('January 1, 2010')){
                  echo 
    'All your stuff here'// Or you could include a file that has it all using include('/path/to/file.ext');
              
    }else{
             echo 
    "It's over, go home";
          }
          
    ?>
    Having problems, or maybe questions about WHT? Head over to the help desk!

  4. #4
    Join Date
    May 2009
    Posts
    766
    Quote Originally Posted by bear View Post
    PHP would do this. Something like this might do it:
    PHP Code:
          <?php
       
    if (time() >= strtotime('December 1, 2009') && time() < strtotime('January 1, 2010')){
                  echo 
    'All your stuff here'// Or you could include a file that has it all using include('/path/to/file.ext');
              
    }else{
             echo 
    "It's over, go home";
          }
          
    ?>
    PHP Code:
    # php
    <?
    echo date("m-d-Y") . "\n";
    if (
    time() >= strtotime('December 1, 2009') && time() < strtotime('January 1, 2010')){
                  echo 
    'All your stuff here'// Or you could include a file that has it all using include('/path/to/file.ext');
              
    }else{
             echo 
    "It's over, go home";
          }
          
    ?>
    11-13-2009
    It's over, go home
    Aw man...it's over before it even began!!!

  5. #5
    Join Date
    Oct 2002
    Location
    State of Disbelief
    Posts
    22,951
    So, two people you basically pick apart for getting it wrong (PHP is obviously not my day job), but where's your example of getting it right, please?
    Teach.

    Or try this instead:
    PHP Code:
          <?php
        
    if (time() < strtotime('January 1, 2010') && (time() >= strtotime('December 1, 2009'))){
          echo 
    "December stuff here";
        }else{
    echo 
    "Non December stuff here";             
        }
        
    ?>
    Last edited by bear; 11-13-2009 at 01:23 PM. Reason: took "=" off Jan so it ends in December
    Having problems, or maybe questions about WHT? Head over to the help desk!

  6. #6
    Join Date
    Dec 2006
    Location
    Barnhart, MO
    Posts
    285
    Thanks for the help guys. I can certainly do PHP but I will have to change the file extension.

    I will try it out.
    Atech St. Louis - Web Hosting - Website builder - 24/7 Support
    Dads In Distress - Dads helping Dads in Distress

  7. #7
    Join Date
    Nov 2005
    Posts
    123
    bear - Nothing wrong with your first code (as you probably know), but the message should have been along the lines of "You're either too early or too late." I think the message is what mattle was chuckling about.

  8. #8
    Join Date
    Oct 2002
    Location
    State of Disbelief
    Posts
    22,951
    Yup, fair enough (though the latter one works far better). I just get a little frustrated sometimes when people don't help.
    Having problems, or maybe questions about WHT? Head over to the help desk!

  9. #9
    Join Date
    Nov 2005
    Posts
    123
    OK, here's some help in the form of an alternative suggestion
    PHP Code:
    if (date('ym') == '0912') {
        echo 
    'December 2009';
    } else {
        echo 
    'Not December 2009';

    Last edited by bigfan; 11-14-2009 at 11:04 AM.

  10. #10
    Join Date
    May 2009
    Posts
    766
    Quote Originally Posted by bear View Post
    Yup, fair enough (though the latter one works far better). I just get a little frustrated sometimes when people don't help.
    I'm always willing to help...that's why I posted links that explain SSI so that the OP could get a better understanding of the technology.

    The website is coded in .shtml.
    That's a big red flag that the OP has a hole in their fundamental knowledge of dynamic web content. How is it not helping to point someone to reference material? For that matter, how is it helping to write someone's code for them, offering no explanation of what the code actually does and why it works?

  11. #11
    Join Date
    Mar 2009
    Posts
    2,218
    And there's the interesting question of how one tests whatever solution one chooses.

    I suppose what one can do is have a server-side script that generates a date and timestamp, then includes the latest file whose name is less than that date and timestamp.

    So if you had a set of files

    190001010000.inc
    200911160800.inc
    200911230800.inc
    200912031200.inc

    the web server would include 200911160800.inc till 08:00 on November 23, when it would switch to including 200911230800.inc (which might be a blank file.)

    The idea here is because there are no code changes, the change management is easier.

  12. #12
    Join Date
    Oct 2002
    Location
    State of Disbelief
    Posts
    22,951
    Quote Originally Posted by tim2718281 View Post
    And there's the interesting question of how one tests whatever solution one chooses.
    Change the dates in the script.
    Having problems, or maybe questions about WHT? Head over to the help desk!

  13. #13
    Ruby, but this shouldn't be handled as such
    Code:
    puts "Something" if Time.now.month == 12

  14. #14
    Join Date
    May 2009
    Posts
    766
    Quote Originally Posted by bear View Post
    Change the dates in the script.
    Or if you're just testing proof of concept, use CLI...no need for script changes

    PHP Code:
    <?
    $time 
    = (isset($argv[1]) ? strtotime($argv[1]) : time());

    if (
    $time strtotime("12/1/2009"))
      
    doSomething();
    else if (
    $time strtotime("1/1/2010"))
      
    doSomethingElse();
    else
      
    doYetSomethingElse();
    ?>

    #php myScript.php "11/30/09"
    executes doSomething()

    #php myScript.php "12/10/09"
    executes doSomethingElse()

    #php myScript.php "1/1/10"
    executes doYetSomethingElse()

    #php myScript.php
    executes appropriate fn based on current date

Similar Threads

  1. Health related blog with 1 year scheduled content
    By edpudol in forum Domain Name with Web Site Offers
    Replies: 0
    Last Post: 02-11-2009, 02:06 PM
  2. How to display dates in database with php
    By shwetank in forum Programming Discussion
    Replies: 5
    Last Post: 01-02-2006, 01:47 AM
  3. How To display XML content from a Url in my website???
    By kumar30 in forum Hosting Security and Technology
    Replies: 0
    Last Post: 12-31-2005, 01:32 PM
  4. information to display when content is seached, can you change?
    By lokodezine in forum Web Design and Content
    Replies: 1
    Last Post: 05-12-2004, 08:19 PM
  5. Dates are off
    By MikeA in forum Web Hosting Lounge
    Replies: 1
    Last Post: 08-29-2000, 06:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •