2012-05-10 1 views
1

각 메인 카테고리의 하위 카테고리가 있습니다. 기본 카테고리가 포함 된 드롭 다운 목록입니다. 기본 카테고리를 선택하면 하위 카테고리 드롭 다운 목록에 기본 카테고리의 하위 카테고리가 표시됩니다. tpl_subcategory_default.php에서zencart의 아약스 문제

<select name="main_category" id="main_category" onchange="showSubCategory(this.value)"> 
     <option>--Select--</option> 
</select> 


<script type="text/javascript"> 
     function showSubCategory(str) 
     { 

      if (str.length==0) 
      { 
       document.getElementById("txtHint").innerHTML=""; 
       return; 
      } 
      if (window.XMLHttpRequest) 
      {// code for IE7+, Firefox, Chrome, Opera, Safari 
       xmlhttp=new XMLHttpRequest(); 
      } 
      else 
      {// code for IE6, IE5 
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
      } 
      xmlhttp.onreadystatechange=function() 
      { 
       if (xmlhttp.readyState==4 && xmlhttp.status==200) 
       { 
        alert(xmlhttp.responseText); 
        document.getElementById("subcategory").innerHTML=xmlhttp.responseText; 
       } 
      } 
      xmlhttp.open("GET","index.php?main_page=getsubcategory&cid="+str,true); 
      xmlhttp.send(); 
     } 
    </script> 

<?php 
$cid=$_GET['cid']; 
$sql="select cd.categories_name, cd.categories_id 
          from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd 
          where c.parent_id = '" . (int) $_GET['cid'] . "' 
          and c.categories_id = cd.categories_id 
          and c.categories_status= 1"; 

$r=mysql_query($sql); 

while($row=mysql_fetch_array($r)) 

{ 
echo "<option value=$row[categories_id]>$row[categories_name]</option>"; 
} 

?> 

답변

0

그것은 전체 페이지를 보여주는 것을 포함 ... 이 다음 코드를 사용하고 있지만, 이것은 하위 범주 상자가 머리글과 바닥 글에 전체 페이지를 포함 보여줍니다 헤더가있는 nd footer는 index.php? main_page = foo를 통해 "page"에 접근하고 있기 때문에 일반적인 templating 시스템 출력을 자신의 페이지 별 출력으로 대체하기위한 아키텍처를 추가하지 않았습니다 ... 즉, 출력으로 직접 이동하십시오 모든 페이지에 나타나는 일반적인 것을 먼저 호출하지 않아도됩니다.

/includes/modules/pages/subcategory/header_php.php 파일에서 수행 한 작업을 알지 못했거나 작성한 적이있는 경우에도 정확하게 질문에 답변 할 수 없습니다. 여러분이 tpl_subcategory_default.php에 넣은 코드가 위에서 언급 한 header_php.php 파일에 들어갈 수 있고, 마지막에 die() 문이오고, 찾고있는 것과 같은 것을 할 수 있습니다.

지금까지 한 일에 대해 더 많은 정보를 제공하면 질문에 완전히 대답하는 것이 더 쉬울 것입니다.

0

머리글, 바닥 글 등을 제거하려면 tpl_main_page.php를 재정의 할 수 있습니다. 이 디렉토리/includes/templates/custom template 디렉토리로 이동하십시오. 귀하의 정보에 따라 main_page = getsubcategory 페이지를 만들었습니다. 이 디렉토리 아래에 getsubcategory라는 폴더를 작성하십시오. 그런 다음 include/templates/custom 템플릿/common /에서 tpl_main_page.php를 복사하여/includes/templates/사용자 정의 템플릿/getsubcategory에 붙여 넣으십시오. 그런 다음 tpl_main_page.php 파일에서 아래 변경 사항을 수행하십시오.

if (in_array($current_page_base,explode(",",'getsubcategory'))) { 

    $flag_disable_left = true; 
    $flag_disable_header = true; 
    $flag_disable_footer = true; 

}