CMS솔루션마켓, 이온디 - 워드프레스, 라이믹스, 카페24, 그누보드, 엑셀

Contents Management System

xe php include 변수 출력

2022년 09월 30일

[XE(라이믹스) 레이아웃제작팁] 외부에서 include된 php문의 변수를 레이아웃 스킨에서 사용하는 방법

레이아웃 스킨 예제

include.php

<?php
$a = "사과";
$c = "당근";
?>

layout.html

<include target="include.php" />
값0:<?= $g_conf_site_cd ?>
값1:<?=$g_conf_site_cd?>
값2:{$g_conf_site_cd}
값3:{$Context->g_conf_site_cd}
값4:{$__Context->g_conf_site_cd}
값5:<?php echo $g_conf_site_cd ?>
값6:<?php echo($g_conf_site_cd);?>

위와 같이 사용하려고 하면 php문의 변수값을 불러오지 못합니다.

이럴 땐 아래와 같이 사용해야 합니다.

include.php

<?php
Context::set(apple, '사과');
Context::set(carrot, '당근');
?>

layout.html

<include target="include.php" />
{$apple}
{$carrot}

그런데 이렇게 할 경우 해당 변수를 다른 php문에서 다시 활용하려고 할 경우는 안됩니다..

그래서 저 경우에는 

layout.html

<?php
include $_SERVER['DOCUMENT_ROOT'] . "/layouts/el_miso/assets/kcp/cfg/cert_conf.php";
?>

이렇게 <include target="..."> 대신 php문으로 include를 해주시면 됩니다.

 
댓글은 로그인 사용자만 작성 가능합니다. 로그인하기