• 30-03-2016, 23:49:45
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    web sitesi ilk açıldığında sol kolonda:
    Kategoriler Listesi var, Örnek Liste detayı aşağıda benim olmasını istemediğim, Kategoriler Altında Oki, Hp, Samsung, Xerox, Panaasonic YAZICI PARÇA Alt kategorileri var bu alt kategoriler içinde bulunan Yazıcı modelleri hepsi sıralanıyor,


    KATEGORILER ( Ana Kategori ismi )

    Oki YAZICI PARÇA ( 1. Marka Yazıcı Kategori )

    280 Model ( Yazıcı Modeli )
    395 Model ( Yazıcı Modeli )
    1120 Model ( Yazıcı Modeli )
    3320/3321 Model ( Yazıcı Modeli )

    HP YAZICI PARÇA ( 2. Marka Yazıcı Kategori )

    Laserjet 1000 ( Yazıcı Modeli )
    Laserjet 1010 ( Yazıcı Modeli )
    Laserjet 3050 ( Yazıcı Modeli )
    Laserjet 4250

    SAMSUNG YAZICI PARÇA ( 3. Marka Yazıcı Kategori )

    CLP-300 Model ( Yazıcı Modeli )
    CLP-310 Model
    ML-1610 Model ( Yazıcı Modeli )
    SCX-4521F Model ( Yazıcı Modeli )

    Xerox YAZICI PARÇA ( 4. Marka Yazıcı Kategori )

    PE-16 Model
    PE-220 Model ( Yazıcı Modeli )
    3100 MFP Model
    3116 Phaser Model ( Yazıcı Modeli )

    PANASONIC YAZICI PARÇA ( 5. Marka Yazıcı Kategori )

    KXP-1150 Model ( Yazıcı Modeli )
    KXP-3196 Model ( Yazıcı Modeli )
    KXP-3696 Model

    EPSON YAZICI PARÇA ( 6. Marka Yazıcı Kategori )

    C1100 Model ( Yazıcı Modeli )
    CX11 Model
    LX-300 Model ( Yazıcı Modeli )
    LX-300+ Model
    LX-300+II Model ( Yazıcı Modeli )

    CANON YAZICI PARÇA ( 7. Marka Yazıcı Kategori )

    IR2800 Model ( Yazıcı Modeli )
    IR3300 Model
    LBP6000 Model ( Yazıcı Modeli )
    MF4270 Model
    MF-4690PL Model ( Yazıcı Modeli )

    LEXMARK YAZICI PARÇA ( 8. Marka Yazıcı Kategori )

    T430 Model ( Yazıcı Modeli )
    T520 Model ( Yazıcı Modeli )
    X215 Model ( Yazıcı Modeli )
    E350D Model

    BERK-JET Kartus ( 9. Marka Yazıcı Kategori )

    Canon Muadil ( Yazıcı Modeli )
    Epson Muadil
    Muhtelif Urunler ( Yazıcı Modeli )
    JetDirect Cart Ethernet ( Yazıcı Modeli )

    --------------------------------- ama ben sadece Kategoriler Altında Oki, Hp, Samsung, Xerox, Panaasonic YAZICI PARÇA Alt kategoriler sıralansın yazıcı modelleri görünmeden ) sıralanmasını istiyorum ---

    KATEGORILER ( Ana Kategori ismi )

    Oki YAZICI PARÇA
    HP YAZICI PARÇA
    SAMSUNG YAZICI PARÇA
    Xerox YAZICI PARÇA
    PANASONIC YAZICI PARÇA
    EPSON YAZICI PARÇA
    CANON YAZICI PARÇA
    LEXMARK YAZICI PARÇA
    BERK-JET Kartus


    --------------------------KAtegori ile ilgili Kod aşağıda -------- ben bu kod yerine ( CategoryTree ) ne kullanabilirim ------------

    class Category
    {

    var $Categories = array();
    var $CurentCategory;
    var $CurentCategoryTree = array();
    var $CurentCategoryParents;
    var $CurentCategoryLevel;
    var $CurentCategoryDetails;
    var $CategoriesSpesc;
    var $Specs;
    var $removeFilter;
    var $FilterName;


    //This get's a;; categories from DB and creates the $this->Categories Array
    function getCategories()
    {
    global $DB;
    $sql = "SELECT * FROM `categories` ORDER BY `parentid`,`order`";
    $DB->Query($sql,'getCategories');
    $NumberOfCategories = 0;
    while ($row = $DB->Fetch('getCategories')) {
    $this->Categories[$row['categoryid']] = array('parentid' => $row['parentid'],'url' => $row['categoryurl'], 'name'=>$row['categoryname']);
    $NumberOfCategories++;
    }
    $this->Categories;
    }
    function setCategory($CurentCategory)
    {
    $this->getCategories();
    $this->CurentCategory = $CurentCategory;
    if (isset($this->Categories[$this->CurentCategory]))$this->CurentCategoryDetails = $this->Categories[$this->CurentCategory];
    $this->CurentCategoryDetails['childs'] = $this->categoryHasChilds($CurentCategory);
    $this->CurentCategoryDetails['level'] = $this->getLevel($CurentCategory);
    $this->CurentCategoryParents = $this->getParents($this->CurentCategory);
    $this->CurentCategoryLevel = $this->getLevel($this->CurentCategory);
    $this->getTree($this->CurentCategory,$this->CurentCategoryLevel);
    }

    // Get the parent ID
    function getParent($catID)
    {
    if (isset($this->Categories[$catID]['parentid'])) return $this->Categories[$catID]['parentid'];
    else return null;
    }
    // Get All parent of a category as [Level][PerentID]
    function getParents($catID)
    {
    $level = $this->getLevel($catID) - 1;
    $lastParentID = $catID;
    $return = array();
    while ( $level >= 0)
    {

    $lastParentID = $this->getParent($lastParentID);
    $return[$lastParentID] = $level;
    $level--;
    }
    asort($return);
    return $return;
    }

    function getChilds($ParentID)
    {
    $return = null;
    foreach ($this->Categories as $ID => $Value)
    {
    if ($this->getParent($ID) == $ParentID) $return[$ID] = $Value;
    }
    return $return;
    }

    function categoryHasChilds($ICatID)
    {
    if (sizeof($this->getChilds($ICatID)) > 0) return 'yes';
    else return 'no';
    }

    // Get's all categories in the respective level [CategoryID][Level]
    function getCategoriesOfLevel($CurentLevel)
    {
    $CategoriesOfID_Level = $this->getCategoriesOfID_Level();
    if (is_array($CategoriesOfID_Level))foreach ($CategoriesOfID_Level as $ID => $Level) {
    if ($CurentLevel == $Level) $return[$ID] = $Level;
    }
    $this->getCategoriesOfLevel = $return;
    return $return;
    }
    //Get's the level of a category Level
    function getLevel($catID)
    {
    $level = 100;
    $parentID = $this->getParent($catID);
    while ($parentID > 0) {
    $level--;
    $parentID = $this->getParent($parentID);
    }
    $level = 100 - $level;

    return $level;

    }
    //This array cointains the [ID] [Level]
    function getCategoriesOfID_Level()
    {
    foreach ($this->Categories as $ID => $Value)
    {
    $return[$ID] = $this->getLevel($ID);
    }
    return $return;
    }

    // Returns a tree for the current Category [ID][Level]
    function getCsategoryTree($CategoryID)
    {
    // Parents Categories
    $CategoryParents = $this->getParents($CategoryID);
    foreach ($CategoryParents as $CatID => $Level)
    {
    $return[$CatID] = $Level;
    }
    // Same Level Categories
    $CategorySameLevel = $this->getChilds($this->getParent($CategoryID));
    foreach ($CategorySameLevel as $CatID => $Level)
    {
    $return[$CatID] = $this->getLevel($CatID);
    }
    return $return;
    }

    //get subcategories / works only with a total of 3 levels (root, 1 , 2 and 3)
    function getChildsTree($CurentCategory){
    //$this->CurentSubCategoriesTree[$CatID] = array('level' => $CatLevel,'url' => $this->Categories[$CatID]['url'], 'name' => $this->Categories[$CatID]['name'], 'childs' => $this->categoryHasChilds($CatID), 'root' => 'no', 'index' => $this->Index[$InterMediateLevel],'parent' => $ParentID);
    if ($this->categoryHasChilds($CurentCategory)) {
    $Childs = $this->getChilds($CurentCategory);
    if (is_array($Childs)) {
    foreach ($Childs as $CatID=>$CatRow) {
    $this->CurentSubCategoriesTree[$CatID] = array('url' => $CatRow['url'],'name' => $CatRow['name'],'childs' => $this->categoryHasChilds($CatID),'parent'=>$this->getParent($CatID));
    $this->getChildsTree($CatID);
    }
    }

    }

    }

    // Returns a tree [ID][Level]
    function getTree($CurentCategory,$CurentLevel,$ParentID = 0,$InterMediateLevel = 0)
    {
    $this->Index[$InterMediateLevel] = 1;
    //Get categories that in the $InterMediateLevel level. First is the root level
    $CategoriesID_Level = $this->getCategoriesOfLevel($InterMediateLevel);
    // In the root we have categories but because the $CurrentLevel is incremented we may not have categories on the respective level
    if (is_array($CategoriesID_Level)) {
    foreach ($CategoriesID_Level as $CatID => $CatLevel){
    // Select only Categories related, not all categories of the $InterMediateLevel level. Ex: Family + Uncles not cousins
    // extracted $CurentLevel+1 >= $InterMediateLevel &&
    if( $this->getParent($CatID) == $ParentID ){
    // If the category contains the root, or the category itself, show it
    if ($CatID == $CurentCategory || key_exists($CatID,$this->getParents($CurentCategory)) ) {
    $this->CurentCategoryTree[$CatID] = array('level' => $CatLevel,'url' => $this->Categories[$CatID]['url'], 'name' => $this->Categories[$CatID]['name'], 'childs' => $this->categoryHasChilds($CatID), 'root' => 'yes', 'index' => $this->Index[$InterMediateLevel],'parent' => $ParentID);

    }
    else{
    $this->CurentCategoryTree[$CatID] = array('level' => $CatLevel,'url' => $this->Categories[$CatID]['url'], 'name' => $this->Categories[$CatID]['name'], 'childs' => $this->categoryHasChilds($CatID), 'root' => 'no', 'index' => $this->Index[$InterMediateLevel],'parent' => $ParentID);
    }
    // Go to the next level but not showing cousins
    if (key_exists($CatID,$this->getParents($CurentCategory)) || $CatID == $CurentCategory )$this->getTree($CurentCategory,$CurentLevel,$CatID,$Inte rMediateLevel+1);
    $this->Index[$InterMediateLevel]++;
    }
    }
    }
    }
    // Returns a tree [ID][Level]
    function makeEntireTree($CurentCategory = 0,$CurentLevel = 0,$ParentID = 0,$InterMediateLevel = 0)
    {
    $this->Index[$InterMediateLevel] = 1;
    //Get categories that in the $InterMediateLevel level. First is the root level
    $CategoriesID_Level = $this->getCategoriesOfLevel($InterMediateLevel);
    // In the root we have categories but because the $CurrentLevel is incremented we may not have categories on the respective level
    if (is_array($CategoriesID_Level)) {
    foreach ($CategoriesID_Level as $CatID => $CatLevel){
    // Select only Categories related, not all categories of the $InterMediateLevel level. Ex: Family + Uncles not cousins
    // extracted $CurentLevel+1 >= $InterMediateLevel &&
    if( $this->getParent($CatID) == $ParentID ){

    $this->AllCategories[$CatID] = array('level' => $CatLevel,'url' => $this->Categories[$CatID]['url'], 'name' => $this->Categories[$CatID]['name'], 'childs' => $this->categoryHasChilds($CatID), 'root' => 'no', 'index' => $this->Index[$InterMediateLevel],'parent' => $ParentID);
    // Go to the next level but not showing cousins
    $this->makeEntireTree($CurentCategory,$CurentLevel,$CatI D,$InterMediateLevel+1);
    $this->Index[$InterMediateLevel]++;
    }
    }
    }
    }
    // Returns a tree [ID][Level]
    function makeHomeTree($CurentCategory = 0,$CurentLevel = 0,$ParentID = 0,$InterMediateLevel = 0,$maxdepth = 1)
    {
    $this->Index[$InterMediateLevel] = 1;
    //Get categories that in the $InterMediateLevel level. First is the root level
    $CategoriesID_Level = $this->getCategoriesOfLevel($InterMediateLevel);
    // In the root we have categories but because the $CurrentLevel is incremented we may not have categories on the respective level
    if (is_array($CategoriesID_Level) && $InterMediateLevel <= $maxdepth) {
    foreach ($CategoriesID_Level as $CatID => $CatLevel){
    // Select only Categories related, not all categories of the $InterMediateLevel level. Ex: Family + Uncles not cousins
    // extracted $CurentLevel+1 >= $InterMediateLevel &&
    if( $this->getParent($CatID) == $ParentID ){

    $this->AllCategories[$CatID] = array('level' => $CatLevel,'url' => $this->Categories[$CatID]['url'], 'name' => $this->Categories[$CatID]['name'], 'childs' => $this->categoryHasChilds($CatID), 'root' => 'no', 'index' => $this->Index[$InterMediateLevel],'parent' => $ParentID);
    // Go to the next level but not showing cousins
    $this->makeHomeTree($CurentCategory,$CurentLevel,$CatID, $InterMediateLevel+1);
    $this->Index[$InterMediateLevel]++;
    }
    }
    }
    }
    function getEntireTree()
    {
    $this->makeEntireTree(0,0);
    return $this->AllCategories;
    }
    function getHomeTree(){
    $this->makeHomeTree(0,0);
    return $this->AllCategories;
    }

    function categoryHasSubCategories($CatID){
    global $DB;
    $sql = "SELECT COUNT(*) AS `SubCategories` FROM `categories` WHERE `parentid` = '$CatID' LIMIT 0, 1";
    $DB->Query($sql,'categoryHasSubCategories');
    $row = $DB->Fetch('categoryHasSubCategories');
    if ($row['SubCategories'] > 0 ) return 'yes';
    else return 'no';
    }
    function categoryHasProducts($CatID){
    global $DB;
    $sql = "SELECT COUNT(*) AS `NumberOfProducts` FROM `products` WHERE `categoryid` = '$CatID' LIMIT 0, 1";
    $DB->Query($sql,'categoryHasProducts');
    $row = $DB->Fetch('categoryHasProducts');
    if ($row['NumberOfProducts'] > 0 ) return 'yes';
    else return 'no';
    }
    function categoryGetParent($Catid){
    global $DB;
    $sql = "SELECT `parentid` AS `ParentID` FROM `categories` WHERE `categoryid` = '$Catid'";
    $DB->Query($sql,'categoryGetParent');
    $row = $DB->Fetch('categoryGetParent');
    return $row['ParentID'];

    }
    function getCategoriesSpecs($CatID)
    {
    global $DB;
    $sql = "SELECT * FROM `specifications_categories` WHERE `catid` = '$CatID' ORDER BY `catorder` ASC";
    $DB->Query($sql,'getCategoriesSpecs');
    while ($row = $DB->Fetch('getCategoriesSpecs')){
    $this->CategoriesSpesc[$row['speccatid']] = $row['speccatname'];
    }
    return $this->CategoriesSpesc;
    }
    function getCatSpecs($SpecCatID)
    {
    global $DB;
    $sql = "SELECT * FROM `specifications` WHERE `speccatid` = '$SpecCatID' ORDER BY `specorder` ASC";
    $DB->Query($sql,'getSpecs');
    while ($row = $DB->Fetch('getSpecs')){
    $return[$row['specid']] = $row;
    }
    return $return;
    }
    function getRawSpecs($CatID)
  • 01-04-2016, 22:43:21
    #2
    Web Sitesi Açıldığıda alttaki Gibi sıralama yapıyor
    ama ben sıralamanın altta ---------------- olması gereken sıralama Altta ---------- yazan yerin altındaki gibi olmasını istiyorum

    CategoryTree

    KATEGORILER
    Oki Yazici Parca
    Hp Yazici Parca
    Laserjet 1000
    Laserjet 1010
    Laserjet 1012
    Laserjet 1015
    Laserjet 1018
    Laserjet 1020
    Laserjet 1022
    Laserjet P1005
    Laserjet P1102
    Laserjet 2014
    Laserjet 2015
    Laserjet P2035
    Laserjet P3005
    Color Laserjet 8500
    Color Laserjet 1600
    Color Laserjet CP1215

    Samsung Yazici Parca
    Xerox Yazici Parca
    Panasonic Yazici Parca
    Epson Yazici Parca
    Canon Yazici Parca
    Lexmark Yazici Parca
    BERK-JET Kartus
    Muhtelif Urunler
    JetDirect Cart Ethernet
    Citizen Yazici Parca
    Wincor Nixdorf Parca
    Tally Yazici Parca
    Yazici Tamir Bakim

    ---------------- olması gereken sıralama Altta ----------


    KATEGORILER
    Oki Yazici Parca
    Hp Yazici Parca
    Samsung Yazici Parca
    Xerox Yazici Parca
    Panasonic Yazici Parca
    Epson Yazici Parca
    Canon Yazici Parca
    Lexmark Yazici Parca
    BERK-JET Kartus
    Muhtelif Urunler
    JetDirect Cart Ethernet
    Citizen Yazici Parca
    Wincor Nixdorf Parca
    Tally Yazici Parca
    Yazici Tamir Bakim