Shop-System

wethe

Mitglied
Richte gerade ein Shop System ein und dort gibt es ein Menü dass ich gerne konfigurieren würde.
Im Moment schaut es so aus dass die Kategorien angezeigt werden und wenn man dann auf eine drauf drückt klappen sich daraunter die Unterkategorien aus. Vom Stil her wie es ist möchte ich es auch behalten, jedoch nur die kleinigkeit dass die Unterkategorien permanent ausgeklappt angezeigt werden und zwar genaus wie hier:

http://img514.imageshack.us/img514/8489/unbenannt27yi.jpg

Habe nach einiger Zeit nun die PHP-Datei gefunden die dies steuert, komme jedoch nicht mit dem Code klar. Habe schon mehrere Leute gefragt die ein mehr Erfahrung mit PHP haben und die konnten mir auch nicht weiter helfen. Liegt vermutlich daran dass der Shop mit Smarty entwickelt wurde.

Ich habe die Datei mal hier hochgeladen:
block_categories.php

Wäre total froh wenn jmd. mir helfen könnte!

Lieben Gruß
Jacob
 
Oops! Vielen Dank für den Hinweis! Aber schonmal schön Resonanz zu haben :)

PHP:
 /** ensure this file is being included by a parent file */
  defined( 'OOS_VALID_MOD' ) or die( 'Direct Access to this location is not allowed.' );

  if (!defined('HIDE_A_CATEGORY_ON')) {
    define('HIDE_A_CATEGORY_ON', 'false');
  }

 /**
  * Return the number of products in a category
  *
  * @param $category_id
  * @param $include_inactive
  * @return string
  */ 
  function oosCountProductsInCategory($category_id, $include_inactive = false) {
    
    $products_count = 0;

    $db =& oosDBGetConn();
    $oosDBTable = oosDBGetTables();

    if ($include_inactive == true) {
      $products = $db->Execute("SELECT COUNT(*) AS total FROM " . $oosDBTable['products'] . " p, " . $oosDBTable['products_to_categories'] . " p2c WHERE p.products_id = p2c.products_id AND p2c.categories_id = '" . intval($category_id) . "'");
    } else {
      $products = $db->Execute("SELECT COUNT(*) AS total FROM " . $oosDBTable['products'] . " p, " . $oosDBTable['products_to_categories'] . " p2c WHERE p.products_id = p2c.products_id AND p.products_status >= '1' AND p2c.categories_id = '" . intval($category_id) . "'");
    }
    $products_count += $products->fields['total'];

    $child_categories_result = $db->Execute("SELECT categories_id FROM " . $oosDBTable['categories'] . " WHERE parent_id = '" . intval($category_id) . "'");
    if ($child_categories_result->RecordCount()) {
      while ($child_categories = $child_categories_result->fields) {
        $products_count += oosCountProductsInCategory($child_categories['categories_id'], $include_inactive);
        $child_categories_result->MoveNext();
      }
    }

    return $products_count;
  }


 /**
  * Return true if the category has subcategories
  *
  * @param $category_id
  * @return boolean
  */
  function oosHasCategorySubcategories($category_id) {

    $db =& oosDBGetConn();    
    $oosDBTable = oosDBGetTables();

    $child_category = $db->Execute("SELECT COUNT(*) AS total FROM " . $oosDBTable['categories'] . " WHERE parent_id = '" . intval($category_id) . "'");

    if ($child_category->fields['total'] > 0) {
      return true;
    } else {
      return false;
    }
  }  

 /**
  * Return Show Category
  *
  * @param $counter
  * @return string
  */
  function oosShowCategory($counter) {
    global $foo, $categories_array, $cPath_new, $id;

    $oosFilename = oosGetFilename();
    $oosModules = oosGetModules();

    $category_array = array('counter' => $counter);

    if ( (isset($id)) && (in_array($counter, $id)) ) {
      $category_array['isSelected'] = 1;
    } else {
      $category_array['isSelected'] = 0;
    }

    if (oosHasCategorySubcategories($counter)) {
      $category_array['isHasSubCategories'] = 1;
    } else {
      $category_array['isHasSubCategories'] = 0;
    }

    if (SHOW_COUNTS == 'true') {
      $products_in_category = oosCountProductsInCategory($counter);
      $category_array['countProductsInCategory'] = $products_in_category;
    }

    $category_array = array_merge($category_array, $foo[$counter]);
    $categories_array[] = $category_array;

    if ($foo[$counter]['next_id']) {
      oosShowCategory($foo[$counter]['next_id']);
    }
  }
  
  
  // Use Categories Scroll List
  // Uses HIDE_A_CATEGORY 
  if (CATEGORIES_BOX_SCROLL_LIST_ON == 'true') {
    $categories_isscroll = 1;
    $categories_array = array();
    $categories_array['hideSession'] = oosHideSessionId();
    $categories_array['pullDownMenu'] = oosDrawPullDownMenu('cPath', oosGetCategories(array(array('id' => '', 'text' => $lang['pull_down_default']))), $cPath, 'onchange="this.form.submit();" size="' . CATEGORIES_SCROLL_BOX_LEN . '"');
  } else {
    // Normal Categories Display list
    $categories_isscroll = 0;
    if (HIDE_A_CATEGORY_ON == 'false') {
      $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id, c.categories_status 
              FROM " . $oosDBTable['categories'] . " c, 
                   " . $oosDBTable['categories_description'] . " cd 
              WHERE c.categories_status = '1' 
                AND c.parent_id = '0' 
                AND c.categories_id = cd.categories_id 
                AND cd.categories_language = '" . oosDBInput($language) . "' 
                AND c.categories_id !='" . (int)HIDE_A_CATEGORY . "' 
              ORDER BY sort_order, cd.categories_name";
    } else {
      $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id, c.categories_status 
              FROM " . $oosDBTable['categories'] . " c, 
                   " . $oosDBTable['categories_description'] . " cd 
              WHERE c.categories_status = '1' 
                AND c.parent_id = '0' 
                AND c.categories_id = cd.categories_id 
                AND cd.categories_language = '" . oosDBInput($language) . "' 
              ORDER BY sort_order, cd.categories_name";
    }
    $categories_result = $db->Execute($sql);
    while ($categories = $categories_result->fields) {
      $foo[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                 'parent' => $categories['parent_id'],
                                                 'level' => 0,
                                                 'path' => $categories['categories_id'],
                                                 'next_id' => false);

      if (isset($prev_id)) {
        $foo[$prev_id]['next_id'] = $categories['categories_id'];
      }

      $prev_id = $categories['categories_id'];

      if (!isset($first_element)) {
        $first_element = $categories['categories_id'];
      }
      $categories_result->MoveNext();
    }


    if (oosNotNull($cPath)) {
      $new_path = '';
      $id = split('_', $cPath);
      reset($id);
      while (list($key, $value) = each($id)) {
        unset($prev_id);
        unset($first_id);
        $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id, c.categories_status 
                FROM " . $oosDBTable['categories'] . " c, 
                     " . $oosDBTable['categories_description'] . " cd 
                WHERE c.categories_status = '1' 
                  AND c.parent_id = '" . intval($value) . "' 
                  AND c.categories_id = cd.categories_id 
                  AND cd.categories_language = '" . oosDBInput($language) . "' 
                ORDER BY sort_order, cd.categories_name";
        $categories_result = $db->Execute($sql);
        $category_check = $categories_result->RecordCount();
        if ($category_check > 0) {
          $new_path .= $value;
          while ($row = $categories_result->fields) {
            $foo[$row['categories_id']] = array('name' => $row['categories_name'],
                                                'parent' => $row['parent_id'],
                                                'level' => $key+1,
                                                'path' => $new_path . '_' . $row['categories_id'],
                                                'next_id' => false);

            if (isset($prev_id)) {
              $foo[$prev_id]['next_id'] = $row['categories_id'];
            }

            $prev_id = $row['categories_id'];

            if (!isset($first_id)) {
              $first_id = $row['categories_id'];
            }

            $last_id = $row['categories_id'];
          
            $categories_result->MoveNext();
          }
          $foo[$last_id]['next_id'] = $foo[$value]['next_id'];
          $foo[$value]['next_id'] = $first_id;
          $new_path .= '_';
        } else {
          break;
        }
      }
    }
    oosShowCategory($first_element); 

  }

  $smarty->assign(array('block_heading_categories' => $block_heading,
                        'categories_contents' => $categories_array,
                        'categories_isscroll' => $categories_isscroll));
?>
 
Zuletzt bearbeitet:
Zurück