isNewMonth

Is Coranto not working properly for you? Here's where to ask for support help; for best results, follow these steps:
  • - Check your core/addon documentation for possible solutions
  • - Search these forums for similar problems that have already been solved
  • - If you're still stumped, check out THIS TOPIC, and post your question in this forum!!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

isNewMonth

Postby sstoner » Sat Jan 29, 2005 8:44 pm

Hi all,
A problem recently popped up when using the isNewMonth Sub. I'm wondering if this has something to do with the new year. My archives prior to January 2005 look like this (which is what I want).

December 2004
headline
headline 2
headline 3

November 2004
headline
headline 2
headline 3

Everything was working fine until we hit the new year. Now, the month of January 2005 is displaying like this:

January 2005
headline

January 2005
headline 2

January 2005
headline 3

This is the code I'm using in my style:

Code: Select all
<If: Sub: isNewMonth>
<div style="font-weight:bold;padding-top:20px;"><Field: Month_Name> <Field: Year></div>
</If>
<div>&middot; <a href="<MaginotURL: News>"><Field: Subject></a></div>


Does anyone know why this is no longer working? I'm using Coranto 1.23.
Sue's Coranto Addons - http://www.ineb.org/sue
User avatar
sstoner
 
Posts: 85
Joined: Thu Feb 05, 2004 2:27 am
Location: Nebraska

Postby Parahead » Sun Jan 30, 2005 9:16 am

My guess when I saw your post was the it was caused by interpretating January as month 0, which would cause problems doing some tests. I checked that out and it really was the cause, so this is a bug in the isNewMonth routine. Open up the file crlib.pl and do a search for "isNewMonth", and you will find a routine that looks like this:
Code: Select all
my(%NewMonthInfo, $lastAnswerMonth, $lastIDMonth);
sub isNewMonth {
 my $isNewMonth;
   
 if ($newsid eq $lastIDMonth && $ProfileName eq $lastProf && $FileName eq $lastFile) {
  return $lastAnswerMonth;
 }
 my $Month = $Month;
 if (!$NewMonthInfo{"$ProfileName--$FileName"} || $NewMonthInfo{"$ProfileName--$FileName"} ne $Month) { # First new Month
  $lastIDMonth = $newsid;
  $lastAnswerMonth = 1;
  $NewMonthInfo{"$ProfileName--$FileName"} = $Month;
  return 1;
 }
 else { # Next same date
  return 0;
 }
}

Change the line:
Code: Select all
my $Month = $Month;
to instead be:
Code: Select all
my $Month = $Month_Number;
and it will work as intended.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby sstoner » Sun Jan 30, 2005 9:44 am

Thanks Parahead! Works perfectly now :D
Sue's Coranto Addons - http://www.ineb.org/sue
User avatar
sstoner
 
Posts: 85
Joined: Thu Feb 05, 2004 2:27 am
Location: Nebraska

Postby Parahead » Sun Jan 30, 2005 9:52 am

sstoner wrote:Thanks Parahead! Works perfectly now :D
Great! :-) Actually this post has inspired me to a new addon. I started to think about that we have a sub for isNewYear, isNewMonth and so on. I have also suggested a isNewXXX routine in this thread before, but why not have isNewValue sub to which you pass the name of the field you would like to check up on instead. That would make it much more generic and flexible...

I am just writing this down as much as for my own memory, or if anyone else feels up to making such an addon... :-D

It would involve using ${$FieldName} in the isNewValue sub and also require a new tag in the style to be able to pass the name. Something like this:
Code: Select all
<If: isNewValue: Name_Of_Field>
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby sstoner » Sun Jan 30, 2005 10:40 am

Parahead wrote:
I am just writing this down as much as for my own memory, or if anyone else feels up to making such an addon... :-D

Is this a hint :D
Sue's Coranto Addons - http://www.ineb.org/sue
User avatar
sstoner
 
Posts: 85
Joined: Thu Feb 05, 2004 2:27 am
Location: Nebraska

Postby Parahead » Sun Jan 30, 2005 10:44 am

sstoner wrote:
Parahead wrote:
I am just writing this down as much as for my own memory, or if anyone else feels up to making such an addon... :-D

Is this a hint :D
Well, I have quite a lot on my TODO list, so it really was ment as a memory savier, if I would like to pick this thought up again. But I really would not mind if anyone else found the need and had the knowledge to do it... ;-)
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby fridolf78 » Mon Feb 07, 2005 2:32 pm

Parahead wrote:
sstoner wrote:Thanks Parahead! Works perfectly now :D
Great! :-) Actually this post has inspired me to a new addon. I started to think about that we have a sub for isNewYear, isNewMonth and so on. I have also suggested a isNewXXX routine in this thread before, but why not have isNewValue sub to which you pass the name of the field you would like to check up on instead. That would make it much more generic and flexible...

I am just writing this down as much as for my own memory, or if anyone else feels up to making such an addon... :-D

It would involve using ${$FieldName} in the isNewValue sub and also require a new tag in the style to be able to pass the name. Something like this:
Code: Select all
<If: isNewValue: Name_Of_Field>


I support the idea! :)
fridolf78
 
Posts: 60
Joined: Mon Feb 16, 2004 1:32 pm

Postby jayo » Thu Jan 05, 2006 2:38 am

Parahead wrote:My guess when I saw your post was the it was caused by interpretating January as month 0, which would cause problems doing some tests. I checked that out and it really was the cause, so this is a bug in the isNewMonth routine. Open up the file crlib.pl and do a search for "isNewMonth", and you will find a routine that looks like this:
Code: Select all
my(%NewMonthInfo, $lastAnswerMonth, $lastIDMonth);
sub isNewMonth {
 my $isNewMonth;
   
 if ($newsid eq $lastIDMonth && $ProfileName eq $lastProf && $FileName eq $lastFile) {
  return $lastAnswerMonth;
 }
 my $Month = $Month;
 if (!$NewMonthInfo{"$ProfileName--$FileName"} || $NewMonthInfo{"$ProfileName--$FileName"} ne $Month) { # First new Month
  $lastIDMonth = $newsid;
  $lastAnswerMonth = 1;
  $NewMonthInfo{"$ProfileName--$FileName"} = $Month;
  return 1;
 }
 else { # Next same date
  return 0;
 }
}

Change the line:
Code: Select all
my $Month = $Month;
to instead be:
Code: Select all
my $Month = $Month_Number;
and it will work as intended.



Im having the exact same problem as described by Stoner...

Ive made the change you suggest, Parahead, but that change didnt seem to have an effect. You you have another suggestion as to why?
No need for a SIG!
jayo
 
Posts: 104
Joined: Tue Mar 18, 2003 9:38 pm
Location: Los Angeles

Postby Parahead » Fri Jan 06, 2006 8:51 am

jayo wrote:Ive made the change you suggest, Parahead, but that change didnt seem to have an effect. You you have another suggestion as to why?
No, I have not, that code change do work... Post the complete code for the isNewMonth sub you are using so we can see that you have implemented the change correctly. As an alternative you could use the isNewValue addon I have created and pass the 'Month_Number' to it.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 0 guests

cron