Jump to content

Auto-populate calendar based on date


kjacobson

Recommended Posts

Not sure if this is better in the Web to Print Form or the JavaScript forum, but here it goes.

 

I am putting together a Web to Print template for a class brochure. For part of the brochure the user chooses from a drop-down the title of the class, then they fill in the dates for the class. From this information, I want to auto-populate a calendar where the title of the class goes into the correct date frame.

 

I'm thinking for each calendar date frame a code that loops something like:

If Field[C1Class1Date1] = Field["Month"]+" 1";

return Field["C1Class1Title"];

else

return"";

 

Where C1Class1Date1 and C1Class1Title would cycle through all the class fields.

 

I'm guessing for each calendar date frame (1st, 2nd, 3rd), I will need a different rule.

Also, each frame would need a list of no more than 8 classes.

 

This is how my fields are setup:

C1Class1Title

C1Class1Date1

C1Class1Date2

C1Class2Title

.

.

.

C1Class10Title

.

.

.

C2Class1Title

.

.

.

C10Class10Title

 

I'm not an expert at JavaScript, I can figure somethings out, but I don't know what the best way to accomplish this would be. Does someone know a good way to approach this or at least point me in the right direction? Any help would be greatly appreciated.

 

I have been working on this template for several weeks and I am hoping that this is the last piece I need to make it work in the manager. Currently, I have each calendar date frame as 16 different fields which make 496 fields total just for the calendar (8 title fields and 8 page fields, I'm not worried about the page numbers right now). Right now the template doesn't work on-line. It loads fine, but when I go to make a changed in the PrintOne Display and apply it, I get an error:

 

"Request Object error 'ASP 0104: 80004005'

Operation not Allowed /printfusion3/pf-Constants-Inc.asp, line 92"

 

Which appears to be a size limit error. So, I am hoping if I'm able to eliminate the 496 fields from the calendar, it might work. Otherwise, I'm going to have to separate the brochure into multiple templates, which is not the ideal solution.

 

Below are a couple of pictures to better explain what I need to do. There is also a link to my template, if you look at it, don't laugh.:D I've never done a template this large and I've been piecing it together as I go.

 

.Zip Template Files

 

http://printable.p1nnacle.com/rei/classes1.jpg

 

http://printable.p1nnacle.com/rei/classes2.jpg

 

Thank you in advance for any help you can give. I'm a bit out of ideas at this point.

Link to comment
Share on other sites

I've been banging my head against the wall about this for the last few days. I'm wasting a lot of time going around in circles trying to figure this out. I figure I need to use a loop and store the results in array, but this is beyond me. I'm learning a lot about JavaScript, but can't seem to put the pieces together for this one.

 

I being pressured from several angles to get this working. I could really use a push in the right direction.

Link to comment
Share on other sites

Hi Kristal,

 

I get a 404 when trying to download your files, although performing a full analysis of your job and building a complex template for it is a bit beyond the scope of this forum. You may need to consider some paid Consulting time. However, I can take a few minutes to try to steer you in the right direction.

 

My first bit of advice is that you may want to consider using a table to output the entire calendar for the month instead of making a grid of 20-something text frames. Take a look at the Frodo Travel Tutorial for an example of this. You'll be generating the table markup in a single JavaScript rule. This approach is a little less WYSIWYG until you get it working in Preview, but it gives you a lot more power and flexibility than dozens of (statically located) text frames and a dozens of corresponding rules to populate them. This is actually a very common usage of FusionPro; you may want to ask about that aspect of the job in the general FP Desktop forum, which more users can see.

 

As for looping to determine whether to list a class on a particular date (in a particular cell in the table), I can't tell you exactly what to do without seeing the data, but it's probably something like this:

 
var Month = Int(Field("Month"));
var result = "";
var numClasses = 10;
for (var i = 1; i <= numClasses; i++)
{
 var ClassTitleFieldName = "C" + i + "Class" + i + "Title";
 var ClassTitle = "";
 try { ClassTitle = Field(ClassTitleFieldName); } catch (e) {}
 if (!ClassTitle)
   continue;

 var maxDates = 20; // ???
 for (var j = 1; j <= maxDates; j++)
 {
   var ClassDateFieldName = "C" + i + "Class" + i + "Date" + j;
   var ClassDateString = "";
   try { ClassDateString = Field(ClassDateFieldName); } catch (e) {}
   if (!ClassDateString)
     break;
   var ClassDate = DateFromString(ClassDateString);
   if (ClassDate.getMonth()+1 == Month)
     result += NormalizeEntities(ClassTitle) + "<br>\n";
 }
}
return result;

As for the error message you're getting from FP Web, please bring that to the attention of your CPM.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...