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: Erbitte Hilge wegen BOX

    gonzo88

    • Mitglied
    • Beiträge: 171
    Erbitte Hilge wegen BOX
    am: 25. April 2013, 16:04:32
    Hallo,

    ich bastele schon seit 3 Std. an einer Box, welche die Artikel mit manufacturers_id=3 per Zufallsgenerator anzeigen soll. Das ist quasi mein "Ersatz" für die "Bestseller", da ich diese dann manuell steuern, definieren  kann.
    Die Datenbakabfrage habe ich schon hinbekommen. Die echo-Zeile zeigt mir den Dateinamen des Bildes an und diese wechseln auch.
    Ich bekomme aber den Code nicht hin, dass meine Box erscheint. Ich habe hierfür die box_specials.php, box_whats_new.pho und eine Boxanleitung von hier zu Rate gezogen, komme aber nicht weiter. Box wird nicht angezeigt.
    Kann mir jemand von Euch einen Tipp geben, bitte?

    source/boxex/best_sellers.php
    Code: PHP  [Auswählen]
    <?php

    $box_smarty = new smarty;
    $box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
    $box_content = '';
    // include needed functions
    require_once (DIR_FS_INC.'xtc_random_select.inc.php');

    //fsk18 lock
    $fsk_lock = '';
    if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
            $fsk_lock = ' and p.products_fsk18!=1';
    }
    if (GROUP_CHECK == 'true') {
            $group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
    }

                                    $best_sellers_query = "select
                                                   p.products_id,
                                                   p.products_image,
                                                   pd.products_name from "
    .TABLE_PRODUCTS." p,
                                                   "
    .TABLE_PRODUCTS_DESCRIPTION." pd       
                                                   where p.products_status = '1'
                                                   "
    .$group_check."
                                                   and p.manufacturers_id = '3'
                                                   and p.products_id = pd.products_id "
    .$fsk_lock."
                                                   and pd.language_id = '"
    .(int) $_SESSION['languages_id']."' ";

                                    $random_best_sellers = xtc_random_select($best_sellers_query);
                                    echo "Produkt: " . $random_best_sellers['products_image'];

    $box_smarty->assign('box_content',$product->buildDataArray($best_sellers_quer));
    $box_smarty->assign('language', $_SESSION['language']);

      // set cache ID
       if (!CacheCheck()) {
              $box_smarty->caching = 0;
              $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html');
      } else {
              $box_smarty->caching = 1;
              $box_smarty->cache_lifetime = CACHE_LIFETIME;
              $box_smarty->cache_modified_check = CACHE_CHECK;
              $cache_id = $_SESSION['language'];
              $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html', $cache_id);
      }
     
      $smarty->assign('box_BEST_SELLERS', $box_best_sellers);
      ?>

    boxes/box_best_sellers.html
    Code: PHP  [Auswählen]
    {config_load file="$language/lang_$language.conf" section="boxes"}
    <h2 class="boxheader"><a href="#">{#heading_best_sellers#}</a></h2>
    <div class="boxbody">
            {if $box_content.PRODUCTS_IMAGE}<p class="center"><a href="index.php?manufacturers_id=3"><img src="{$box_content.PRODUCTS_IMAGE}" alt="{$box_content.PRODUCTS_NAME}" class="productboximage"/></a></p>{/if}
    </div>


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

    Matt

    • Experte
    • Beiträge: 4.241
    Re: Erbitte Hilge wegen BOX
    Antwort #1 am: 25. April 2013, 16:13:09
    Cache geleert? File in source/boxes.php inkludiert? Box in der index.html eingebunden?

    gonzo88

    • Mitglied
    • Beiträge: 171
    Re: Erbitte Hilge wegen BOX
    Antwort #2 am: 26. April 2013, 14:46:48
    Hallo Matt,

    danke für Deine Antwort.
    Ja, habe ich:

    module/main_content.html (soll nur auf der Startseite erscheinen)
    Code: PHP  [Auswählen]
    {php}
    global $smarty;
    $this->assign('box_BEST_SELLERS',$smarty->_tpl_vars['box_BEST_SELLERS']);
    {/php}

    source/boxex.php
    Code: PHP  [Auswählen]
        require_once(DIR_WS_BOXES . 'best_sellers.php');

    Cache geleert.
    :-(

    Grüße
    Gonzo

    Matt

    • Experte
    • Beiträge: 4.241
    Re: Erbitte Hilge wegen BOX
    Antwort #3 am: 26. April 2013, 16:22:12
    Und es gibt einen Grund, warum du in der index.html die Box nicht so einbindest wie alle anderen Boxen auch?

    gonzo88

    • Mitglied
    • Beiträge: 171
    Re: Erbitte Hilge wegen BOX
    Antwort #4 am: 29. April 2013, 13:59:01
    Hallo Matt,

    ja, weil ich die Box(en) nur im Content der Startseite haben möchte. Deswegen die Einbindung in die module/main_content.html.
    Ich habe den Fehler jetzt aber gefunden. Es war ein falsche Variable gesetzt.

    Für Alle, die auch eine eigene Box planen, in der ein Zufallsprodukt einer Hersteller-ID angezeigt werden soll, hier der Code. Variablen oder Benennungen der Box ggf. nach eigenen Bedürfnissen anpassen:

    In der index.html (oder wie bei mir in der /module/main_content.html
    Code: PHP  [Auswählen]
    <div id="produktboxen">
    {php}
    global $smarty;
    $this->assign('box_BEST_SELLERS',$smarty->_tpl_vars['box_BEST_SELLERS']);
    {/php}
    <div id="produktbox-bestsellers">
    {$box_BEST_SELLERS}
    </div>
     

    In der source/boxes.php (an der entsprechenden Stelle)
    Code: PHP  [Auswählen]
    require_once(DIR_WS_BOXES . 'best_sellers.php');
     

    Neu erstellen: source/boxes/best_sellers.php
    Code: PHP  [Auswählen]
    <?php

    $box_smarty = new smarty;
    $box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
    $box_content = '';
    // include needed functions
    require_once (DIR_FS_INC.'xtc_random_select.inc.php');

    //fsk18 lock
    $fsk_lock = '';
    if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
            $fsk_lock = ' and p.products_fsk18!=1';
    }
    if (GROUP_CHECK == 'true') {
            $group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
    }

                                    $best_sellers_query = "select
                                                   p.products_id,
                                                   p.products_image,
                                                   pd.products_name from "
    .TABLE_PRODUCTS." p,
                                                   "
    .TABLE_PRODUCTS_DESCRIPTION." pd       
                                                   where p.products_status = '1'
                                                   "
    .$group_check."
                                                   and p.manufacturers_id = '3'
                                                   and p.products_id = pd.products_id "
    .$fsk_lock."
                                                   and pd.language_id = '"
    .(int) $_SESSION['languages_id']."' ";

                                    $random_best_sellers = xtc_random_select($best_sellers_query);


    $box_smarty->assign('box_content',$product->buildDataArray($random_best_sellers));
    $box_smarty->assign('language', $_SESSION['language']);

      // set cache ID
       if (!CacheCheck()) {
              $box_smarty->caching = 0;
              $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html');
      } else {
              $box_smarty->caching = 1;
              $box_smarty->cache_lifetime = CACHE_LIFETIME;
              $box_smarty->cache_modified_check = CACHE_CHECK;
              $cache_id = $_SESSION['language'];
              $box_best_sellers = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_best_sellers.html', $cache_id);
      }
     
      $smarty->assign('box_BEST_SELLERS', $box_best_sellers);
      ?>
     

    Neu erstellen: boxes/best_sellers.html
    Code: PHP  [Auswählen]
    {config_load file="$language/lang_$language.conf" section="boxes"}
    <h2 class="boxheader"><a href="#">{#heading_best_sellers#}</a></h2>
    <div class="boxbody">
            {if $box_content.PRODUCTS_IMAGE}<p class="center"><a href="index.php?manufacturers_id=3"><img src="{$box_content.PRODUCTS_IMAGE}" alt="{$box_content.PRODUCTS_NAME}" class="productboximage"/></a></p>
    {/if}
    </div>
     

    Ein Dankeschön der Community!
    Grüße
    Gonzo
    1 Antworten
    4263 Aufrufe
    04. August 2011, 08:48:51 von DokuMan
    2 Antworten
    2337 Aufrufe
    23. April 2012, 17:35:28 von bluecali
    0 Antworten
    1008 Aufrufe
    25. September 2017, 15:39:17 von Friederike
    0 Antworten
    1870 Aufrufe
    12. Mai 2011, 11:19:44 von Tomcraft
               
    anything