You are here

static function Messaging_Template_Engine::get_template_part in Messaging 6.3

Get template part, FALSE if not found

Parameters

$key: Part key, like 'subject', 'header', 'footer', ...

$type: Template type, like 'messaging-template', 'notifications-event'...

1 call to Messaging_Template_Engine::get_template_part()
Messaging_Template::get_part in messaging_template/messaging_template.inc
Get template part, FALSE if not found

File

messaging_template/messaging_template.inc, line 73
Base classes for messaging templates

Class

Messaging_Template_Engine
Static template functions that interact with the module API

Code

static function get_template_part($key, $type, $method, $language) {
  $lang = $language->language;
  self::_debug('Getting template part', array(
    'type' => $type,
    'key' => $key,
    'method' => $method,
    'language' => $lang,
  ));
  self::build_template($type, $method, $language);
  if (!isset(self::$templates[$lang][$type][$method][$key])) {

    // Try method default for the same type
    if ($method_default = self::method_default($method)) {
      $part = self::get_template_part($key, $type, $method_default, $language);
    }
    elseif (!($part = self::get_default($type, $key, $language))) {
      $part = FALSE;
    }
    self::$templates[$lang][$type][$method][$key] = $part;
  }
  elseif (self::$templates[$lang][$type][$method][$key]->options == MESSAGING_TEMPLATE_FALLBACK) {

    // Resolve fallbacks first time the part is retrieved
    if ($fallback = self::type_fallback($type)) {
      self::$templates[$lang][$type][$method][$key] = self::get_template_part($key, $fallback, $method, $language);
    }
    else {
      self::$templates[$lang][$type][$method][$key] = FALSE;
    }
  }
  return self::$templates[$lang][$type][$method][$key];
}