본문 바로가기

프로그래밍

Template 언더바 설치! 디렉토리구조 및 설정하기

반응형
1. 디렉토리 구조 만들기

/website 디렉토리 안에 다운로드 받은 Template_ 파일들을 업로드한다.




2. 서브클래스 만들기

홈페이지 루트 디렉토리에 Template.class.php 라는 파일을 아래와 같이 작성하자.
주의!!! Template_.class.php 와 Template.class.php 을 혼동하지 말것
주의!!! new Template_ 와 new Template 을 혼동하지 말것.

<?php
include dirname(__file__).'/Template_.class.php';
class Template extends Template_
{
   var $compile_check =true;
   var $compile_ext   ='php';
   var $prefilter     ='adjustPath';

    function Template()
    {
        $this->template_dir='_global';
        //$this->compile_dir =$_SERVER['DOCUMENT_ROOT'].'/compile';
        $this->compile_dir ='compile';
        $this->skin='skin1';
    } 
}

?>

자 이제 테스트 파일을 만들어 템플릿이 제대로 작동하는지 확인하다.

<?php
include 'Template.class.php'; // 주의!! 파일명 변경함.
$tpl = new Template; // 주의!! 상속 클래스로 변경함. 
$tpl->define('index', 'index.tpl');
$tpl->assign(array(
    'title'  =>'First Template_',
    'content'=>'Hello World!',
));
$tpl->print_('index');
?>

xtac.net에 자세한 설명이 나와있기는 하지만
조금 헷갈리는 부분과 착각 할 수 있는 부분들이 있어 정리하기로 하였다.


참고: http://xtac.net/reference/?item=config2
반응형