예를들어 글쓰기창에서 확장변수1과 2만 쓰기권한을 관리자로 주고 싶을 때
아래와 같이 해결했습니다. 개인적으로는 상당히 유용하네요.

(아래의 소스는 write_form.html 문서에 적용하는 소스입니다.)
view plaincopy to clipboardprint? <!--@foreach($module_info->extra_vars as $key => $val)--> <!--@if($val->name && !($key == 1 && !$grant->manager || $key == 2 && !$grant->manager))--> <!-- 확장변수 --> {$val->name} <!--@if($val->is_required=='Y')-->*<!--@end--> <!-- 확장변수(extra_var)의 type에 따른 form을 출력하기 위해서 특별히 제작된 파일을 include 한다 --> <!--#include("./extra_var_form.html")--> <!--@end--> <!--@end--> <!--@foreach($module_info->extra_vars as $key => $val)--> <!--@if($val->name && !($key == 1 && !$grant->manager || $key == 2 && !$grant->manager))--> <!-- 확장변수 --> {$val->name} <!--@if($val->is_required=='Y')-->*<!--@end--> <!-- 확장변수(extra_var)의 type에 따른 form을 출력하기 위해서 특별히 제작된 파일을 include 한다 --> <!--#include("./extra_var_form.html")--> <!--@end--> <!--@end-->
* 위의 소스는 확장변수1과 2의 사용을 허가했을 때 확장변수1과 2는 관리자만 작성권한을 주는 것이고, 나머지 확장변수들은 쓰기권한제한이 없습니다.

알고 계실지도 모르지만 이번에는 view_document.html에 원하는 확장변수의 번호를 각각 불러올 수 있는 것에 대한 설명입니다.

위의 소스를 응용해서 아래와 같이 해봤습니다.
view plaincopy to clipboardprint? <!--@if($oDocument->isSecret() && !$oDocument->isGranted())--><!--@else--> <!--@if($oDocument->isExtraVarsExists())--> <!--@foreach($module_info->extra_vars as $key => $val)--> <!--@if($val->name == $module_info->extra_vars[1]->name && $oDocument->getExtraValue(1) || $val->name == $module_info->extra_vars[2]->name && $oDocument->getExtraValue(2))--> {$val->name} : <!-- 확장변수(extra_var)의 type에 따른 값을 출력하기 위해서 특별히 제작된 파일을 include 한다 --><!--#include("./extra_var_value.html")--> <!--@end--> <!--@end--> <!--@end--> <!--@end--> <!--@if($oDocument->isSecret() && !$oDocument->isGranted())--><!--@else--> <!--@if($oDocument->isExtraVarsExists())--> <!--@foreach($module_info->extra_vars as $key => $val)--> <!--@if($val->name == $module_info->extra_vars[1]->name && $oDocument->getExtraValue(1) || $val->name == $module_info->extra_vars[2]->name && $oDocument->getExtraValue(2))--> {$val->name} : <!-- 확장변수(extra_var)의 type에 따른 값을 출력하기 위해서 특별히 제작된 파일을 include 한다 --><!--#include("./extra_var_value.html")--> <!--@end--> <!--@end--> <!--@end--> <!--@end-->
* 위의 소스는 관리자가 설정창에서 지정한 변수의 성질(?)대로 내용화면에 불러오고 싶어서 일부러 foreach를 이용하여 출력한 것입니다.
그런 이유가 아니었다면 나쁜머리를 굴릴 필요도 없었다는.. orz...

그리고 제일 첫줄에 있는 함수는 비밀글일 때 내용화면에서 비밀글 읽기 권한이 있는 사람만 작성된 확장변수를 볼 수 있게 하기 위한 것이니 삭제하셔도 됩니다.

* 삭제하시려면 첫줄의 <!--@if($oDocument->isSecret() && !$oDocument->isGranted())--><!--@else--> 이것과 끝줄의 <!--@end--> 이것을 삭제하셔야 합니다.

확장변수의 이름이 있어도 해당 확장변수에 내용이 없으면 내용화면에 항목을 출력하지 않기위해서
$val->name == $module_info->extra_vars[1]->name && $oDocument->getExtraValue(1) 이렇게 했는데요..

더 간단한 방법이 없을까요?

저는 이렇게 해서 확장변수 1~4, 11~14는 내용 상단에 / 5,15는 내용 오른쪽 또는 왼쪽에 / 6~10, 16~18, 20 은 내용아래에 / 19는 코멘트창 바로 위에 출력하여 사용하고 있습니다.
by Anna 안나 2008. 4. 5. 23:26