CMS MADE SIMPLE FORGE

CGSimpleSmarty

 

[#9286] Adding "get_template_id" and "get_template_name"

avatar
Created By: Jocelyn Lusseau (kraygoon)
Date Submitted: 2013-05-28 11:46

Assigned To: Robert Campbell (calguy1000)
Resolution: Won't Fix
State: Closed
Summary:
Adding "get_template_id" and "get_template_name"
Detailed Description:
   /////////
  // A function to return the template ID of a given page
  /////////
  static public function get_template_id($alias = '',$assign = '')
  {
    $gCms = cmsms();
    $contentops = $gCms->GetContentOperations();
	 $templateops = $gCms->GetTemplateOperations();
    $smarty = $gCms->GetSmarty();

    if( $alias == '' ) {
      $alias = $smarty->get_template_vars('page_alias');
    }
    $content = $contentops->LoadContentFromAlias($alias);
    if( !is_object($content) ) return '';

    if( $assign != '' ) {
      $smarty->assign($assign,$content->templateId());
      return;
    }
    return $content->templateId();
  }
  
    /////////
  // A function to return the template name of a given page
  /////////
  static public function get_template_name($alias = '',$assign = '')
  {
    $gCms = cmsms();
    $contentops = $gCms->GetContentOperations();
	 $templateops = $gCms->GetTemplateOperations();
    $smarty = $gCms->GetSmarty();

    if( $alias == '' ) {
      $alias = $smarty->get_template_vars('page_alias');
    }
    $content = $contentops->LoadContentFromAlias($alias);
    if( !is_object($content) ) return '';
	 
	 $templateId = $content->templateId() ;
	 if ( empty($templateId) ) return '';

	 $template = $templateops->LoadTemplateByID($content->templateId());
	 
	 if( !is_object($template) ) return '';
	 
    if( $assign != '' ) {
      $smarty->assign($assign,$template->name);
      return;
    }
    return $template->name;
  }

History

Updates

Updated: 2015-05-05 21:50
state: Open => Closed

Updated: 2015-01-15 23:15
resolution_id: => 8