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.

General Questions

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

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

Content displaying on certain mentioned day


Reply

6 Posts   674 Views

Avatar
musicfreak1995

5 May 2011 at 7:30pm Community Member, 28 Posts

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

5 May 2011 at 8:15pm Forum Moderator, 1796 Posts

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

5 May 2011 at 10:13pm Community Member, 28 Posts

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

Avatar
Hibari

12 July 2011 at 1:20pm (Last edited: 12 July 2011 1:23pm), Community Member, 9 Posts

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

15 July 2011 at 2:34am Community Member, 528 Posts

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

15 July 2011 at 2:41am Forum Moderator, 1796 Posts

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.