Page 1 of 1

Activate/show in menu after certain date

Posted: Thu Sep 03, 2009 4:14 pm
by lewis
Hi,
I would like to have a possibility to display content pages in menu only if specified date and time has passed.This is for newsletter purposes.

I am sending newsletter once a month and have some new pages to display on website after the newsletter is sent. I am using external system for newsletters and I am scheduling there mails to be sent. I would like also at the same time enable some pages to be visible on my page (either by change Active flag or Show in menu), but would like to automate it. Any ideas?

Re: Activate/show in menu after certain date

Posted: Fri Sep 04, 2009 2:50 am
by frankmanl
Lewis,
How about not using a page but using news articles? When you write a news article and check the Use expiration date box, you can enter a start and end date.

Frank

Re: Activate/show in menu after certain date

Posted: Fri Sep 04, 2009 8:47 am
by lewis
I believe it will not work as post date is only indication put in the content of news. It doesn't hide news until the post date will pass. You can post news with future date. Expiration date is what I am looking for, but from other end of process.

Re: Activate/show in menu after certain date

Posted: Fri Sep 04, 2009 9:13 am
by RonnyK
Lewis,

Frank meant the expiration tick in News, which when ticked, shows the date-range, in between a News entry is valid. So the entry will only show (default sorted by postdate) when the current date is between the expirations start/end.

Ronny

Re: Activate/show in menu after certain date

Posted: Fri Sep 04, 2009 9:17 am
by lewis
Hi,
Thanks, this is clear now. But it will not work for me as this would cause lot of work: the pages that needs to be shown after certain date are linked from newsletter and changing the URLs for pages belonging to previously sent newsletters will cause links to stop working. I know that I can do some aliases or taylor news system to match the URLs, but in this case it is not worthy to spend such amount of time.

Re: Activate/show in menu after certain date

Posted: Fri Sep 04, 2009 9:30 am
by Rolf
lewis wrote: changing the URLs for pages belonging to previously sent newsletters will cause links to stop working.
You can use the .htaccess file to 301-redirect the old page-urls to new news-urls...

Grtz. Rolf

Re: Activate/show in menu after certain date

Posted: Fri Sep 04, 2009 9:31 am
by RonnyK
Do you mean, that you WANT them to show after a certain date, but do NOT want them to dissappear later... That is doable, by putting in a real far-away expiry-date....

If the issue is that you want to show pages, that are linked to by the mailing-list, then you can link to pages that are hidden in menu, but active... That way when people link to a page, it will show, only in menu it doesnt show...

Ronny

Re: Activate/show in menu after certain date

Posted: Sat Sep 05, 2009 2:59 am
by jmcgin51
I believe you could put some custom Smarty logic in the menu template to show pages with certain aliases only after a certain date.  But it could become quite cumbersome...

Re: Activate/show in menu after certain date

Posted: Sat Sep 05, 2009 1:07 pm
by lewis
Thanks guys for all replies, I think the only solution at this time is to use news module.

Re: Activate/show in menu after certain date

Posted: Sat Sep 05, 2009 1:16 pm
by RonnyK
You could try using a extra-field in the content-page, and see if that works when calling in the MenuManager template....

Ronny

Re: Activate/show in menu after certain date

Posted: Thu Sep 10, 2009 10:49 pm
by nhaack
That's a great idea. You could write the dates e.g. YYYY-MM-DD for expiration and start date of a page into extra 1 and extra2

Then request these into your menu template and use little UDT that takes the current date and checks it's in the valid range.

Code: Select all


{foreach from=$nodelist item=node}
...
 {check_date start=$node->extra1 end=$node->extra2 assign="something"}
   {if $something != false}
      <a href="{$node->url}">{$node->menutext}</a>
   {/if}
...
{/foreach}

The UDT would look something like that (not tested, this is just an idea):

Code: Select all


$today = date("Y-m-d"); 
$start = $params['start'];
$end= $params['end'];

$today = strtotime($today); 
$start = strtotime($start ); 
$end= strtotime($end); 

if (($today > $start ) and ($today < $end )) {
     $smarty->assign($params['assign'], true);
  } else {
     $smarty->assign($params['assign'], false);
  }

return;

That way, your page will automatically be taken of your navigation but is still available as an active page.

Alternatively, you could also just set the page to "not show in menu".

If you want your links to work but don't want people to see the old content, you could implement the date check into your template, so your page could automatically send location header information to the users browser. To your current news index page for example if the page is "outdated". There are several ways to get the extra fields. In the template, right after the beginning body tag, you could have a smarty logic like that:

Code: Select all


 {check_date start=$content_obj->GetPropertyValue('extra1') end=$content_obj->GetPropertyValue('extra2')  assign="something"}
   {if $something != true}
      {send_to_other_page page="my-primary-news-page-url"}
   {/if}

You would have to create a second UDT with the name "send_to_other_page":

Code: Select all


  $location = $params['page']:
  header ('HTTP/1.1 301 Moved Permanently');
  header ('Location: '.$location);

These are just some ideas - I'm curious about what you think of it. :)

Best
Nils.

Re: Activate/show in menu after certain date

Posted: Fri Sep 11, 2009 5:58 am
by lewis
Nils,
Thanks very much for that. This is great idea and I will implement it. Thanks once again!