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
<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)
require_once(DIR_WS_BOXES . 'best_sellers.php');
Neu erstellen: source/boxes/best_sellers.php
<?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
{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