Da schon mehrere gefragt haben, hier die L?sung f?r eine Liste der neuen Produkte im Content-Bereich, ohne diese in der TOP-Kategorie einordnen zu m?ssen. Vielleicht g?be es auch einen anderen Weg, aber ich habe halt diese L?sung programmiert....
Ok. Im Prinzip musst ein neues Module programmiert werden. Das ist als solches nicht schwer, allerdings gibt es zwei Dateien im XTC, die ver?ndert werden m?ssen....
Ein Modul besteht im wesentlichen aus einer Modul-Datei, die die Programmierung enth?lt und dem entsprechenden SMARTY-Template mit dem HTML-Output.
Als erstes mu? in \includes\filenames.php die neue Modul-Datei eingetragen werden. Dort f?gt man einfach diese Zeile ein:
define('FILENAME_WHATS_NEW', 'whats_new.php');
Jetzt mu? der Content-Seite in der Mitte gesagt werden, dass dieses neue Modul geladen werden soll:
Dies findet in der Datei \includes\center_modules.php statt:
require(DIR_WS_MODULES . FILENAME_WHATS_NEW);
Ich hab diese Zeile nach der Zeile mit NEW_PRODUCTS eingef?gt.
Das war es im wesentlichen.
Der unten aufgef?hrte Sourcecode muss als Datei WHATS_NEW.PHP in das Verzeichnis \includes\modules gespeichert werden.
In das Verzeichnis \templates\meintemplate\module muss der zweite Sourcecode als WHATSNEW.HTML gespeichert werden.
Diese Datei mu?t nach eigenen Bed?rfnissen anpasst werden. Die generiert den HTML-Output. Das funktioniert wie bei den anderen HTML-Templates.
So, im letzten Schritt muss nat?rlich noch dem Main Content klargemacht werden, dass er den Modul-Output auch angezeigt. Hierf?r wird in der Datei \template\meintemplate\module\main_content.htm l noch den Smarty-Aufruf eingef?gt:
{$MODULE_whats_new}
Und zwar da, wo die Liste erscheinen soll.
in der WHATS_NEW.PHP gibt es eine Angabe $how_much_entries, die angibt, wie viele neue Produkte angezeigt werden sollen. Da ich eine zweispaltige Ausgabe gemacht habe, ist der Wert immer eine gerade Zahl, aber das h?ngt davon ab, wie die Ausgabe gestaltet wird.
ich hoffe, das war soweit verst?ndlich....
WHATS_NEW.PHP
Code:
<?
/* -----------------------------------------------------------------------------------------
WHATS_NEW MODULE, created by Joern Steinhauer, 2004-09-05
---------------------------------------------------------------------------------------*/
$box_smarty = new smarty;
$box_smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');
$box_content = '';
$how_much_entries = 2;
# include needed functions
require_once(DIR_FS_INC . 'xtc_random_select.inc.php');
require_once(DIR_FS_INC . 'xtc_rand.inc.php');
require_once(DIR_FS_INC . 'xtc_get_products_name.inc.php');
require_once(DIR_FS_INC . 'xtc_get_products_price.inc.php');
require_once(DIR_FS_INC . 'xtc_row_number_format.inc.php');
require_once(DIR_FS_INC . 'xtc_image_button.inc.php');
require_once(DIR_FS_INC . 'xtc_get_short_description.inc.php');
require_once(DIR_FS_INC . 'format_price_image.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_ids LIKE '%c_".$_SESSION['customers_status']['customers_status_id']."_group%'";
# create database query
$strSQL = "select distinct
p.products_fsk18,
p.products_id,
p.products_image,
p.products_tax_class_id,
p.products_price
from " . TABLE_PRODUCTS . " p, " .
TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " .
TABLE_CATEGORIES . " c
where p.products_status=1
and p.products_id = p2c.products_id
and p.products_id !='".(int)$_GET['products_id']."' ".$fsk_lock."
and c.categories_id = p2c.categories_id
".$group_check."
and c.categories_status=1 order by
p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW;
$random_product = xtc_db_query($strSQL);
$rows = 0;
$box_content = array();
$tmp_content = array();
# create array with all entries
while ($whats_new = xtc_db_fetch_array($random_product))
{
$rows++;
$image = ($whats_new['products_image']) ? $image = DIR_WS_THUMBNAIL_IMAGES . $whats_new['products_image'] : '';
$name = xtc_get_products_name($whats_new['products_id']);
$whats_new['products_short_description'] = xtc_get_short_description($whats_new['products_id']);
if ($_SESSION['customers_status']['customers_status_show_price'] != '0') $buy_now='';
if ($_SESSION['customers_status']['customers_fsk18'] == '1')
{
if ($whats_new['products_fsk18'] == '0') $buy_now='<a href="' . xtc_href_link(basename($PHP_SELF), xtc_get_all_get_params(array('action')) . 'action=buy_now&BUYproducts_id=' . $new_products['products_id'], 'NONSSL') . '">' . xtc_image_button('button_buy_now.gif', TEXT_BUY . $name . TEXT_NOW);
}
else
{
$buy_now='<a href="' . xtc_href_link(basename($PHP_SELF), xtc_get_all_get_params(array('action')) . 'action=buy_now&BUYproducts_id=' . $whats_new['products_id'], 'NONSSL') . '">' . xtc_image_button('button_buy_now.gif', TEXT_BUY . $name . TEXT_NOW);
}
$price_str = xtc_get_products_price($whats_new['products_id'],$price_special = 1,$quantity = 1);
$img_price_str = format_price_image($price_str);
$tmp_content[] = array(
'ID' => xtc_row_number_format($rows),
'NAME' => $name,
'IMAGE' => $image,
'DESCRIPTION' => $whats_new['products_short_description'],
'PRICE'=> $img_price_str,
'LINK'=> xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $whats_new['products_id']),
'BUTTON_BUY_NOW'=>$buy_now);
}
# get a random part of it
$rand_keys = array_rand($tmp_content, $how_much_entries);
foreach ($rand_keys as $key=>$value)
{
$box_content[] = $tmp_content[$value];
}
$box_smarty->assign('box_content', $box_content);
$box_smarty->assign('language', $_SESSION['language']);
# set cache ID
if (USE_CACHE == 'false')
{
$box_smarty->caching = 0;
$box_whats_new = $box_smarty->fetch(CURRENT_TEMPLATE.'/module/whatsnew.html');
}
else
{
$box_smarty->caching = 1;
$box_smarty->cache_lifetime = CACHE_LIFETIME;
$box_smarty->cache_modified_check = CACHE_CHECK;
$cache_id = $_SESSION['language'].$random_product['products_id'].$_SESSION['customers_status']['customers_status_name'];
$box_whats_new = $box_smarty->fetch(CURRENT_TEMPLATE.'/module/whatsnew.html',$cache_id);
}
$default_smarty->assign('MODULE_whats_new',$box_whats_new);
?>
WHATSNEW.HTML
Code:
{config_load file="$language/lang_$language.conf" section="boxes"}
<div class="tblcontent">
<a href="/products_new.php"><img class="tblcontent"src="{$tpl_path}images/r_new_product.jpg" border="0" alt="{#heading_whatsnew#}"></a>
</div>
<div class="tblcontent" style="margin-top: 0px; margin-bottom:10px;">
<table class="tblcontent" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
{foreach name=aussen item=box_data from=$box_content}
{php} $col++;
if ($col == 1) echo '<td style="padding-top: 5px;">';
else echo '<td align="right" style="padding-right: 2px; padding-top:5px;">';
{/php}
<div class="window mainbox">
<div class="titleBarW">
<span class="titleBarTextW">{$box_data.NAME}</span>
</div>
<div class="clientAreaW">
<table width="100%" border="0" cellpadding="0" cellspacing="4">
<tr>
<td rowspan="2" class="picbox">{if $box_data.IMAGE}<a href="{$box_data.LINK}"><img src="{$box_data.IMAGE}" border="0"></a>{/if}</td>
<td class="main"><strong><a href="{$box_data.LINK}">{$box_data.NAME}</a></strong></td>
</tr>
<tr valign="bottom">
<td class="main">
{$box_data.DESCRIPTION}<br/>
<strong>{$box_data.PRICE}</strong>
<br/>{$box_data.BUTTON_BUY_NOW}
</td>
</tr>
</table>
</div>
</div>
</td>
{php}
if ($col>=2)
{
$col=0;
echo '</tr><tr>';
}
{/php}
{/foreach}
</tr>
</table>
</div>
Gruss
Morix :?: