Jump to content
xt:Commerce Community Forum

Whats New Box


Recommended Posts

Hallo NG

wie ist es mir m?glich in der Box whats_new oder whats_new2

mehrere zuletzt angelegte neue Produkte anzeigen zu lassen. Als

Standard wird jetzt ja nur ein neu angelegtes Produkt angezeigt. Ich

w?rde aber gerne auf der Startseite zwei oder drei anzeigen lassen.

Was f?r Code/Datei muss ge?ndert werden um dies zu Realisieren?

Vielen Dank.

Gru?

Link to comment
Share on other sites

HAllo Bigfoot.

es gibt, soweit ich es verstanden habe, zwe "Whats new" routinen. Zum einen kann man in der "Mitte des Contents", also z.B. unter dem "Willkommen" das Module "new_products" einbinden. Hier werden dann wohl alle die Produkte angezeigt, die in die Kategorie "TOP" einsortiert werden. Das finde ich aber reichlich umst?ndlich, da ich dauernd Artikel umsortieren, bzw. kopieren muss.

Daher habe ich die Box WHATSNEW entsprechend umgebaut. Die holt sich aus den neuen Artikel eine definierbare Zahl an zuf?lligen Eintr?gen (das l??t sich aber leicht ?ndern, wenn man z.B. nur die "neuesten" 10 oder so haben will.

Folgende Dateien habe ich ge?ndert:

YOURTEMPLATE/SOURCE/BOXES/WHATS_NEW.PHP


	$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');


	# 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_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 = '';

 if ($whats_new['products_image']) $image = DIR_WS_THUMBNAIL_IMAGES . $whats_new['products_image'];

 $tmp_content[] = array(

          'ID' => xtc_row_number_format($rows),

          'NAME' => xtc_get_products_name($whats_new['products_id']),

          'IMAGE' => $image,

          'PRICE'=> xtc_get_products_price($whats_new['products_id'],$price_special = 1,$quantity = 1),

          'LINK'=> xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $whats_new['products_id']));


	}


	# 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.'/boxes/box_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.'/boxes/box_whatsnew.html',$cache_id);

	}


  $smarty->assign('box_WHATSNEW',$box_whats_new);

Als zweites braucht man nat?rlich ein passendes SMARTY-HTML-File... die kann man dann an seine "Designw?nsche" anpassen. In diesem Fall wird eine zweispaltige Liste aufgebaut: YOURTEMPLATE/BOXES/BOX_WHATSNEW.HTML

{config_load file="$language/lang_$language.conf" section="boxes"}

<table width="100%" border="0" cellpadding="0" cellspacing="0">

	<tr>

 <td class="infoBoxHeading">{#heading_whatsnew#}</td>

	</tr>

</table>

<br/>

<br/>


<table width="100%" border="0" cellspacing="0" cellpadding="0">

	<tr>

 {foreach name=aussen item=box_data from=$box_content}

 	{php}

  $col++;

 	{/php}

 	<td class="main">

  <div align="left">

  <table width="100%" border="0" cellpadding="0" cellspacing="4">

  	<tr>

   <td width="1" rowspan="2" >{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>

   <td class="main">

   	<strong>{$box_data.PRICE}<br>

   </td>

  	</tr>

  </table>

  </div>

 	</td>

 	{php}

  if ($col>=2)

  {

  	$col=0;

  	echo '</tr><tr>';

  }

 	{/php}

 {/foreach}

	</tr>

</table>

e voila... und schon klappts auch mit den neuen Produkten....

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

Hallo,

passt zwar nicht ganz dazu, aber vielleicht hilft es jemand weiter. Ich habe mir die whats_new_box so angepasst, dass ich Sie über die products_id auswerten kann. Da ich kein PHP-Experte bin hoffe ich jetzt nicht, dass die Leute über mich herfallen. Das ganze ist für das 3.4SP1 und wie immer vorher ein Backup machen. Es sind lediglich die IDs in das input array einzutragen:

/templates/templates/source/boxes/whats_new.php


<?php

/* -----------------------------------------------------------------------------------------
$Id: whats_new.php 1292 2005-10-07 16:10:55Z mz $

XT-Commerce - community made shopping
http://www.xt-commerce.com

Copyright (c) 2003 XT-Commerce
-----------------------------------------------------------------------------------------
based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommerce(whats_new.php,v 1.31 2003/02/10); www.oscommerce.com
(c) 2003 nextcommerce (whats_new.php,v 1.12 2003/08/21); www.nextcommerce.org

Released under the GNU General Public License
-----------------------------------------------------------------------------------------
Third Party contributions:
Enable_Disable_Categories 1.3 Autor: Mikel Williams | [email protected]

Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
$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');

# 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 ";
}

/* Möglichkeit die Produkte zu begrenzen
a) den SQL-Select ändern auf die gewünschte product id z.B. and p.products_id = 231 oder Angabe einer Variabel
Ein Array mit den Produkt-IDs füttern die in der Box angezeigt werden sollen und über array_rand auswerten lassen
*/

$input = array("230", "231", "55", "35");
$rand_keys = array_rand($input, 2);
$produkte = ($input[$rand_keys[0]]);
//echo($produkte);


# create database query
$strSQL = "select distinct
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 = ".$produkte."
and c.categories_id = p2c.categories_id
".$group_check."
and c.categories_status=1 order by
p.products_date_added desc limit 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 = '';
if ($whats_new['products_image']) $image = DIR_WS_THUMBNAIL_IMAGES . $whats_new['products_image'];
$tmp_content[] = array(
'ID' => xtc_row_number_format($rows),
'NAME' => xtc_get_products_name($whats_new['products_id']),
'IMAGE' => $image,
// 'PRICE'=> xtc_get_products_price($whats_new['products_id'],$price_special = 1,$quantity = 1),
'LINK'=> xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $whats_new['products_id']));

}

/* # 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_content = $tmp_content;

$box_smarty->assign('box_content', $tmp_content);
// $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.'/boxes/box_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.'/boxes/box_whatsnew.html',$cache_id);
}
$smarty->assign('box_WHATSNEW',$box_whats_new);
?>

[/php]

und

/templates/templaes/boxes/box_whatsnew.html

[php]

{config_load file="$language/lang_$language.conf" section="boxes"}
<table width="210" border="0" cellpadding="0" cellspacing="0">
{foreach name=aussen item=box_data from=$box_content}
{php}
$col++;
{/php}
<tr>
<td height="22" class="box_oben_neuimshop"><a href="{$NEW_LINK}"><img src="{$tpl_path}img/icon_more.gif" alt="" /></a></td>
</tr>
<tr>
<td align="center" valign="middle" class="box_mitteweiss"> {if $box_data.IMAGE}<a href="{$box_data.LINK}"><img src="{$box_data.IMAGE}" border="0"></a>{/if}<br />
<a href="{$box_data.LINK}">{$box_data.NAME}</a></strong><br />
{$box_data.PRICE}<br /></td>
</tr>
<tr>
<td height="5" class="box_unten"></td>
</tr>
<tr> {php}
if ($col>=0)
{
$col=0;
echo '</tr>';
}
{/php}
{/foreach}
</tr>
</table>

gruesse

olli

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...