● 팝업의 경우 ' 오늘 하루 안보기' 버튼을 클릭할 때, 쿠키를 사용해 해당 기능을 구연한다.
●php는 $_COOKIE 를 사용한다.
●view
<?php
if($popup)
{
foreach($popup as $popup_row)
{
$popup_file_t = get_image_url($popup_row['popup_file1'], 'Y');
//$_COOKIE['delivery_modal_'.$popup_row["idx"]];
//쿠키(이름)가 있고 그 값이 ok면 통과시킨다.
if($_COOKIE['delivery_modal_'.$popup_row["idx"]]=="ok") continue;
?>
<div class="modal popup " id="delivery_modal_<?php echo $popup_row["idx"];?>" name="popup_modal" data-backdrop="static" tabindex="-1" aria-labelledby="delivery_modalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered ">
<div class="modal-content">
<div class="modal-body text-center">
<figure class="rect4">
<img src="<?php echo $popup_file_t?>" >
</figure>
</div>
<div class="modal_footer">
<div class="btn_wr">
<button type="button" class="btn btn-secondary btn-lg btn-block col-9" onclick="close_today('today','<?php echo $popup_row["idx"]?>');">오늘하루그만보기</button>
<button type="button" class="btn fs_16 btn-lg col-3" onclick="close_today('now','<?php echo $popup_row["idx"]?>');">닫기</button>
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
● script
<script>
$( document ).ready(function() {
//화면 들어올때 팝업모달을 열어준다
$(".modal").modal();
});
//닫기 버튼 클릭시
function close_today(time,modal_idx)
{
//오늘 하루 보지않기 클릭시
if(time == "today")
{
//쿠키를 생성한다
setCookie("delivery_modal_"+modal_idx, "ok", 1);
}
//해당 모달을 숨긴다
$('#delivery_modal_'+modal_idx).modal('hide');
}
</script>
●js
<script>
$( document ).ready(function() {
//화면 들어올때 팝업모달을 열어준다
$(".modal").modal();
});
//닫기 버튼 클릭시
function close_today(time,modal_idx)
{
//오늘 하루 보지않기 클릭시
if(time == "today")
{
//쿠키를 생성한다
setCookie("delivery_modal_"+modal_idx, "ok", 1);
}
//해당 모달을 숨긴다
$('#delivery_modal_'+modal_idx).modal('hide');
}
</script>
'STUDY > PHP' 카테고리의 다른 글
썸머노트 - 반응형 에디터, 썸머노트 파일 업로드 (1) | 2023.01.06 |
---|---|
<fome><input><select><GET><POST> (0) | 2021.05.06 |
php 자료형 함수 (0) | 2021.05.04 |
php기본 출력함수 (0) | 2021.05.03 |
PHP란? (0) | 2021.05.01 |