I'm displaying a non-interactive "bookings calendar" page using Calendar and Views, and need to control several elements of the display. For each item, I've figured out a way to hack it, but my solutions are inelegant, and I have to believe there's a better way even though many hours of mucking around under the hood did not lead me to it.
1. Force view to "Year" (Calendar defaults to "Month" view)
I did this in template.php, implementing theme_calendar_display() and checking the value of param $view->name against the hard-coded name of my view and setting $view->calendar_type = 'year'.
function phptemplate_calendar_display(&$view, ...){
if ($view->name == {hard-coded value}) $view->calendar_type = 'year'; //**UGLY!**
...
2. Disable "Year Month Week Day" links / views
I did this also in template.php:
function phptemplate_calendar_show_nav($view, ...){
if ($view->name == {hard-coded value}) {/* don't show nav links */}
...
3. Force page title to view name instead of calendar module's default ("Year", "Month", etc.)
I did this in page.tpl.php, using a custom function, declared in template.php:
/**
* Determine if custom page title should be displayed
* @param $title
* Current/default page title
* @return Correct title
*/
function _customTitle($title){
//Handle calendar with suppressed title (calendar views set title to indicate the view arguments (year/month/etc.); there are cases where we don't want that
$hideCalTitle = false;
if(isset($GLOBALS['current_view'])){
if ($GLOBALS['current_view']->name == 'bookings') return 'Bookings';
}
//Hide Home Page title
if ($title == 'Home Page'){
return '';
//Show default
}else{
return $title;
}
/*
*/
}
4. Disable "day links" in calendar year view (I don't want visitors to be able to click through to more detailed views)
I did this in template.php:
function phptemplate_calendar_date_box(){
if($GLOBALS['current_view']->name = {hard-coded-value}){/* Don't add links */}
...
}
Each of these seems to me something that "should" be configurable (in an ideal world, of course), and so I just wonder if I'm missing something, or if these are use-cases that the module just doesn't handle.
Cheers and thanks!