Modulshop - Eine große Auswahl an neuen und hilfreichen Modulen für die modified eCommerce Shopsoftware
Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: In den Kategorien nur Level 1 anzeigen ?!

    newbee79

    • Fördermitglied
    • Beiträge: 185
    • Geschlecht:
    In den Kategorien nur Level 1 anzeigen ?!
    am: 23. Februar 2014, 12:17:36
    Hi zusammen,

    such' mir echt den Wolf und finde einfach nix.

    Ich habe mir meine Kategoriebox dupliziert ( also neue Dateien cat2.php und box_cat2.html ) und habe diese nun im Template woanders eingebaut  - klappt auch prima.

    Und bei dieser möchte ich jetzt aber, dass nur die Level 1 Links angezeigt werden - also dass keine
    Unterverzeichnisse aufgehen.

    Kann mir jemand helfen?

    Kann ich da in der source/boxes/cat2.php nicht irgendwelche Textstellen einfach löschen, dass er nicht
    weiter runter geht?

    Gruß
    David

    Linkback: https://www.modified-shop.org/forum/index.php?topic=29451.0
    Modulshop - Eine große Auswahl an neuen und hilfreichen Modulen für die modified eCommerce Shopsoftware

    extrem

    • Neu im Forum
    • Beiträge: 33
    • Geschlecht:
    Re: In den Kategorien nur Level 1 anzeigen ?!
    Antwort #1 am: 23. Februar 2014, 12:55:47
    Hallo, Poster doch bitte mal den Code deiner php Datei.

    newbee79

    • Fördermitglied
    • Beiträge: 185
    • Geschlecht:
    Re: In den Kategorien nur Level 1 anzeigen ?!
    Antwort #2 am: 23. Februar 2014, 13:05:40
    Hi,

    hier mal der Code ( ist ja die Standard Categories.php )

    Code: PHP  [Auswählen]
    <?php

    /* -----------------------------------------------------------------------------------------
       $Id: categories.php 1302 2005-10-12 16:21:29Z mz $  

       XT-Commerce - community made shopping
       http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))

       Copyright (c) 2003 XT-Commerce
       -----------------------------------------------------------------------------------------
       based on:
       (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
       (c) 2002-2003 osCommerce(categories.php,v 1.23 2002/11/12); www.oscommerce.com
       (c) 2003      nextcommerce (categories.php,v 1.10 2003/08/17); www.nextcommerce.org

       Released under the GNU General Public License
       -----------------------------------------------------------------------------------------
       Third Party contributions:
       Enable_Disable_Categories 1.3                Autor: Mikel Williams | mikel@ladykatcostumes.com

       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/

    // reset var
    $start = microtime();
    $box_smarty = new smarty;
    $box_content = '';
    //$rebuild = false; //DokuMan - 2010-02-28 - fix Smarty cache error on unlink

    $box_smarty->assign('language', $_SESSION['language']);
    // set cache ID
    if (!CacheCheck()) {
            $cache=false;
            $box_smarty->caching = 0;
            $cache_id = null; //DokuMan - 2010-02-26 - Undefined variable: cache_id
    } else {
            $cache=true;
            $box_smarty->caching = 1;
            $box_smarty->cache_lifetime = CACHE_LIFETIME;
            $box_smarty->cache_modified_check = CACHE_CHECK;
            $cache_id = $_SESSION['language'].$_SESSION['customers_status']['customers_status_id'].'-'.$cPath;
    }

    if(!$box_smarty->is_cached(CURRENT_TEMPLATE.'/boxes/box_categories.html', $cache_id) || !$cache){
    $box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
    //$rebuild=true; //DokuMan - 2010-02-28 - fix Smarty cache error on unlink

    // include needed functions
    require_once (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/inc/xtc_show_category.inc.php');
    require_once (DIR_FS_INC.'xtc_has_category_subcategories.inc.php');
    require_once (DIR_FS_INC.'xtc_count_products_in_category.inc.php');

    $categories_string = '';
    $group_check = ''; //DokuMan - 2010-02-28 - set undefined variable group_check
    if (GROUP_CHECK == 'true') {
            $group_check = "and c.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
    }
    $categories_query = "select c.categories_id,
                                               cd.categories_name,
                                               c.parent_id from "
    .TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd
                                               where c.categories_status = '1'
                                                                                       AND c.section = 0
                                               and c.parent_id = '0'
                                               "
    .$group_check."
                                               and c.categories_id = cd.categories_id
                                               and cd.language_id='"
    .(int) $_SESSION['languages_id']."'
                                               order by sort_order, cd.categories_name"
    ;
    $categories_query = xtDBquery($categories_query);

    while ($categories = xtc_db_fetch_array($categories_query, true)) {
            $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'];
            }
    }

    //------------------------
    if ($cPath) {
            $new_path = '';
            $id = explode('_', $cPath); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
            reset($id);
            while (list ($key, $value) = each($id)) {
                    unset ($prev_id);
                    unset ($first_id);
                    $categories_query = "select c.categories_id, cd.categories_name, c.parent_id from ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd where c.categories_status = '1' and c.parent_id = '".$value."' ".$group_check." and c.categories_id = cd.categories_id and cd.language_id='".$_SESSION['languages_id']."' order by sort_order, cd.categories_name";
                    $categories_query = xtDBquery($categories_query);
                    $category_check = xtc_db_num_rows($categories_query, true);
                    if ($category_check > 0) {
                            $new_path .= $value;
                            while ($row = xtc_db_fetch_array($categories_query, true)) {
                                    $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'];
                            }
                            $foo[$last_id]['next_id'] = $foo[$value]['next_id'];
                            $foo[$value]['next_id'] = $first_id;
                            $new_path .= '_';
                    } else {
                            break;
                    }
            }
    }

    xtc_show_category($first_element);

    $box_smarty->assign('BOX_CONTENT', $categories_string); //DokuMan - 2010-03-02 - BOX_CONTENT on wrong position

    }

    // set cache ID
    //BOF - DokuMan - 2010-02-28 - fix Smarty cache error on unlink
    /*
    if (!$cache || $rebuild) {
            $box_smarty->assign('BOX_CONTENT', $categories_string);
            if ($rebuild) $box_smarty->clear_cache(CURRENT_TEMPLATE.'/boxes/box_cat2.html', $cache_id);
            $box_categories = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_cat2.html',$cache_id);
    } else {
            $box_categories = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_cat2.html', $cache_id);
    }
    */

    if (!$cache) {
        $box_categories = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_cat2.html');
    } else {
        $box_categories = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_cat2.html', $cache_id);
    }
    //EOF - DokuMan - 2010-02-28 - fix Smarty cache error on unlink

    $smarty->assign('box_CAT2', $box_categories);
    ?>

    Gruß
    David

    extrem

    • Neu im Forum
    • Beiträge: 33
    • Geschlecht:
    Re: In den Kategorien nur Level 1 anzeigen ?!
    Antwort #3 am: 23. Februar 2014, 16:59:59
    Hallo David,

    Lösche oder kommentiere folgende Zeilen aus.

    Bei mir ist es Zeile 95 bis 141

    Hier der Teil den du Löschen solltest.

    Code: PHP  [Auswählen]
     if ($cPath) {
          $new_path = '';
          $id = explode('_', $cPath); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
          reset($id);
          while (list ($key, $value) = each($id)) {
            unset ($prev_id);
            unset ($first_id);
            //BOF - web - 2010-11-11 - Do not display empty catagorie names - add and trim(cd.categories_name) != ''
            $categories_query = "select c.categories_id,
                                        cd.categories_name,
                                        c.parent_id
                                   from "
    .TABLE_CATEGORIES." c,
                                        "
    .TABLE_CATEGORIES_DESCRIPTION." cd
                                  where c.categories_status = '1'
                                    and c.parent_id = '"
    .$value."'
                                        "
    .$group_check."
                                    and c.categories_id = cd.categories_id
                                    and cd.language_id='"
    .$_SESSION['languages_id']."'
                                    and trim(cd.categories_name) != ''
                                  order by sort_order, cd.categories_name"
    ;
            //EOF - web - 2010-11-11 - Do not display empty catagorie names - add and trim(cd.categories_name) != ''
            $categories_query = xtDBquery($categories_query);
            $category_check = xtc_db_num_rows($categories_query, true);
            if ($category_check > 0) {
              $new_path .= $value;
              while ($row = xtc_db_fetch_array($categories_query, true)) {
                $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'];
              }
              //BOF - DokuMan - 2010-09-21 - fixed undefined index 2
              //$foo[$last_id]['next_id'] = $foo[$value]['next_id'];
              $foo[$last_id]['next_id'] = isset($foo[$value]['next_id']) ? $foo[$value]['next_id'] : 0;
              //EOF - DokuMan - 2010-09-21 - fixed undefined index 2
              $foo[$value]['next_id'] = $first_id;
              $new_path .= '_';
            } else {
              break;
            }
          }
        }

    Das sollte dein Problem löschen.

    Gruß Thomas

    newbee79

    • Fördermitglied
    • Beiträge: 185
    • Geschlecht:
    Re: In den Kategorien nur Level 1 anzeigen ?!
    Antwort #4 am: 23. Februar 2014, 17:43:59
    Hey Thomas !  :-)

    Klappt! Super, vielen Dank!

    Glaubst das, den Teil hatte ich aber schon mal rausgelöscht, aber da lief der Shop dann nicht mehr... hatte ich vielleicht eine Klammer übersehen oder zu wenig gelöscht!

    Freu' mich!

    Nochmals danke und einen schönen Restsonntag noch!

    Gruß
    David
    rechtstexte für onlineshop
    9 Antworten
    5391 Aufrufe
    09. Februar 2015, 14:57:25 von noRiddle (revilonetz)
    1 Antworten
    2721 Aufrufe
    09. Juni 2011, 19:02:13 von bergerschmuck
    3 Antworten
    4219 Aufrufe
    29. Oktober 2012, 19:52:22 von CWYG
               
    anything