[nCtag_Calendar]
Description
If you need to show one or more small calendars, this cTag can help. You can specify the start month, number of months to generate, dates to highlight, and whether you want a vertical or horizontal orientation. Output is a table using CSS class styles which you specify in your HTML page or included CSS file. If you don't specify styles for Title, Heading, Days, Weekends and Highlighted Dates, then it will use whatever default the browser reverts to. You may certainly use this, if it helps. Please drop me an e-mail if you do (bret@novusweb.com). It should work with v8.x, but haven't tested it yet. If you do find any bugs, please let me know. One note: in order for the HTML to show correctly in the browser, you should set encoding to -EncodeNone for the calendar output.
Parameters
-Day
string, optional
CSS class for normal day table cells (Opt)
-Heading
string, optional
CSS class for Days of Week (Opt)
-Highlight
string, optional
CSS class for table cell for dates provided by "HighlightDates" (Opt)
-HighlightDates
string, optional
String of space delimited dates (YYYY-MM-DD) (Opt)
-Months
integer, optional
Number of Months to show (Opt: Default is '1')
-Orientation
string, optional
Vertical/Horizontal (Opt: Default is Vertical)
-StartMonth
date, optional
YYYY-MM (Opt: Default is current Month)
-Table
string, optional
CSS class for table. Normally set bgcolor to show through cellpadding and for overall width. REMEMBER: if you are using a horizontal orientation, your CSS table width should include the full width of all tables in the row.
-Title
string, optional
CSS class for calendar title (Month and Year area)
-Weekend
string, optional
CSS class for Weekend table cells (Opt: If not provided, will use Day CSS Style)
Sample Usage
nCtag_Calendar:
-StartMonth = '2006-01',
-Months = '3',
-Orientation = 'Vertical',
-HighlightDates = '2006-01-04 2006-01-14 2006-02-12 2006-03-21',
-Table = 'calTable',
-Title = 'calTitle',
-Heading = 'calHeading',
-Day = 'calDay',
-Weekend = 'calWeekend',
-Highlight = 'calHighlight';
Source Code
Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<?LassoScript
// [
/* ----------------------------------------------
nCtag_Calendar
Author: Bret Williams
Created: 2006-01-31
Copyright: 2006 Novusweb. All rights reserved.
This tag may be used as long as the above information is included. An e-mail to bret@novusweb.com would be appreciated, as well.
Contact: Novusweb, 7446 Trigo Lane, Carlsbad, CA 92009, (760) 942-3773, info@novusweb.com
Purpose: This tag produces a calendar of dates, with selected dates highlighted.
NOTE: used CSS class styles for determining output. If no styles are provided for various attributes, then results may be less than optimal.
Usage -
nCtag_Calendar:
-StartMonth = '2006-01',
-Months = '3',
-Orientation = 'Vertical',
-HighlightDates = '2006-01-04 2006-01-14 2006-02-12 2006-03-21',
-Table = 'calTable',
-Title = 'calTitle',
-Heading = 'calHeading',
-Day = 'calDay',
-Weekend = 'calWeekend',
-Highlight = 'calHighlight';
"StartMonth" = YYYY-MM (Opt: Default is current Month)
"Months" = Number of Months to show (Opt: Default is '1')
"Orientation" = Vertical/Horizontal (Opt: Default is Vertical)
"HighlightDates" = String of space delimited dates (YYYY-MM-DD) (Opt)
"Table" = CSS class for table. Normally set bgcolor to show through cellpadding and for overall width. REMEMBER: if you are using a horizontal orientation, your CSS table width should include the full width of all tables in the row.
"Title" = CSS class for calendar title (Month and Year area)
"Heading" = CSS class for Days of Week (Opt)
"Day" = CSS class for normal day table cells (Opt)
"Weekend" = CSS class for Weekend table cells (Opt: If not provided, will use Day CSS Style)
"Highlight = CSS class for table cell for dates provided by "HighlightDates" (Opt)
*/
If: !(Lasso_TagExists:'nCtag_Calendar');
Define_Tag: 'nCtag_Calendar',
-Optional = 'StartMonth',
-Optional = 'Months',
-Optional = 'Orientation',
-Optional = 'HighlightDates',
-Optional = 'Table',
-Optional = 'Title',
-Optional = 'Heading',
-Optional = 'Day',
-Optional = 'Weekend',
-Optional = 'Highlight',
-Priority = 'High';
// Set Local Variables and default values
Local:
'LV_StartMonth' = (Date)->(Format: '%Y-%m'),
'LV_Months' = (Integer: 1),
'LV_Orientation' = 'Vertical',
'LV_HighlightDates' = (Array),
'LV_Table' = (String),
'LV_Title' = (String),
'LV_Heading' = (String),
'LV_Day' = (String),
'LV_Weekend' = (String),
'LV_Highlight' = (String);
// Test for StartMonth Parameter
If: (Local: 'StartMonth')->(Size) > 0;
Local: 'LV_TempDate' = (Date: (Local: 'StartMonth'), -Format = '%Y-%m');
Select: #LV_TempDate;
Case: NULL;
#LV_StartMonth = #LV_StartMonth;
Case;
#LV_StartMonth = #LV_TempDate->(Format: '%Y-%m');
/Select;
/If;
// Test for Months Parameter
If: (Local: 'Months')->(Size) > 0;
Select: (String_IsDigit: (Local: 'Months'));
Case: True;
#LV_Months = (Local: 'Months');
/Select;
/If;
// Test for Orientation Parameter
If: (Local: 'Orientation')->(Size) > 0;
Select: (Local: 'Orientation')->(BeginsWith: 'Hor');
Case: True;
#LV_Orientation = 'Horizontal';
/Select;
/If;
// Test for HighlightDates Parameter
If: (Local: 'HighlightDates')->(Size) > 0;
Local: 'LV_TempHighlightDates' = (Local: 'HighlightDates')->(Split: ' ');
#LV_HighlightDates = #LV_TempHighlightDates;
/If;
// Test for Table Parameter
If: (Local: 'Table')->(Size) > 0;
#LV_Table = (Local: 'Table');
/If;
// Test for Title Parameter
If: (Local: 'Title')->(Size) > 0;
#LV_Title = (Local: 'Title');
/If;
// Test for Heading Parameter
If: (Local: 'Heading')->(Size) > 0;
#LV_Heading = (Local: 'Heading');
/If;
// Test for Day Parameter
If: (Local: 'Day')->(Size) > 0;
#LV_Day = (Local: 'Day');
/If;
// Test for Weekend Parameter
If: (Local: 'Weekend')->(Size) > 0;
#LV_Weekend = (Local: 'Weekend');
Else;
#LV_Weekend = #LV_Day;
/If;
// Test for Highlight Parameter
If: (Local: 'Highlight')->(Size) > 0;
#LV_Highlight = (Local: 'Highlight');
/If;
// Loop for number of Calendar rows
Local: 'LV_CalendarRows' = (Integer),
'LV_CalendarCols' = (Integer);
Select: #LV_Orientation;
Case: 'Horizontal';
#LV_CalendarRows = 1;
#LV_CalendarCols = #LV_Months;
Case: 'Vertical';
#LV_CalendarRows = #LV_Months;
#LV_CalendarCols = 1;
/Select;
Local: 'LV_Build' = (String);
// Build Calendar Cells Array
Local: 'LV_CalendarArray' = (Array);
Local: 'LV_CellArray' = (Array);
Local: 'LV_MonthDate' = (Date: #LV_StartMonth);
Local: 'LV_StartDay' = (Integer);
Local: 'LV_EndDate' = (Integer);
Local: 'LV_LoopMonth' = (Integer);
Local: 'LV_TestDate' = (Date);
Local: 'LV_CalendarRows' = (Integer);
Local: 'LV_MaxRows' = (Integer);
Local: 'LV_RowCountArray' = (Array);
Local: 'LV_DayCount' = (Integer);
Local: 'LV_RowCount' = (Integer);
Loop: #LV_Months;
// Initialize Necessary Vars
#LV_CellArray = (Array);
// Determine the first day of the month
#LV_StartDay = #LV_MonthDate->(DayofWeek);
//Determine last day of the month
#LV_EndDate = (Integer);
#LV_LoopMonth = (#LV_MonthDate->(Month));
#LV_TestDate = (Date: -Year=(#LV_MonthDate->(Year)), -Month=(#LV_MonthDate->(Month)), -Day='28');
Loop: -From=28, -To=31;
If: (#LV_TestDate->(Month) == #LV_LoopMonth);
#LV_EndDate = (Loop_Count);
Else;
Loop_Abort;
/If;
// Add one day
#LV_TestDate = (Date_Add: #LV_TestDate, -Day='1');
/Loop;
// Pad beginning of Array
Loop: (#LV_StartDay-1);
#LV_CellArray->(Insert: ('<td class="' + #LV_Day + '"></td>'));
/Loop;
// Insert Remaining Cells
Loop: #LV_EndDate;
// Set Calendar Date
#LV_TestDate = (Date: -Year=(#LV_MonthDate->(Year)), -Month=(#LV_MonthDate->(Month)), -Day=(Loop_Count));
If: (#LV_HighlightDates->(Find: #LV_TestDate)->(Size)) != 0;
#LV_CellArray->(Insert: ('<td class="' + #LV_Highlight + '">' + (Loop_Count) + '</td>'));
Else: (#LV_TestDate->(DayofWeek) == 1)
|| (#LV_TestDate->(DayofWeek) == 7);
#LV_CellArray->(Insert: ('<td class="' + #LV_Weekend + '">' + (Loop_Count) + '</td>'));
Else;
#LV_CellArray->(Insert: ('<td class="' + #LV_Day + '">' + (Loop_Count) + '</td>'));
/If;
/Loop;
// Pad End of Array
If: #LV_CellArray->(Size)%7 > 0;
Local: 'LV_LoopSize' = (Math_Sub: 7, (#LV_CellArray->(Size)%7));
Loop: #LV_LoopSize;
#LV_CellArray->(Insert: ('<td class="' + #LV_Day + '"></td>'));
/Loop;
/If;
// Determine if month has maximum number of rows
#LV_CalendarRows = #LV_CellArray->(Size)/7;
If: #LV_CellArray->(Size)%7 > 0;
#LV_CalendarRows += 1;
/If;
If: #LV_CalendarRows > #LV_MaxRows;
#LV_MaxRows = #LV_CalendarRows;
/If;
// Add Row Count to Array
#LV_RowCountArray->(Insert: #LV_CalendarRows);
// Add Cell Array to Calendar Array
#LV_CalendarArray->(Insert: #LV_CellArray);
// Add One Month
#LV_MonthDate = (Date_Add: #LV_MonthDate, -Month=1);
/Loop;
#LV_MonthDate = (Date: #LV_StartMonth);
// Build Calendar Shell
#LV_Build += (
'<table class="' + #LV_Table + '" cellspacing="1">\n');
// Build Calendar Core
// IF Vertical Orientation
If: #LV_Orientation == 'Vertical';
// Loop Through Calendars
Loop: #LV_Months;
// Build Title Row
#LV_Build += (
'<tr><td colspan="7" class="' + #LV_Title + '">' + #LV_MonthDate->(Format: '%B %Y') + '</td></tr>\n'
);
// Build Heading Row
#LV_Build += (
'<tr><td class="' + #LV_Heading + '">S</td><td class="' + #LV_Heading + '">M</td><td class="' + #LV_Heading + '">T</td><td class="' + #LV_Heading + '">W</td><td class="' + #LV_Heading + '">T</td><td class="' + #LV_Heading + '">F</td><td class="' + #LV_Heading + '">S</td></tr>\n'
);
// Add Calendar Core
#LV_CellArray = #LV_CalendarArray->(Get: (Loop_Count));
#LV_CalendarRows = #LV_RowCountArray->(Get: (Loop_Count));
#LV_DayCount = 1;
Loop: #LV_CalendarRows;
#LV_Build += (
'<tr>'
);
Loop: -From=#LV_DayCount, -To=(#LV_DayCount + 6);
#LV_Build += #LV_CellArray->(Get: (Loop_Count));
/Loop;
#LV_DayCount += 7;
#LV_Build += (
'</tr>'
);
/Loop;
// Add One Month
#LV_MonthDate = (Date_Add: #LV_MonthDate, -Month=1);
/Loop;
// ELSE IF Horizontal Orientation
Else;
// Build Table Title Row
#LV_Build += (
'<tr>'
);
Loop: #LV_Months;
#LV_Build += (
'<td colspan="7" class="' + #LV_Title + '">' + #LV_MonthDate->(Format: '%B %Y') + '</td>'
);
#LV_MonthDate = (Date_Add: #LV_MonthDate, -Month=1);
/Loop;
#LV_Build += (
'</tr>\n'
);
#LV_MonthDate = (Date: #LV_StartMonth);
// Build Table Heading Row
#LV_Build += (
'<tr>'
);
Loop: #LV_Months;
#LV_Build += (
'<td class="' + #LV_Heading + '">S</td><td class="' + #LV_Heading + '">M</td><td class="' + #LV_Heading + '">T</td><td class="' + #LV_Heading + '">W</td><td class="' + #LV_Heading + '">T</td><td class="' + #LV_Heading + '">F</td><td class="' + #LV_Heading + '">S</td>'
);
/Loop;
#LV_Build += (
'</tr>\n'
);
// Build each row of dates
#LV_DayCount = 1;
Loop: #LV_MaxRows;
#LV_Build += (
'<tr>'
);
#LV_RowCount = (Loop_Count);
Loop: #LV_Months;
#LV_CellArray = #LV_CalendarArray->(Get: (Loop_Count));
If: #LV_RowCountArray->(Get: (Loop_Count)) >= #LV_Rowcount;
Loop: -From=#LV_DayCount, -To=(#LV_DayCount + 6);
#LV_Build += #LV_CellArray->(Get: (Loop_Count));
/Loop;
Else;
#LV_Build += ('<td colspan="7" class="' + #LV_Day + '"></td>');
/If;
/Loop;
#LV_Build += (
'</tr>\n'
);
#LV_DayCount += 7;
/Loop;
/If;
// Build closing part of table
#LV_Build += (
'</table>\n');
// Return final build
Return: #LV_Build;
/Define_Tag;
/If;
// ]
?>
Comments
none