Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Scheduled Blog Post (future dates)


Go to End


2 Posts   2755 Views

Avatar
Yellow7 Jon

Community Member, 39 Posts

7 May 2010 at 2:01am

Edited: 07/05/2010 2:03am

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()";
			}
		}

Avatar
Bstarr

Community Member, 25 Posts

30 June 2011 at 4:37am

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 = '';
		}