I would like to see generally used day abbreviations (like "Mon" or "Tue"). Perhaps being able to set each day's abbreviation would be the most flexible for people with varying calendar sizes, so for example someone could just use "M" or "T" if they're making a very small calendar block. Opinions?

Comments

skilip’s picture

Hi jmstacey,

It's currently not possible to change the weekday titles using hook_calendar, but I think it will be relatively easy to add 'alter weekdays' functionality in the hook function. I'm planning to add a configuration option which allowes you to set the first day of the week. When I do I'll take your request with it and release a new version.

For now, you can just change the weekdays in the calendar_block.module. I'll let you know when I'm done.

skilip’s picture

Status: Active » Fixed

Hey,

The new version is released which enables you to change the text used in the weekdays. Please refer to the help section of the new release for an usage example.

Cheers!

dubitable’s picture

Status: Fixed » Active

While I appreciate that you've provided a way to customize these abbreviations, it's still not clear to me how this is possible outside of writing a new module that uses the calendar block. Is there any way to change these abbreviations inside of the theme, say in template.php? Am I just not understanding how this works?

Thanks!

Best,
Dave

jmstacey’s picture

Thanks for the update skilip. The example in the documentation might want to be changed to something similar to the example below. If $calendar->weekdays = array(... is used, the order that was chosen through the interface will be overridden. This is not a problem but might catch people unawares. Changing the values in place would be more generic. Just a tip since I didn't catch what I was doing until I noticed that the order was no longer the one I had chosen in the interface.

@Dave, In the current version you have to use a separate module. Here is an example of how I do it:

/**
* Implementation of hook_calendar_block().
*/
function calendar_block_events_calendar_block(&$calendar, &$date, $op) {
	
	switch ($op) {
				
		case 'load':
			$calendar->weekdays['su'] = "Sun";
			$calendar->weekdays['mo'] = "Mon";
			$calendar->weekdays['tu'] = "Tue";
			$calendar->weekdays['we'] = "Wed";
			$calendar->weekdays['th'] = "Thu";
			$calendar->weekdays['fr'] = "Fri";
			$calendar->weekdays['sa'] = "Sat";
			
			break;
	}
}
skilip’s picture

@Dave,

As jmstacey mentioned, the calendar block is only written to be used by other modules. You already need an other module to create links on the calendar, so IMHO there's no point to create a separate configuration setting for day abbreviations.

In the future I will extend the module with a checkbox in node forms, which let users choose whether or not to display a link to the node in he calendar block. If that's done, the configuration setting for day abbreviations may be more useful.

All the best!

skilip’s picture

@ jmstacey,

Thanks for your suggestion! I think it's better to use a separate default weekdays array to be used for the order, instead of using the weekdays array returned by hook_calendar_block. This ensures that other modules cannot mess up the order of weekdays. I'll take this into a next version.

Thanks again!

skilip’s picture