Produkte statt Kategorien auflisten als Block
Produkte statt Kategorien auflisten als Block
Hallo, ich würde gerne statt des Kategorie-Blocks ein Block haben, welcher meine Produkte auflistet, da ich keine Kategorien habe. Wie kann ich das in eurem Template-System umsetzen?
Beste Grüße,
Dennis
Beste Grüße,
Dennis
Hallo,
relativ einfach... der Shop wird ja mit unzähligen Content Blöcken ausgeliefert. Hiervon wird
ja in der Regel nur ein Bruchteil später im Shop verwendet... eines dieser nicht verwendeten
Blöck-Systeme schreibst du dir einfach um...
Für die Datenbankabfrage würde ich das Modul neue produkte verwenden
~/shop/includes/moduels/new_products.php
und mir dies reduzieren auf
relativ einfach... der Shop wird ja mit unzähligen Content Blöcken ausgeliefert. Hiervon wird
ja in der Regel nur ein Bruchteil später im Shop verwendet... eines dieser nicht verwendeten
Blöck-Systeme schreibst du dir einfach um...
Für die Datenbankabfrage würde ich das Modul neue produkte verwenden
~/shop/includes/moduels/new_products.php
Code: Alles auswählen
/** ensure this file is being included by a parent file */
defined( 'OOS_VALID_MOD' ) or die( 'Direct Access to this location is not allowed.' );
if (!is_numeric(MAX_DISPLAY_NEW_PRODUCTS)) return false;
if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
$sql = "SELECT p.products_id, pd.products_name, p.products_image, p.products_tax_class_id,
p.products_price, p.products_base_price, p.products_base_unit, p.products_discount_allowed,
substring(pd.products_description, 1, 150) AS products_description,
IF(s.status, s.specials_new_products_price, NULL) AS specials_new_products_price
FROM " . $oosDBTable['products] . " p,
" . $oosDBTable['products_description] . " pd LEFT JOIN
" . $oosDBTable['specials] . " s ON pd.products_id = s.products_id
WHERE p.products_status >= '1'
AND p.products_id = pd.products_id
AND pd.products_languages_id = '" . intval($nLanguageID) . "'
ORDER BY p.products_date_added DESC";
} else {
$sql = "SELECT DISTINCT p.products_id, pd.products_name, p.products_image, p.products_tax_class_id,
p.products_price, p.products_base_price, p.products_base_unit, p.products_discount_allowed,
substring(pd.products_description, 1, 150) AS products_description,
IF(s.status, s.specials_new_products_price, NULL) AS specials_new_products_price
FROM " . $oosDBTable['products] . " p,
" . $oosDBTable['products_description] . " pd LEFT JOIN
" . $oosDBTable['specials] . " s ON pd.products_id = s.products_id,
" . $oosDBTable['products_to_categories] . " p2c,
" . $oosDBTable['categories] . " c
WHERE p.products_id = p2c.products_id
AND pd.products_id = p2c.products_id
AND pd.products_languages_id = '" . intval($nLanguageID) . "'
AND p2c.categories_id = c.categories_id
AND c.parent_id = '" . intval($new_products_category_id) . "'
AND p.products_status >= '1'
ORDER BY p.products_date_added DESC";
}
$new_products_result = $db->SelectLimit($sql, MAX_DISPLAY_NEW_PRODUCTS);
$new_products_array = array();
while ($new_products = $new_products_result->fields) {
$new_product_price = '';
$new_product_special_price = '';
$new_max_product_discount = 0;
$new_product_discount_price = '';
$new_base_product_price = '';
$new_base_product_special_price = '';
$new_special_price = '';
$new_product_price = $oCurrencies->display_price($new_products['products_price], oos_get_tax_rate($new_products['products_tax_class_id]));
$new_special_price = $new_products['specials_new_products_price];
if (oos_is_not_null($new_special_price)) {
$new_product_special_price = $oCurrencies->display_price($new_special_price, oos_get_tax_rate($new_products['products_tax_class_id]));
} else {
$new_max_product_discount = min($new_products['products_discount_allowed],$_SESSION['member]->group['discount]);
if ($new_max_product_discount != 0 ) {
$new_special_price = $new_products['products_price]*(100-$new_max_product_discount)/100;
$new_product_discount_price = $oCurrencies->display_price($new_special_price, oos_get_tax_rate($new_products['products_tax_class_id]));
}
}
if ($new_products['products_base_price] != 1) {
$new_base_product_price = $oCurrencies->display_price($new_products['products_price] * $new_products['products_base_price], oos_get_tax_rate($new_products['products_tax_class_id]));
if ($new_special_price != '') {
$new_base_product_special_price = $oCurrencies->display_price($new_special_price * $new_products['products_base_price], oos_get_tax_rate($new_products['products_tax_class_id]));
}
}
$new_products_array[] = array('products_id' => $new_products['products_id],
'products_image' => $new_products['products_image],
'products_name' => $new_products['products_name],
'products_description' => oos_remove_tags($new_products['products_description]),
'products_base_price' => $new_products['products_base_price],
'products_base_unit' => $new_products['products_base_unit],
'new_product_price' => $new_product_price,
'new_product_special_price' => $new_product_special_price,
'new_max_product_discount' => $new_max_product_discount,
'new_product_discount_price' => $new_product_discount_price,
'new_base_product_price' => $new_base_product_price,
'new_base_product_special_price' => $new_base_product_special_price,
'new_special_price' => $new_special_price);
$new_products_result->MoveNext();
}
$smarty->assign(array('block_heading_new_products' => sprintf($aLang['table_heading_new_products], strftime('%B')),
'new_products_array' => $new_products_array));
und mir dies reduzieren auf
Code: Alles auswählen
$sql = "SELECT DISTINCT p.products_id, pd.products_name, p.products_image, p.products_tax_class_id,
p.products_price, p.products_base_price, p.products_base_unit, p.products_discount_allowed,
substring(pd.products_description, 1, 150) AS products_description,
IF(s.status, s.specials_new_products_price, NULL) AS specials_new_products_price
FROM " . $oosDBTable['products] . " p,
" . $oosDBTable['products_description] . " pd LEFT JOIN
" . $oosDBTable['specials] . " s ON pd.products_id = s.products_id,
" . $oosDBTable['products_to_categories] . " p2c,
" . $oosDBTable['categories] . " c
WHERE p.products_id = p2c.products_id
AND pd.products_id = p2c.products_id
AND pd.products_languages_id = '" . intval($nLanguageID) . "'
AND p2c.categories_id = c.categories_id
AND c.parent_id = '0'
AND p.products_status >= '1'
ORDER BY p.products_date_added DESC";
}
$new_products_result = $db->SelectLimit($sql, MAX_DISPLAY_NEW_PRODUCTS);
$new_products_array = array();
while ($new_products = $new_products_result->fields) {
$new_product_price = '';
$new_product_special_price = '';
$new_max_product_discount = 0;
$new_product_discount_price = '';
$new_base_product_price = '';
$new_base_product_special_price = '';
$new_special_price = '';
$new_product_price = $oCurrencies->display_price($new_products['products_price], oos_get_tax_rate($new_products['products_tax_class_id]));
$new_special_price = $new_products['specials_new_products_price];
if (oos_is_not_null($new_special_price)) {
$new_product_special_price = $oCurrencies->display_price($new_special_price, oos_get_tax_rate($new_products['products_tax_class_id]));
} else {
$new_max_product_discount = min($new_products['products_discount_allowed],$_SESSION['member]->group['discount]);
if ($new_max_product_discount != 0 ) {
$new_special_price = $new_products['products_price]*(100-$new_max_product_discount)/100;
$new_product_discount_price = $oCurrencies->display_price($new_special_price, oos_get_tax_rate($new_products['products_tax_class_id]));
}
}
if ($new_products['products_base_price] != 1) {
$new_base_product_price = $oCurrencies->display_price($new_products['products_price] * $new_products['products_base_price], oos_get_tax_rate($new_products['products_tax_class_id]));
if ($new_special_price != '') {
$new_base_product_special_price = $oCurrencies->display_price($new_special_price * $new_products['products_base_price], oos_get_tax_rate($new_products['products_tax_class_id]));
}
}
$new_products_array[] = array('products_id' => $new_products['products_id],
'products_image' => $new_products['products_image],
'products_name' => $new_products['products_name],
'products_description' => oos_remove_tags($new_products['products_description]),
'products_base_price' => $new_products['products_base_price],
'products_base_unit' => $new_products['products_base_unit],
'new_product_price' => $new_product_price,
'new_product_special_price' => $new_product_special_price,
'new_max_product_discount' => $new_max_product_discount,
'new_product_discount_price' => $new_product_discount_price,
'new_base_product_price' => $new_base_product_price,
'new_base_product_special_price' => $new_base_product_special_price,
'new_special_price' => $new_special_price);
$new_products_result->MoveNext();
}
$smarty->assign(array('block_heading_new_products' => sprintf($aLang['table_heading_new_products], strftime('%B')),
'new_products_array' => $new_products_array));
das Template
~/neue produkte
als coneten block nach
~/bloks speichern ud auf die tabellen zellenverzichten.
hth
r23 (ich halt mich auch für bescheuert.
~/neue produkte
Code: Alles auswählen
{section name=i loop=$new_products_array}
{if $smarty.section.i.first}
<tr>
<td><br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19" class="block_head_background"><img src="{$theme_image}/table_head_arrow.gif" alt=" " width="21" height="19" /></td>
<td width="100%" class="block_head_background">{$block_heading_new_products}</td>
<td width="5" class="block_head_background"><img src="{$theme_image}/table_head_right.gif" alt=" " width="5" height="19" /></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr>
{/if}
<td width="50%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="left" width="{$smarty.const.SMALL_IMAGE_WIDTH}" class="smallText"><a href="{product_info_link products_id=$new_products_array[i].products_id}">{small_product_image image=$new_products_array[i].products_image alt=$new_products_array[i].products_name|strip_tags}</a></td>
<td><img src="{$theme_image}/trans.gif" border="0" alt=" " width="5" height="1" /></td>
<td valign="top" class="smallText"><a href="{product_info_link products_id=$new_products_array[i].products_id}"><b>{$new_products_array[i].products_name}</b></a><br />
<br />{$new_products_array[i].products_description|truncate:120:" [...]":false|close_tags}<br />
</tr>
<tr>
<td valign="bottom" class="smallText" nowrap="nowrap">
{if (!empty($new_products_array[i].new_product_special_price))}
<s>{$new_products_array[i].new_product_price}</s><br />
<span class="special_price">{$new_products_array[i].new_product_special_price|price2image:true}</span>
{else}
{if $new_products_array[i].new_max_product_discount != 0}
<s>{$new_products_array[i].new_product_price}</s> -{$new_products_array[i].new_max_product_discount}%<br />
<span class="discount_price">{$new_products_array[i].new_product_discount_price|price2image:true}</span>
{else}
{$new_products_array[i].new_product_price|price2image}
{/if}
{/if}
</td>
<td><img src="{$theme_image}/trans.gif" border="0" alt=" " width="5" height="1" /></td>
<td valign="bottom" align="right" >{if $smarty.session.member->group.show_price eq 1 }<a href="{html_href_link modul=$main_page file=$page_file action=buy_now products_id=$new_products_array[i].products_id}">{html_image_button image="hp_buy.gif" alt=$lang.image_button_in_cart}</a>{/if}
<img src="{$theme_image}/trans.gif" border="0" alt=" " width="5" height="1" />
<a href="{product_info_link products_id=$new_products_array[i].products_id}">{html_image_button image="hp_more.gif" alt=$lang.image_button_hp_more}</a>
</td>
</tr>
<tr>
<td valign="top" colspan="3" class="smallText">
{if $new_products_array[i].products_base_price != 1}
<span class="smallText">{$lang.text_products_base_price}: </span>
{if (!empty($new_products_array[i].new_special_price))}
<span class="special_base_price">{$new_products_array[i].products_base_unit} = {$new_products_array[i].new_base_product_special_price}</span></s><br />
{else}
{if $new_products_array[i].new_max_product_discount != 0}
<span class="discount_base_price">{$new_products_array[i].products_base_unit} = {$new_products_array[i].new_base_product_special_price}</span></s><br />
{else}
<span class="base_price">{$new_products_array[i].products_base_unit} = {$new_products_array[i].new_base_product_price}</span><br />
{/if}
{/if}
{/if}
<span class="pangv">{$pangv}</span><br />
</td>
</tr>
</table></td>
{if $smarty.section.i.rownum is even}
</tr>
<tr>
{else}
<td><img src="{$theme_image}/pg.gif" border="0" alt=" " width="1" height="150" /></td>
{/if}
{if $smarty.section.i.last}
</tr>
</table>
</td>
</tr>
{/if}
{/section}
~/bloks speichern ud auf die tabellen zellenverzichten.
Code: Alles auswählen
{section name=i loop=$new_products_array}
<a href="{product_info_link products_id=$new_products_array[i].products_id}">{small_product_image image=$new_products_array[i].products_image alt=$new_products_array[i].products_name|strip_tags}</a>
<a href="{product_info_link products_id=$new_products_array[i].products_id}"><b>{$new_products_array[i].products_name}</b></a><br />
<br />{$new_products_array[i].products_description|truncate:120:" [...]":false|close_tags}<br />
usw.
{/section}
r23 (ich halt mich auch für bescheuert.
Ich habs nicht hinbekommen. Mit dem allgemeinen new_products_array bekomme ich ja eine ausgabe. Wechsel ich jetzt nun auf die Produktseite, so sind die links dann weg!
Zuletzt geändert von drkey am 27.05.2009, 20:08, insgesamt 1-mal geändert.