Publish/vanish page to a specific date

Permalink 1 user found helpful
Hi people,

i am playing around with C5 for a while and happily learning more and more tricks. Now I haven't found an answer to this one:

Is it possible somehow, to create a page and add some attribute that the pages permissions will be set to "View>Guests" on a specific date and will be unviewable to another specific date?

This way it would be so easy to set up date-specific pages like for events without hesitating to make them invisible after the event.

Anybody any ideas?

View Replies:
beebs93 replied on at Permalink Reply 1 Attachment
beebs93
If you use the advanced permissions model you can set "timed release settings" which will allow any user group access to any page you wish for the date/times you specify.

http://www.concrete5.org/documentation/general-topics/simple-permis...

(See attached)
ministrycrm replied on at Permalink Reply 1 Attachment
ministrycrm
I got Publish and Unpublish to work by creating three new templates for AutoNav, Pagelist, DateNav & the default slider. The code is pretty straight forward.

First:
Create a custom attribute called Unpublish (This should be a date field)

Then I create two variables inside the custom view template:
$publish = strtotime($cobj->getCollectionDatePublic('M j, Y'));
$unpublished = strtotime($cobj->getAttribute('unpublish_date')); ?>


Now we need to create some logic:
//set $pub var to 0 so we get a fresh look at each item we loop through
$pub=0;
//if there is no unpublish date or the unpublish date is in the future then $pub = 1
if($unpublished =='' || $unpublished >= time()){
        //Check to see if this we should be publishing yet
   if(time()>$publish){
      $pub = 1;
   }else{
      $pub = 0;
   }
}else{
   $pub = 0;
}


Finally, we have a variable called $pub and it is either 1 or 0 (true or false) and it is time to wrap our display code with another if statement.

Here is an example (auto-nav):
$publish = strtotime($_c->getCollectionDatePublic('M j, Y'));
$unpublished = strtotime($_c->getAttribute('unpublish_date'));
$pub=0;
if($unpublished =='' || $unpublished >= time()){
   if(time()>$publish){
      $pub = 1;
   }else{
      $pub = 0;
   }
}else{
   $pub = 0;
}
if($pub==1){
  if ($c->getCollectionID() == $_c->getCollectionID()) { 
    echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');


I attached some custom view files

Hope this helps