Jump to content

Creating a "calendar class"


Wuhtzu

Recommended Posts

Hey

 

I'm in the process of writing a calendar class which basically constructs a table and populate it days/dates. It offers a lot of ways to customize the table:

 

  - Choose start and end day of the week

  - Give the days local names

  - Display week numbers

  - Choose calendar title

  - ect.

 

The maybe most essential feature must be the ability to set the id and class attribute for key elements in the table. These key elements are:

 

  - the <table> element it self

  - the <th> element which hold the calendar title (September 2007)

  - <td> elements which hold day names (Mon, Tue, Wed, ect.)

  - <td> elements which hold weekdays (maybe...)

  - <td> elements which hold weekend days (1, 2, 8, 9, 15, 16, 22, 23, 29, 30 for this month)

  - <td> elements which hold week numbers (35, 36, 37, 38, 39 for this month)

  - <td> elements which hold blanks

 

I originally planned to let the user of the script (mostly myself I think) set these classes by populating an array with class names like this:

 

<?php
//Name of the html class attribute
var $classes = array('descriptive_identifying_name' => 'class_name_choosen_by_user',
                     'main_table' => 'calendar_main_table',
                     'title_th' => 'calendar_title_th',
                     'day_name_td' => 'calendar_day_name_td',
                     'weekday_td' => 'calendar_weekday_td',
                     'weekend_td' => 'calendar_weekend_td',
                     );

?>

 

Then I would simply output the class name in its respective element, it works perfectly, but it collides with another feature which I would like to add. I would like to give the user of the script (I still think myself for most parts) the ability to specify additional attributes for each element. The most obvious need for this feature is the table element which could benefit from the specification of border, cellpadding, cellspacing, align, ect.

 

Again this would be done by specifying different arrays containing all the attributes and their values:

 

 

<?php
//Optional attributes for the <table> tag
var $table_attributes = array('border' => '1',
                              'cellpadding' => '5',
                              'cellspacing' => '5',
                              'align' => 'left'
                              );

//Optional attributes for the <another> tag
var $another_attributes = array('a' => '1',
                                'b' => '2',
                                'c' => '3'
                              );
?>

 

This troubles me because if I create a way for users of the script to specify additional attributes then it would render the "specify class" feature somewhat useless. Fine, then I'll let the class attribute be specified just any other attribute. But that would be somewhat overkill since there is no other attributes to specify for, say, the <tr> element...

 

So what do you guys think would be the best solution (to my luxury problem)? Should I have a both "specify class" and "specify additional attributes" feature or should I remove one of them?

 

 

 

Thanks for reading and hopefully your thoughts on the subject

Wuhtzu

 

 

Link to comment
Share on other sites

Short version:

 

I'm writing a calendar class which constructs a HTML table and populates it with relevant data, day names, days, week number ect. It's possible to customize the table in different ways and on of the most important is the ability to specify the class attribute for key elements like <td>'s holding weekend days ect.

 

I have created a feature which allows users of the script to add the class names by populating an array with the names:

 

<?php
//Name of the html class attribute
var $classes = array('descriptive_identifying_name' => 'class_name_choosen_by_user',
                     'main_table' => 'calendar_main_table',
                     'title_th' => 'calendar_title_th'
                     );
?>

 

Now I would like to give the user the ability to specify additional attributes for for example the table element (cellpadding, cellspacing, ect.) but that would "dublicate" the function of the "add class name" feature...

 

How should I go about that? Should there be both a "specify class name" and "specify additional attributes" feature or ?

 

 

The calendar

Here are the calendar table, just so we are on the same page (being worked on so it might change)

http://wuhtzu.dk/random/calendar.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.