CampURI::getTemplate PHP Method

getTemplate() public method

public getTemplate ( $p_templateIdOrName = null )
    public function getTemplate($p_templateIdOrName = null)
    {
        if (!is_null($this->m_template)) {
            return $this->m_template->name;
        }
        if (!empty($p_templateIdOrName)) {
            $tplObj = new MetaTemplate($p_templateIdOrName);
            if (!$tplObj->defined()) {
                $template = CampSystem::GetInvalidURLTemplate($this->publication->identifier, $this->issue->number, $this->language->number, !$this->m_preview);
                $template = substr($template, strlen($this->getThemePath()));
            } else {
                $template = $tplObj->name;
            }
        } elseif (is_null($this->m_errorCode)) {
            $template = CampSystem::GetTemplate($this->language->number, $this->publication->identifier, $this->issue->number, $this->section->number, $this->article->number);
            if (is_null($template)) {
                $template = CampSystem::GetInvalidURLTemplate($this->publication->identifier, $this->issue->number, $this->language->number, !$this->m_preview);
            }
            $template = substr($template, strlen($this->getThemePath()));
        } else {
            return null;
        }
        $filePath = CS_PATH_TEMPLATES . DIR_SEP . $this->getThemePath() . $template;
        if (!file_exists($filePath)) {
            return null;
        }
        return $template;
    }

Usage Example

 /**
  * Get template
  *
  * @return MetaTemplate
  */
 private function _getTemplate()
 {
     $templateId = CampRequest::GetVar(CampRequest::TEMPLATE_ID);
     $themePath = $this->m_issue->defined() ? $this->m_issue->theme_path : $this->m_publication->theme_path;
     $template = new MetaTemplate(parent::getTemplate($templateId), $themePath);
     if (!$template->defined()) {
         throw new InvalidArgumentException("Invalid template in URL or no default template specified.", self::INVALID_TEMPLATE);
     }
     CampTemplate::singleton()->config_dir = APPLICATION_PATH . '/../themes/' . $themePath . '_conf';
     return $template;
 }
All Usage Examples Of CampURI::getTemplate