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: Neue Box im modified 2.0.0.0 Template

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Neue Box im modified 2.0.0.0 Template
    am: 24. August 2016, 18:17:11
    Hallo Zusammen,
    ich möchte gern eine separate Box für zwei Produktkategorien im modified 2.0.0.0 Template anlegen (für Aktionsartikel)

    Diese soll getrennt von den sonstigen Kategorien sein.
    Gehe ich da am besten nach diesem Tutorial vor, oder funktioniert das anders?

    Tutorial: Erstellung Box

    Linkback: https://www.modified-shop.org/forum/index.php?topic=35590.0

    Tomcraft

    • modified Team
    • Gravatar
    • Beiträge: 46.373
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #1 am: 24. August 2016, 20:50:08
    Das wird ein wenig aufwendiger, denn erstmal musst du ja im Adminbereich die Kategorie-Bearbeitung um Auswahl einer entsprechenden Sektion (Box 1 oder Box 2) erweitern.
    Dann musst du die Kategorie-Box duplizieren und dann noch in beiden Dateien "/templates/tpl_modified/source/boxes/categories.php" sowie "/templates/tpl_modified/source/boxes/categories_2.php" den SQL-Query um die Abfrage Sektion erweitern.

    Grüße

    Torsten

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #2 am: 24. August 2016, 21:55:46
    Okay, das klingt komplizierter.
    Habe das mal nur getestet und die Kategorie Box dupliziert.
    Das hat soweit geklappt.
    Dann Query angepasst um nur eine ID zu erhalten

    Code: PHP  [Auswählen]
    $categories_query = xtDBquery("SELECT c.categories_id,
                                            cd.categories_name,
                                            c.parent_id
                                       FROM "
    .TABLE_CATEGORIES." c
                                       JOIN "
    .TABLE_CATEGORIES_DESCRIPTION." cd
                                            ON c.categories_id = cd.categories_id
                                               AND cd.language_id='"
    .(int)$_SESSION['languages_id']."'
                                               AND trim(cd.categories_name) != ''
                                      WHERE c.categories_status = '1'
                                        AND c.parent_id = '0'
                                        AND c.categories_id = '644'
                                            "
    .CATEGORIES_CONDITIONS_C."
                                   ORDER BY c.sort_order, cd.categories_name"
    );

    in der originalen Box natürlich ebenfalls angepasst um die Kategorie dort zu enfernen.

    Code: SQL  [Auswählen]
    $categories_query = xtDBquery("SELECT c.categories_id,
                                            cd.categories_name,
                                            c.parent_id
                                       FROM "
    .TABLE_CATEGORIES." c
                                       JOIN "
    .TABLE_CATEGORIES_DESCRIPTION." cd
                                            ON c.categories_id = cd.categories_id
                                               AND cd.language_id='"
    .(INT)$_SESSION['languages_id']."'
                                               AND trim(cd.categories_name) != ''
                                      WHERE c.categories_status = '1'
                                        AND c.parent_id = '0'
                                        AND c.categories_id != '644'
                                            "
    .CATEGORIES_CONDITIONS_C."
                                   ORDER BY c.sort_order, cd.categories_name"
    );

    Nur leider ist das wohl zu einfach gedacht.
    Ich kann mir in der selbsterstellten Box irgendwie nur die erste Kategorie aus der originalen Box anzeigen lassen. Also wenn die erste Kategorie z.B. die ID 7 hat, kann ich mir in der selbsterstellten Box auch nur ID 7 anzeigen lassen. Keine beliebige ID.
    Hab ich da einen Denkfehler drin?

    awids

    • Experte
    • Beiträge: 3.803
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #3 am: 24. August 2016, 22:12:48
    Ich schüre dir gerade ein kleines 2.0-Paket für dein Anliegen zurecht. Hatte das vor ein paar Wochen schonmal testweise umgesetzt, aber aus Versehen den falschen Ordner gelöscht, wie mir scheint, und rekonstruiere das nun. Spätestens morgen hast du es als Fertiglösung.

    Angeal

    • Fördermitglied
    • Beiträge: 411
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #4 am: 25. August 2016, 18:05:37
    Oh, das wäre absolut traumhaft. :D

    awids

    • Experte
    • Beiträge: 3.803
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #5 am: 25. August 2016, 18:15:55
    Wenn ich noch das Problem mit der Link-Erstellung lösen könnte, damit ich dir das endlich schicken kann, fände ich noch viel traumhafter.  :lol:

    awids

    • Experte
    • Beiträge: 3.803
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #6 am: 25. August 2016, 21:31:58
    Komme leider nicht so wirklich weiter mit der Linkbildung für die zweite Kategoriebox. Poste hier mal meinen Code, falls ein Profiprogrammierer drüber guckt.

    Wo ist der Fehler in meinem Code?

    categories_section.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
       
       second Categorynavigation by (( Wir dulden keine kommerziellen Werbelinks - Bitte <a href="index.php?topic=3013.0">Forenregeln</a> beachten! ))
       11.07.2006
       ---------------------------------------------------------------------------------------*/

    // include smarty
    include(DIR_FS_BOXES_INC . 'smarty_default.php');

    $box_content = '';

    $box_smarty->assign('language', $_SESSION['language']);
    // set cache ID
    if (!CacheCheck()) {
            $cache=false;
            $box_smarty->caching = 0;
    } 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'].'section'.$cPath;
    }

    if(!$box_smarty->is_cached(CURRENT_TEMPLATE.'/boxes/box_categories_section.html', $cache_id) || !$cache){

    $smarty->assign('tpl_path', DIR_WS_BASE.'templates/'.CURRENT_TEMPLATE.'/');

    // include needed functions
    require_once (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/inc/xtc_show_category_section.inc.php');
    require_once (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/inc/close_ul_tags.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_section_string = '';

    if (GROUP_CHECK == 'true') {
            $group_check = "and c.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
    }
    $categories_section_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 = '1'
                                               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_section_query = xtDBquery($categories_section_query);

    while ($categories_section = xtc_db_fetch_array($categories_section_query, true)) {
            $foo[$categories_section['categories_id']] = array (
                    'name' => $categories_section['categories_name'],
                    'parent' => $categories_section['parent_id'],
                    'level' => 0,
                    'path' => $categories_section['categories_id'],
                    'next_id' => false);

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

            $prev_id = $categories_section['categories_id'];

            if (!isset ($first_section_element)) {
                    $first_section_element = $categories_section['categories_id'];
            }
    }

    //------------------------
    if ($cPath) {
            $new_path = '';
            $id = split('_', $cPath);
            reset($id);
            while (list ($key, $value) = each($id)) {
                    unset ($prev_id);
                    unset ($first_id);
                    $categories_section_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_section_query = xtDBquery($categories_section_query);
                    $category_check = xtc_db_num_rows($categories_section_query, true);
                    if ($category_check > 0) {
                            $new_path .= $value;
                            while ($row = xtc_db_fetch_array($categories_section_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_section($first_section_element);
            $box_smarty->assign('BOX_CONTENT', $categories_section_string);

    }

    // set cache ID
    if (!$cache) {
            $box_categories = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_categories_section.html');
    } else {
            $box_categories = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_categories_section.html', $cache_id);
    }

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

    xtc_show_category_section.inc.php
    Code: PHP  [Auswählen]
    <?php
      /* -----------------------------------------------------------------------------------------
       $Id: xtc_show_category.inc.php 4200 2013-01-10 19:47:11Z Tomcraft1980 $

       modified eCommerce Shopsoftware
       http://www.modified-shop.org

       Copyright (c) 2009 - 2013 [www.modified-shop.org]
       -----------------------------------------------------------------------------------------
       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 (xtc_show_category.inc.php,v 1.4 2003/08/13); www.nextcommerce.org
       (c) 2010  web28 (xtc_show_category.inc.php, v 2.1 2010/11/12); www.rpa-com.de

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

      function xtc_show_category_section($counter, $oldlevel=1) {
        global $foo, $categories_section_string, $id, $cPath_new;  

        $level = $foo[$counter]['level']+1;

        //BOF +++ UL LI Verschachtelung  mit Quelltext Tab Einzügen +++    
        $ul = $tab = '';  
        for ($i = 1; $i <= $level; $i++) {
          $tab .= "\t";
        }    
       
        if ($level > $oldlevel) { //neue Unterebene
          $ul = "\n" . $tab. '<ul>'. "\n";
          $categories_section_string = rtrim($categories_section_string, "\n"); //Zeilenumbruch entfernen
          $categories_section_string = substr($categories_section_string, 0, strlen($categories_section_string) -5);  //letztes  </li>  entfernen  
        } elseif ($level < $oldlevel) { //zurück zur höheren Ebene
          $ul = close_ul_tags($level,$oldlevel);      
        }
        //EOF +++ UL LI Verschachtelung  mit Quelltext Tab Einzügen +++

        //BOF +++ Kategorien markieren +++
        $cPath_new = explode('_',$cPath); //Kategoriepfad in Array einlesen

        //Elternkategorie markieren
        $cat_active_parent = '';
        $in_path = in_array($counter, $cPath_new); //Testen, ob aktuelle Kategorie ID im Kategoriepfad enthalten ist
        if ($in_path) $cat_active_parent = " activeparent".$level;
       
        //Aktive Kategorie markieren
        $cat_active = '';
        $this_category = array_pop($cPath_new); //Letzter Eintrag im Array ist die aktuelle Kategorie
        if ($this_category == $counter) $cat_active = " active".$level;
        //EOF +++ Kategorien markieren +++

        //BOF +++ Kategorie Linkerstellung +++  
        if (trim($categories_section_string == '')) $categories_section_string = "\n"; //Zeilenschaltung Codedarstellung  
        $categories_section_string .= $ul; //UL LI Versschachtelung
        $categories_section_string .= $tab; //Tabulator Codedarstellung
        $categories_section_string .= '<li class="level'.$level.$cat_active.$cat_active_parent.'">';
        $categories_section_string .= '<a href="'.$foo[$counter]['link'].'" title="'. $foo[$counter]['name'] . '">';
        $categories_section_string .= $foo[$counter]['name'];
        //Anzeige Anzahl der Produkte in Kategorie, für bessere Performance im Admin deaktivieren
        if (SHOW_COUNTS == 'true') {
          $products_in_category = xtc_count_products_in_category($counter);
          if ($products_in_category > 0) {
            $categories_section_string .= '&nbsp;(' . $products_in_category . ')';
          }
        }  
        $categories_section_string .= '</a></li>';
        $categories_section_string .= "\n"; //Zeilenschaltung Codedarstellung  
        //EOF  +++ Kategorie Linkerstellung +++

        //Nächste Kategorie
        if ($foo[$counter]['next_id']) {
          xtc_show_category_section($foo[$counter]['next_id'], $level);
        } else {  
          if ($level > 1) $categories_section_string .= close_ul_tags(1,$level);
          return;
        }
      }
    ?>

    [ Für Gäste sind keine Dateianhänge sichtbar ]

    Bonsai

    • Viel Schreiber
    • Beiträge: 4.127
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #7 am: 29. August 2016, 17:53:46
    Code: PHP  [Auswählen]
        $categories_section_string .= '<a href="'.$foo[$counter]['link'].'" title="'. $foo[$counter]['name'] . '">';

     :-?

    Habe jetzt nicht den kompletten Code gelesen, aber ... was steht denn drin in der Variable $foo[$counter]['link']?

    Mach da mal ein var_dump($foo[$counter]['link']);
    Dann würde ich noch prüfen:
    var_dump($counter);

    Globale Variable $foo ... die sind böse :-) ... wird die irgendwo zurückgesetzt?

    misterwong

    • Frisch an Board
    • Beiträge: 87
    • Geschlecht:
    Re: Neue Box im modified 2.0.0.0 Template
    Antwort #8 am: 03. Mai 2017, 15:11:13
    Vielleicht kann ja diese alte Lösung helfen:

    http://www.xtc-load.de/2009/05/zweite-kategorie-box/

    Sonst googlen nach zweite_kategoriebox_xtc304sp21

    LG
    Gordian
    Managed Server
    27 Antworten
    5150 Aufrufe
    11. Mai 2021, 19:35:59 von noRiddle (revilonetz)
    7 Antworten
    6022 Aufrufe
    10. Februar 2011, 22:21:14 von Tomcraft
    2 Antworten
    2949 Aufrufe
    22. Dezember 2016, 16:07:09 von S_teffi
    2 Antworten
    3957 Aufrufe
    17. August 2010, 10:37:58 von Modulfux