Wuhtzu Posted September 15, 2007 Share Posted September 15, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/69468-creating-a-calendar-class/ Share on other sites More sharing options...
Wuhtzu Posted September 15, 2007 Author Share Posted September 15, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/69468-creating-a-calendar-class/#findComment-349066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.