묻고답하기

1. module/board에서 list.html에 skin을 include하는 구조가 조금 비효율적이라고 생각했습니다.
그래서 조금 다르게 해보고싶었습니다.

    <!--@if($module_info->default_style == 'webzine')-->
        <!--#include("./style.webzine.html")-->
    <!--@elseif($module_info->default_style == 'gallery')-->
        <!--#include("./style.gallery.html")-->
    <!--@elseif($module_info->default_style == 'forum')-->
        <!--#include("./style.forum.html")-->
    <!--@elseif($module_info->default_style == 'blog')-->
        <!--#include("./style.blog.html")-->

이렇게 된 구조를


{@ $include_list = {"webzine", "gallery", "forum","blog"}; }
{@ $module_style = $module_info->default_style;}
<!--@if(in_array($module_style,$include_list))-->
<!--#include("./style.$module_style.html")-->
<!--@else-->
<!--#include("./style.list.html")-->
<!--@end-->

이렇게 해보려고 했는데 실패했습니다



2. 혼자 고민 해 보았습니다.

우선 TemplateHandler.class.php에서

        function _compileIncludeToCode($matches) 
함수에서 <--#include("")--> 구문을 관리합니다.

제가 입력한 것 처럼 list.html을 만들어서 관리하면

제대로 작동이 안됩니다.


./files/cache/template_compiled 에서 만들어신 php파일을 확인해보니 해당 부분은 이렇게 바뀌어 있었습니다.


<!-- 목록 출력 -->

<?php @$__Context->include_list = <?php print("webzine", "gallery", "forum","blog");?>;;?>
<?php @$__Context->module_style = $__Context->module_info->default_style;;?>
<?php  if(in_array($__Context->module_style,$__Context->include_list)){ ?>

<?php  }else{ ?>
        <?php
$oTemplate = &TemplateHandler::getInstance();
print $oTemplate->compile('./modules/board/skins/manlist/','style.list.html');
?>

<?php  } ?>


3. 고민 끝에 저는 이러한 결론에 도달하였습니다.

html이 TemplateHandler에 의해서 처리됩니다.

문제있는 부분이 처리가 됩니다.
( <!--#include("./style.$module_style.html")-->)

Context.class.php에서 Context::get("module_style")이 호출 됩니다.

하지만 _get($key)함수에서 $this->context->module_style 값이 아직 입력되지 않은 것 같습니다.

그래서 처리되지 않은게 않을까.... (왜 말끝이 흐려져!!)


4. 고민 이후

그래서 어떻게 하는게 좋을 까 생각을 하다가

TemplateHandler.class.php에서

                for($j=0;$j<count($tmp2_arr);$j++) {
                    $item = trim($tmp2_arr[$j]);
                    if(substr($item,0,1)=='$') $item = Context::get(substr($item,1));
                    $tmp2_arr[$j] = $item;

이부분에서 말입니다.

원래는 변수가 들어오면 해당 값을 받아와서 치환해주었는데

만약 값이 있으면 치환해주고

없으면 

<!-- 목록 출력 -->

<?php @$__Context->include_list = <?php print("webzine", "gallery", "forum","blog");?>;;?>
<?php @$__Context->module_style = $__Context->module_info->default_style;;?>
<?php  if(in_array($__Context->module_style,$__Context->include_list)){ ?>
        <?php
$oTemplate = &TemplateHandler::getInstance();
print $oTemplate->compile('./modules/board/skins/manlist/','style.$__Context->include_list.html');
?>

<?php  }else{ ?>
        <?php
$oTemplate = &TemplateHandler::getInstance();
print $oTemplate->compile('./modules/board/skins/manlist/','style.list.html');
?>

<?php  } ?>

이런식으로 출력하면 제대로 작동하지 않을까요??




그래서 제가 사용법을 잘 모르고 있는 것인지

어떤 부분이 문제인지 잘 모르겠습니다.

저의 미천한 지식을 이용해서 몇 줄 글을 올렸습니다만,

혹시나 관심 있으시면 도움을 주시면 감사하겠습니다 :)
태그 연관 글
  1. [2018/05/26] 묻고답하기 게시판 스킨에서 include사용법에 대해서 ... 부탁드립니다^^ by ecli**** *3
  2. [2017/06/07] 묻고답하기 c언어 소스코드 조언을 부탁드립니다. ㅠ.ㅠ by 하마응가 *3
  3. [2011/04/12] 웹마스터 팁 1.4.5.2로 업데이트 후 짧은 주소가 제대로 되지 않으실때... by 라르게덴 *8
  4. [2009/07/12] 묻고답하기 노프레임 include.... 하는법 ? by 노프레임 *1
  5. [2009/07/08] 묻고답하기 외부페이지 include가 안됩니다. by L4 *3