php 문서를 별도 스타일시트로 뺀 후 view.skin.php에서 불러오고 싶습니다.
본문
background: linear-gradient(-45deg, <?=$css['menu_tooltip'][0]?>, <?=$css['btn_default'][0]?>);
등의 css를 사용해야 해서, css 문서에는 넣을 수 없기에 처음에는 view.skin.php 상단에 <style>로 집어넣었습니다.
그러다 코드가 갈수록 더러워져서 style.skin.php 라는 별도 문서로 분리했습니다. 이후 link rel로 불러올 생각이었습니다. ㅠㅠ
그런데 style.skin.php가 전혀 적용이 되지 않네요.. 혹시 어떤 부분이 잘못되었는지 봐주실 수 있으실까요?
1. view.skin.php
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once($board_skin_path.'/_setting.php');
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
if($write['wr_type'] == 'pair') {
goto_url($list_href.$qstr);
}
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.skin.php" type="text/css">', 0);
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/js/css/swiper.css">', 0);
$body_cnt = sql_fetch("select count(*) as cnt from {$g5['character_body_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}'");
$body_cnt = $body_cnt['cnt'];
$check_body = $write['wr_2'];
if($body_cnt > 0) {
$check_bodys = sql_fetch("select bd_url from {$g5['character_body_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bd_use = '1'");
$check_body = $check_bodys['bd_url'] ? $check_bodys['bd_url'] : $check_body;
}
$color_bak = get_style('color_bak');
$color_line_color = $color_bak['cs_value'];
$color_bak_off = hex2rgba($color_bak['cs_value'], 30);
$color_bak_over = hex2rgba($color_bak['cs_value'], 5);
$default_font = get_style('default_font');
$default_font = hex2rgba($default_font['cs_value'], $default_font['cs_etc_1']);
?>
<script>
var skin_path = "<?=$board['bo_skin']?>";
var skin_url = g5_url + "/skin/board/" + skin_path;
</script>
<div class="loading">
<div>
<div class="lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
<p>Loading...</p>
</div>
</div>
<div class="characterViewer">
<? if($write['wr_2']) { ?>
<div class="ch-body" onclick="$(this).toggleClass('pop');">
<div class="img">
<div><em style="background-image:url(<?=$check_body?>);"></em><img src="<?=$check_body?>" alt="" onerror="this.remove();"/></div>
</div>
</div>
<? } ?>
<div class="extend-icon-links">
<div class="icons-link-box link-box">
<?
$extend_link_file = array();
$tmp = dir(G5_PATH."/plugin/board");
while ($entry = $tmp->read()) {
// php 파일만 include 함
if (preg_match("/(\.php)$/i", $entry))
$extend_file[] = $entry;
}
if(!empty($extend_file) && is_array($extend_file)) {
natsort($extend_file);
foreach($extend_file as $file) {
include_once(G5_PATH."/plugin/board/".$file);
}
}
unset($extend_file);
?>
</div>
</div>
<div class="ch-pannel">
<div class="inner">
<div class="mid">
<!--타이틀-->
<div class="ch-view-title"><? if($write['wr_3']){?><span><?=$write['wr_3']?></span><? } ?></div>
<!--이름-->
<div class="ch-view-name"><?=$write['wr_subject']?></div>
<!--한마디-->
<? if ($write['wr_8_txt']) { ?><div class="ch-view-says">“<?=nl2br($write['wr_8_txt'])?>”</div><? } ?>
<? if($write['wr_content']) { ?>
<div class="info">
<div class="info-sub"><?=$write['wr_content']?></div>
</div>
<? } ?>
<div class='char-body-list'>
<? if($body_cnt > 0 && $write['wr_2'] != '') {
// 전신 리스트 출력 (단, 추가로 등록한 전신이 있을 경우에만)
include_once($board_skin_path."/view_body.skin.php");
}
?>
</div>
<div class="universe" style="<?php if (!empty($write['wr_10'])): ?>
color: <?= substr($write['wr_10'], 0, 7); ?>;
<?php else: ?>
color: <?=$css['menu_tooltip'][2]?>;
<?php endif; ?>; text-align:center;">븿 븿 븿</div>
<? if ($write['wr_4']) { ?><div class="sub-title"><?=$write['wr_4']?></div><? } ?>
<? if ($write['wr_4_txt']) { ?><div class="descript"><?=nl2br($write['wr_4_txt'])?></div><? } ?>
<hr class="line" />
<? if ($write['wr_5']) { ?><div class="sub-title"><?=$write['wr_5']?></div><? } ?>
<? if ($write['wr_5_txt']) { ?><div class="descript"><?=nl2br($write['wr_5_txt'])?></div><? } ?>
<hr class="line" />
<? if ($write['wr_6']) { ?><div class="sub-title"><?=$write['wr_6']?></div><? } ?>
<? if ($write['wr_6_txt']) { ?><div class="descript"><?=nl2br($write['wr_6_txt'])?></div><? } ?>
<hr class="line" />
<? if ($write['wr_7']) { ?><div class="sub-title"><?=$write['wr_7']?></div><? } ?>
<? if ($write['wr_7_txt']) { ?><div class="descript"><?=nl2br($write['wr_7_txt'])?></div><? } ?>
<hr class="padding" />
<hr class="line" />
<div class="control">
<?php if ($update_href) { ?><a href="<?php echo $update_href ?>" class="ui-btn etc" style=""><i class="material-icons">edit</i> 수정</a><?php } ?>
<?php if ($delete_href) { ?><a href="<?php echo $delete_href ?>" class="ui-btn etc" onclick="del(this.href); return false;"><i class="material-icons">delete</i> 삭제</a><?php } ?>
<?php if ($update_href && $write['wr_2'] != '') { ?><a href="javascript:$('.body-add-form').toggle();" class="ui-btn etc"><i class="material-icons">checkroom</i> 전신추가</a><? } ?>
<a href="<?php echo $list_href ?><?=$qstr?>" class="ui-btn etc"><i class="material-icons">list</i> 목록</a>
</div>
<?php if ($update_href && $write['wr_2'] != '') { ?>
<div class="body-add-form theme-box">
<form method="post" id="frm_add_body" enctype="multipart/form-data" autocomplete="off">
<input type="hidden" name="bo_table" value="<?=$bo_table?>" />
<input type="hidden" name="wr_id" value="<?=$wr_id?>" />
<input type="radio" name="add_new_body_type" id="add_new_body_type1" value="url" checked/>
<label for="add_new_body_type1">URL등록</label>
<input type="radio" name="add_new_body_type" id="add_new_body_type2" value="file" />
<label for="add_new_body_type2">FILE등록</label>
<div class="input-box">
<input type="text" name="add_new_body" value="" />
<input type="file" name="add_new_body_file" title="용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" accept="image/*"/>
<button type="button" onclick="fn_body_add_form('frm_add_body');" class="ui-btn">등록</button>
</div>
</form>
</div>
<script>
function fn_body_add_form(frm) {
var form = $("#" + frm)[0];
var formData = new FormData(form);
var url = skin_url;
$('.loading').addClass('mask');
$.ajax({
cache : false,
url : url + "/proc/add_body.php", // 요기에
type : 'POST',
processData: false,
contentType: false,
data : formData,
success: function(data) {
// Toss
var response = data;
$('.char-body-list').empty().append(response);
form.reset();
},
error: function(data, status, err) {
console.log("error!!");
},
complete: function() {
// Complete
$('.loading').removeClass('mask');
}
});
}
</script>
<? } ?>
</div>
</div>
</div>
</div>
2. style.skin.php (style css를 <?php ?>로 감싸도 봤고, 빼 보기도 했습니다. 아래 첨부는 감싼 버전입니다.
<?php
header("Content-Type: text/css; charset=utf-8");
// CSS 코드를 변수에 저장
$dynamicCss = "
.txt-center {display:none;}
.pcmymenu {display:none;}
.mainbox {
border: none;
border-radius: 0;
box-shadow: none;
backdrop-filter: none;
background-color: transparent;
}
.characterViewer .ch-body .img {
filter: drop-shadow(25px 25px 0 " . (!empty($write['wr_10']) ? substr($write['wr_10'], 0, 7) : $css['menu_tooltip'][0]) . ");
-webkit-filter: drop-shadow(25px 25px 0 " . (!empty($write['wr_10']) ? substr($write['wr_10'], 0, 7) : $css['menu_tooltip'][0]) . ");
}
.characterViewer .ch-pannel .info .info-sub {
color: " . $css['menu_tooltip'][2] . ";
background: linear-gradient(-45deg, " . (!empty($write['wr_10']) ? $write['wr_10'] : $css['menu_tooltip'][0] . ", " . $css['btn_default'][0]) . ");
}
.characterViewer .ch-pannel .sub-title,
.characterViewer .ch-pannel > .inner::-webkit-scrollbar-thumb {
color: " . $css['menu_tooltip'][2] . ";
background: linear-gradient(-45deg, " . (!empty($write['wr_10']) ? $write['wr_10'] : $css['menu_tooltip'][0] . ", " . $css['btn_default'][0]) . ");
}
#body .fix-layout {max-width: 100% !important;}
";
// 배경 이미지 조건부 출력
if (!empty($view['wr_9'])) {
$dynamicCss .= "
html, html.single:before {
background-image: url('" . $view['wr_9'] . "'), url('" . $css['background'][0] . "');
background-attachment: fixed;
background-size: cover;
}
";
}
// 루트 변수
$dynamicCss .= "
:root {
--pannel-line: " . $color_line_color . ";
--pannel-bak: " . $color_bak_off . ";
--pannel-bak-over: " . $color_bak_over . ";
}
";
echo $dynamicCss;
?>
!-->!-->!-->
답변 3
style.skin.php 파일은 css확장자가 아니라서 include() 사용해서 불러와야 할 듯.
short_open_tag 가 Off 되어있는 환경이라면
<? ... 태그에 대해 <?php ... 태그로 수정되어야 할것 같습니다.
수정이 안 되어서 댓글로 홈페이지 주소도 남겨둡니다!! ㅠㅠ
1
답변을 작성하시기 전에 로그인 해주세요.