i wanna change mini calendar month theme with my custom theme
It works only /sites/all/themes/mytheme/templates/view/calendar-mini.tpl.php
but i wanna change theme by views information because i have a lots views year calendar
like/sites/all/themes/mytheme/templates/view/calendar-mini--view_name.tpl.php it doesnt work it include /sites/all/modules/contrib/calendar/theme/calendar-mini.tpl.php

Comments

lazzyvn’s picture

I think in function
function template_preprocess_calendar_year(&$vars)
it call theme calendar_mini
$months[$month] = theme('calendar_mini', $variables);
that's why i can't make custom theme for mini calendar

I don't know how to make patch
i hope next version will add this code to theme.inc
i try replace 'calendar_mini' by $theme_hook_suggestion

function template_preprocess_calendar_year(&$vars) {

  // Construct a calendar for each month, adjusting the $view passed
  // to the theme so it will produce the right results.
  $view = clone($vars['view']);
  $year = date_format($view->date_info->min_date, 'Y');
  $view->date_info->style_with_weekno = FALSE;
  $rows = $vars['rows'];
  $months = array();
    $hooks = theme_get_registry();
    $theme_hook_suggestion = 'calendar_mini';
    $display = $view->display[$vars['view']->current_display];
    $themes = views_theme_functions($theme_hook_suggestion, $view, $display);
    foreach ($hooks as $hook) {
        if (!empty($hook['base hook']) and $hook['base hook'] == $theme_hook_suggestion) {
            $_hook_suggestion = str_replace('-', '_', $hook['template']);
            if (in_array($_hook_suggestion, $themes)) {
                $theme_hook_suggestion = $_hook_suggestion;
            }
        }
    }
  foreach ($rows as $month => $month_rows) {
    $view->date_info->month = $month;
    $view->date_info->granularity = 'month';
    $view->date_info->mini = TRUE;
    $view->date_info->hide_nav = TRUE;
    $view->date_info->show_title = TRUE;
    $view->date_info->url = date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month));
    $view->date_info->min_date = new DateObject($view->date_info->year . '-' . date_pad($month) . '-01 00:00:00', date_default_timezone());
    $view->date_info->max_date = clone($view->date_info->min_date);
    date_modify($view->date_info->max_date, '+1 month');
    date_modify($view->date_info->max_date, '-1 second');
    $variables = array(
      'view' => $view,
      'options' => $vars['options'],
      'rows' => $month_rows,
    );
    $months[$month] = theme($theme_hook_suggestion, $variables);
  }
  $view->date_info->mini = FALSE;

  $vars['months'] = $months;
  $vars['view']->date_info->hide_nav = FALSE;
  $vars['view']->date_info->granularity = 'year';
  $vars['mini'] = FALSE;

}

You can make hook YOURTHEME_preprocess_calendar_year(&$vars). but it takes more time for me 0.2s vs 0.9s

Neslee Canil Pinto’s picture

Status: Active » Closed (outdated)