Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

트리 형식 카테고리 리스트 v2

2011-12-24 by 편리

아침에 포스팅한 2011/12/24 – 트리 형식 카테고리 출력에서 몇가지를 수정한 코드이다. + 클릭 시 하위 분류가
열리도록 하는 것과 IE6과 IE7에서 li 사이테 쓸데없는 공간이 들어가는 것을 inline-block 속성을 이용해 수정했다.

<?php
include_once(“./_common.php”);

$sql_common = ” from $g4[shop_category_table] “;
?>

<ul>
    <li class=”cat_list0″>
        <div class=”wrap”>
            <div class=”mark minus” id=”C00″></div>
            <div class=”name” id=”CID_C”>전체분류</div>
        </div>
    </li>
    <li id=”C00_categoryList”>
        <ul>
        <?php // 1차 분류
        $sql_where = ” where char_length(ca_code) = 3 order by ca_code asc “;
        $sql = ” select ca_name, ca_code
                    $sql_common
                    $sql_where “;
        $result = sql_query($sql);

        for($i = 0; $row = sql_fetch_array($result); $i++ ) {
        ?>
            <li class=”cat_list1″>
                <div class=”wrap”>
                    <div class=”mark plus” id=”<?=$row[ca_code]?>”></div>
                    <div class=”name” id=”CID_<?=$row[ca_code]?>”><?=get_text($row[ca_name])?></div>
                </div>
            </li>
            <li id=”<?=$row[ca_code]?>_categoryList” class=”nodisplay”>
                <ul>
                <?php
                $sql_where2 = ” where char_length(ca_code) = 5 and substr(ca_code, 1, 3) = ‘$row[ca_code]’ order by ca_code asc “;
                $sql2 = ” select ca_name, ca_code
                            $sql_common
                            $sql_where2 “;
                $result2 = sql_query($sql2);

                for($j = 0; $row2 = sql_fetch_array($result2); $j++ ) {
                ?>
                    <li class=”cat_list2″>
                        <div class=”wrap”>
                            <div class=”mark plus” id=”<?=$row2[ca_code]?>”></div>
                            <div class=”name” id=”CID_<?=$row2[ca_code]?>”><?=get_text($row2[ca_name])?></div>
                        </div>
                    </li>
                    <li id=”<?=$row2[ca_code]?>_categoryList” class=”nodisplay”>
                        <ul>
                        <?php
                        $sql_where3 = ” where char_length(ca_code) = 7 and substr(ca_code, 1, 5) = ‘$row2[ca_code]’ order by ca_code asc “;
                        $sql3 = ” select ca_name, ca_code
                                    $sql_common
                                    $sql_where3 “;
                        $result3 = sql_query($sql3);

                        for($j = 0; $row3 = sql_fetch_array($result3); $j++ ) {
                        ?>
                            <li class=”cat_list3″>
                                <div class=”wrap”>
                                    <div class=”mark plus” id=”<?=$row3[ca_code]?>”></div>
                                    <div class=”name” id=”CID_<?=$row3[ca_code]?>”><?=get_text($row3[ca_name])?></div>
                                </div>
                            </li>
                        <?php
                        }
                        ?>
                        </ul>
                    </li>
                <?php
                }
                ?>
                </ul>
            </li>
        <?php
        }
        ?>
        </ul>
    </li>
</ul>

<script type=”text/javascript”>
var c_id;
var n_id;
$(function() {
    $(‘.mark’).click(function() {
        c_id = $(this).attr(“id”);

        if($(this).hasClass(“minus”)) {
            $(this).removeClass(“minus”);
            $(this).addClass(“plus”);
            $(‘#’ + c_id + ‘_categoryList’).hide();
        } else {
            $(this).removeClass(“plus”);
            $(this).addClass(“minus”);
            $(‘#’ + c_id + ‘_categoryList’).show();
        }
    });

    $(‘.name’).click(function() {
        n_id = $(this).attr(“id”).replace(“CID_”, “”);
        $(‘.name’).removeClass(“clicked”);
        $(this).addClass(“clicked”);

        loadCategoryForm(n_id);
    });
});
</script>

#categoryList { float: left; width: 215px; height: 383px; margin-top: 60px; padding: 15px 0 0 20px; border: 1px solid #ccc; overflow: auto; }
#categoryList ul {  margin: 0; padding: 0; list-style: none; }
#categoryList li { display: inline-block; }
#categoryList .cat_list0 { width: 196px; height: 18px; padding-top: 6px; background: url(‘../images/item_category_folder.gif’) no-repeat 14px 5px; }
#categoryList .cat_list1 { width: 180px; height: 18px; padding-top: 6px; padding-left: 16px; background: url(‘../images/item_category_folder.gif’) no-repeat 30px 5px; }
#categoryList .cat_list2 { width: 164px; height: 18px; padding-top: 6px; padding-left: 32px; background: url(‘../images/item_category_folder.gif’) no-repeat 46px 5px; }
#categoryList .cat_list3 { width: 148px; height: 18px; padding-top: 6px; padding-left: 48px; background: url(‘../images/item_category_folder.gif’) no-repeat 62px 5px; }
#categoryList .wrap { float: left; }
#categoryList .wrap .mark { float: left; width: 35px; height: 9px; cursor: pointer; }
#categoryList .wrap .minus { background: url(‘../images/item_category_minus.gif’) no-repeat left top; }
#categoryList .wrap .plus { background: url(‘../images/item_category_plus.gif’) no-repeat left top; }
#categoryList .name { float: left; top: 0; color: #333; font-weight: bold; cursor: pointer; }
#categoryList .clicked { background: #ccc; }
#categoryList .nodisplay { display: none; }

사실 이것말고 여기에 붙어서 해당 카테고리를 클릭했을 때 정보를 보여주고 수정하는 페이지와 삭제.. 그리고
하위 분류를 추가하는 기능까지 작업을 했다. 아침부터 지금까지.. 이제는 좀 지친다. 쉬어야 할 시간인가 보다.

Post navigation

Previous Post:

트리 형식 카테고리 출력

Next Post:

갤럭시 넥서스와 디자이어

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • SK 세븐모바일 유심 셀프교체
  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes