Activate/show in menu after certain date

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
lewis
Forum Members
Forum Members
Posts: 14
Joined: Mon Jun 30, 2008 11:20 pm

Activate/show in menu after certain date

Post 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?
User avatar
frankmanl
Power Poster
Power Poster
Posts: 425
Joined: Sat Jul 12, 2008 3:50 am

Re: Activate/show in menu after certain date

Post 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
lewis
Forum Members
Forum Members
Posts: 14
Joined: Mon Jun 30, 2008 11:20 pm

Re: Activate/show in menu after certain date

Post 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.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Activate/show in menu after certain date

Post 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
lewis
Forum Members
Forum Members
Posts: 14
Joined: Mon Jun 30, 2008 11:20 pm

Re: Activate/show in menu after certain date

Post 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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Activate/show in menu after certain date

Post 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
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Activate/show in menu after certain date

Post 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
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Activate/show in menu after certain date

Post 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...
lewis
Forum Members
Forum Members
Posts: 14
Joined: Mon Jun 30, 2008 11:20 pm

Re: Activate/show in menu after certain date

Post by lewis »

Thanks guys for all replies, I think the only solution at this time is to use news module.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Activate/show in menu after certain date

Post 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
nhaack

Re: Activate/show in menu after certain date

Post 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.
Last edited by nhaack on Thu Sep 10, 2009 10:51 pm, edited 1 time in total.
lewis
Forum Members
Forum Members
Posts: 14
Joined: Mon Jun 30, 2008 11:20 pm

Re: Activate/show in menu after certain date

Post by lewis »

Nils,
Thanks very much for that. This is great idea and I will implement it. Thanks once again!
Post Reply

Return to “CMSMS Core”