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   759 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, 1805 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, 532 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, 1805 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.