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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Content displaying on certain mentioned day


Go to End


6 Posts   1453 Views

Avatar
musicfreak1995

Community Member, 28 Posts

5 May 2011 at 7:30pm

Is there anyway of allowing content to display on a mentioned day- so if it was monday- the content will only display on every monday and won't display every other days content.

Avatar
swaiba

Forum Moderator, 1899 Posts

5 May 2011 at 8:15pm

I take it the advanced workflow with embargo and expiry dates did nothing for you...

how about this then...

in your page controller...

	public function Content() {
		$content = $this->getField('Content');

		if (date('N')==1) { //if Monday
			$content = 'It is Monday you get this string instead';
		}

		return $content;
	}

Avatar
musicfreak1995

Community Member, 28 Posts

5 May 2011 at 10:13pm

Wow!! Thanks:)
I can't get alot of PHP coding right! Lol

Avatar
Hibari

Community Member, 9 Posts

12 July 2011 at 1:20pm

Edited: 12/07/2011 1:23pm

Though, I think that this post definitely helped for the code inside the php, does anybody know how to make it so that it can display content that you can edit in the cms?

Any help would be greatly appreciated.

-Hibari

Avatar
zenmonkey

Community Member, 545 Posts

15 July 2011 at 2:34am

All you'd have to do is replace

$content = 'It is Monday you get this string instead';

with

$content = $this->getField('MondayContent');

And obviously add the MondayContent field to the page object

Avatar
swaiba

Forum Moderator, 1899 Posts

15 July 2011 at 2:41am

and I had pointed yer man to http://silverstripe.org/advanced-workflow-module/ this before which has options for controlling (with embargo / expiry) when certain pages can be seen.