Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » Scheduled Blog Post (future dates)

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1359 Views
  • Yellow7 Jon
    Avatar
    Community Member
    39 Posts

    Scheduled Blog Post (future dates) Link to this post

    Seems there was no way of hiding future blog posts, I searched on here, but couldn't find an answer. So for anyone in the future, you need to edit Blog/code/BlogTree.php on line 251 there is BlogEntries(), replace the filter if statement with this:

          if ($this->LandingPageFreshness && !$this->request->param('Action')) {
             if(defined('DB::USE_ANSI_SQL')) {
                $filter = "\"BlogEntry\".\"Date\" < NOW() - INTERVAL " . $this->LandingPageFreshness;
             } else {
                $filter = "`BlogEntry`.Date < NOW() - INTERVAL " . $this->LandingPageFreshness;
             }
          } else {
             /**** THIS IS THE PART THAT IS CHANGING ****/
             if(defined('DB::USE_ANSI_SQL')) {
                $filter = "\"BlogEntry\".\"Date\" < NOW()";
             } else {
                $filter = "`BlogEntry`.Date < NOW()";
             }
          }

  • Bstarr
    Avatar
    Community Member
    25 Posts

    Re: Scheduled Blog Post (future dates) Link to this post

    I'm trying to do this as well, is this still the correct approach to be able to schedule future posts? This post was over a year ago so the code in my file looks different. Below is what shows up in my code, can anyone tell me what I should be modifying?

    // only use freshness if no action is present (might be displaying tags or rss)
          if ($this->LandingPageFreshness && !$this->request->param('Action')) {
             $d = new Zend_Date(SS_Datetime::now()->getValue());
             $d->sub($this->LandingPageFreshness);
             $date = $d->toString('YYYY-MM-dd');
             
             $filter = "\"BlogEntry\".\"Date\" > '$date'";
          } else {
             $filter = '';
          }

    1359 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.