Jump to content



Latest News: (loading..)

PupStar

Member Since 19 Jul 2009
OFFLINE Last Active Yesterday, 06:35 PM
*****

Topics I've Started

Reviews pagination using jQuery

09 June 2013 - 12:56 PM

Afternoon guys,

I am struggling with this little problem and its really starting to bug me now.

I am using the following code to display reviews in a tab on my product_info page

<?php
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_REVIEWS);
$reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 200) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and r.reviews_status = 1 and r.approved = '1' order by r.reviews_id desc";
$reviews_split = new splitPageResults($reviews_query_raw, '3');
if ($reviews_split->number_of_rows > 2) {
$reviews_query = tep_db_query($reviews_split->sql_query);
while ($reviews = tep_db_fetch_array($reviews_query)) {
?>
	 <div style="padding:4px;"></div>
	 <div style="padding:2px;">
		 <?php echo tep_date_long($reviews['date_added']); ?>
	 </div>
	 <div style="padding:2px;">
		 <strong><?php echo tep_output_string_protected($reviews['customers_name']) . '</strong>&nbsp;&nbsp;' . TEXT_STARS_RATING . tep_image(DIR_WS_IMAGES . 'stars_' . $reviews['reviews_rating'] . '.png', sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])); ?>
	 </div>
	 <div style="padding:2px; font-style: italic;">
		 <?php echo tep_output_string_protected($reviews['reviews_text']);?>
	 </div>
	 <div class="line-separator"></div>
<?php
}
} else {
?>
<div>
	 <br /><?php echo TEXT_NO_REVIEWS; ?>
</div>
<div>
	 <?php echo TEXT_REVIEW_BUTTON . '&nbsp;' . tep_draw_button(IMAGE_BUTTON_WRITE_REVIEW, 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()), 'primary'); ?>
</div>
<?php
}
if ($reviews_split->number_of_rows > 2) {
?>
<br />
<div class="contentText" style="position:absolute; top:660px; right:410px;">
<?php echo $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info'))); ?>
</div>
<br /><br />
<div class="buttonSet" style="float: right;">
<span class="buttonAction"><?php echo TEXT_REVIEW_BUTTON . '&nbsp;' . tep_draw_button(IMAGE_BUTTON_WRITE_REVIEW, 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()), 'primary'); ?></span>
</div>
<?php
}
?>
</div>
</div>

The issue I have is that when I click 'page 2' of the reviews it reloads the page with the second page of reviews but does not show the previous page link. Also when the page reloads it defaults back to the first tab.

Ideally I would like to stop the page reload and load the reviews using jQuery. Is this possible and does anyone have a nice bit of script that would do the job???

Thanks for the help

Mark

Qty box on product_info page error checking

19 May 2013 - 01:17 PM

Hi Guys,

I am trying to figure out a way of adding some error checking to the quantity box I have on the product info page.

Maybe its easier done than I am thinking but being full of a head cold today is making things blurry urgh

So far I have this

<script type="text/javascript">
function cartqty(form) {
	 if (form.cartqty.value == "" ) {
		 alert("<?php echo BOX_QUANTITY_ERROR; ?>")
		 form.cartqty.focus();
		 return false;
		 }
	 else {
		 // form.submit()
		 return true;
		 }
}
</script>

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'), 'onsubmit="return cartqty(this);"'); ?>

Maybe I am going about this wrong way but any advice would be appreciated.

Thanks

Mark

Watermarking Images

13 May 2013 - 08:59 PM

Does anyone know of an easy to integrate watermarking script either using pure php or jquery?

Thanks

Mark

Code modification help

27 April 2013 - 07:53 PM

Hi Guys,

Attached File  screenshot_parts.jpg   57.86K   19 downloads

I need the following code modded to only show products from the selected category.

If you look at the title it is 'Air Filter & Shroud' however the code below is listing all products in all categories.

This maybe a simple fix but for the life of me can not get my head around it.

Any help would be appreciated.

Thanks

Mark

<?php
/*
Parts Filter
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
$printer_category_id = $_REQUEST['printer_category_id'];
$parent_id = $_REQUEST['parent_id'];
if(isset($_REQUEST['printer_category_id'])&&($_REQUEST['printer_category_id']!=''))
{
$vehcat_query = tep_db_query("SELECT * FROM ".TABLE_PRINTER_CATEGORY." WHERE printer_category_id = '".$_REQUEST['printer_category_id']."'");
$vehcat_row = tep_db_fetch_array($vehcat_query);
}
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
// Ultimate SEO URLs v2.1
// If the action will affect the cache entries
if ( preg_match("(insert|update|setflag)", $action) ) include_once('includes/reset_seo_cache.php');
if (tep_not_null($action)) {
switch ($action) {
case 'assign_products':
	 $productids = "";
	 $mediacat_ref_no = "";
	 $mediacat_quantity = "";
$selvalarray = array();
$pagearray = array();
$remproductarray = array();
$products_query_raw = 'select p.products_id, products_mediacat_quantity, products_mediacat_ref_no from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_name asc';
$products_query = tep_db_query($products_query_raw);
$products_split = new splitPageResults($_REQUEST['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows);
$products_query = tep_db_query($products_query_raw);
while ($products = tep_db_fetch_array($products_query))
{
array_push($pagearray,$products['products_id']);
}
if(isset($HTTP_POST_VARS['productids']))
{
foreach($HTTP_POST_VARS['productids'] as $val)
{
if($val!='')
{
	 array_push($selvalarray,$val);
	 $productids .= $val.",";
}
}
}
foreach($pagearray as $val)
{
if(!in_array($val,$selvalarray))
{
array_push($remproductarray,$val);
}
}
$olderdata = $vehcat_row['productids'];
$finaldata = "";
if($olderdata!='')
{
$oldprodarray = explode(",",$olderdata);
foreach($oldprodarray as $val)
{
	 if(!in_array($val,$remproductarray))
{
	 if(!in_array($val,$selvalarray))
	 {
	 array_push($selvalarray,$val);
	 }
}
}
$productids = "";
foreach($selvalarray as $val)
{
	 $productids .= $val.",";
}
$finaldata = substr($productids,0,-1);
}
else
{
$finaldata = substr($productids,0,-1);
}
$update_sql_data = array('productids' => $finaldata);
	 tep_db_perform(TABLE_PRINTER_CATEGORY, $update_sql_data, 'update', "printer_category_id = '" . (int)$printer_category_id . "'");
	 tep_redirect(tep_href_link(FILENAME_PRINTER_PRODUCTS, 'parent_id=' . $parent_id.'&printer_category_id='.$printer_category_id.'&page='.$_REQUEST['page'] ));
	 break;
}
}
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
require(DIR_WS_INCLUDES . 'template_top.php');
$vehcat_query = tep_db_query("SELECT * FROM ".TABLE_PRINTER_CATEGORY." WHERE printer_category_id = '".$_REQUEST['printer_category_id']."'");
$vehcat_row = tep_db_fetch_array($vehcat_query);
$prodidsarr = explode(",",$vehcat_row['productids']);
?>
<table border="0" align="center" width="100%" cellspacing="2" cellpadding="2">
<tr>
<!-- body_text //-->
<td width="100%" valign="top">
	 <table border="0" width="100%" cellspacing="4" cellpadding="0">
	 <tr>
		 <td>
		 <table border="0" width="100%" cellspacing="1" cellpadding="1">
			 <tr>
			 <td class="pageHeading"><?php echo HEADING_TITLE." ".$vehcat_row['category_name']; ?></td>
			 <td class="pageHeading" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_PRINTER_CATEGORY, 'printer_category_id='.$printer_category_id.'&parent_id=' . $parent_id ) . '">Back To Category List</a>';?> </td>
				 <?php echo tep_draw_form('categorie', FILENAME_PRINTER_PRODUCTS, '', 'get'); echo tep_draw_hidden_field( 'row_by_page', $row_by_page);?>
				 <td class="smallText" align="right" valign="top">
				 </td></form>
			 <td align="right"></td>
			 </tr>
		 </table>
		 </td>
	 </tr>
	 <tr>
		 <td>
		 <table border="0" width="100%" cellspacing="0" cellpadding="0">
		 <tr>
			 <td valign="top">
			 <?php echo tep_draw_form('printerfilter', FILENAME_PRINTER_PRODUCTS, 'action=assign_products&parent_id='.$parent_id.'&printer_category_id='.$printer_category_id.'&page='.$_REQUEST['page'], 'post');?>
			 <table border="0" width="100%" cellspacing="0" cellpadding="0">
				 <tr class="dataTableHeadingRow">
				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCT_ID; ?></td>
				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCT_MODEL;?></td>
				 <td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_PRODUCT_NAME;?></td>
				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCT_CATEGORY_NAME;?></td>
				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCT_MEDIACAT_REF_NO;?></td>
				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCT_MEDIACAT_QUANTITY;?></td>
				 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_PRODUCT_SELECT;?></td>
				 </tr>
<?php
	 $products_query_raw = 'select distinct p.products_id, p.products_model, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_id, p.products_mediacat_ref_no, p.products_mediacat_quantity from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by pd.products_id asc';
	 $products_split = new splitPageResults($_REQUEST['page'], '20', $products_query_raw, $products_query_numrows);
	 $products_query = tep_db_query($products_query_raw);
	 while ($products = tep_db_fetch_array($products_query))
	 {
if ( strpos( tep_get_product_path($products['products_id']), "_" ) == FALSE ) {
$result = tep_get_category_name( tep_get_product_path( $products['products_id'] ) );
} else {
$pieces = explode("_", tep_get_product_path($products['products_id']) );
	 $categories_array = array();
	 $categories_array = tep_get_categories( $categories_array, $pieces[0] );
	 for ( $j = 0 ; $j < count($categories_array) ; $j++ ) {
	 if ( $categories_array[ $j ]['id'] == $pieces[ count( $pieces ) - 1 ] ) {
	 $result = $categories_array[ $j ][ 'text' ];
	 break;
	 }
}
}
?>
				 <tr>
				 <td class="dataTableContentBorder" valign="middle" align="center"><?php echo $products['products_id'];?></td>
				 <td class="dataTableContentBorder" align="center" valign="middle"><?php echo $products['products_model'];?></td>
				 <td class="dataTableContentBorder" valign="middle"><?php echo $products['products_name'];?></td>
				 <td class="dataTableContentBorder" valign="middle" align="center"><?php echo $result; ?></td>
				 <td class="dataTableContentBorder" valign="middle" align="center"><?php echo $products['products_mediacat_ref_no'];?></td>
				 <td class="dataTableContentBorder" valign="middle" align="center"><?php echo $products['products_mediacat_quantity'];?></td>
				 <td class="dataTableContentBorder" valign="middle" align="center"><input type="checkbox" name="productids[]" value="<?php echo $products['products_id'];?>" <?php if(in_array($products['products_id'],$prodidsarr)) echo 'checked';?> /></td>
				 </tr>
<?php
	 } // End of while
?>
<tr>
<td class="smallText" align="right" colspan="7" style="padding: 12px"><div class="assign_parts">
	 <?php echo tep_draw_button(IMAGE_ASSIGN_PARTS, null, null, 'primary'); ?></div>
</td>
</tr>
			 </table></form>
			 </td>
		 </tr>
		 <tr>
<td ><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
	 <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_REQUEST['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
	 <td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_REQUEST['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID', 'action'))); ?></td>
</tr>
</table></td>
</tr>
	 </table>
</td>
	 </tr>
</table>
</td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Tabbed Category Box

18 March 2013 - 06:50 PM

I have combined the category and manufacturers boxes with a tabbed display.

I am however not entirely satisfied with the tabs/box header and have been fiddling with it for quite a while now and can not achieve a decent look.]

The code is

$data = '<div id="tabs_box" style="padding: 0px;">' .
		 '<ul>' .
			 '<li><div class="ui-widget infoBoxHeading"><a href="#tabs-1">' . MODULE_BOXES_CATEGORIES_BOX_TITLE . '</a></div></li>' .
			 '<li><div class="ui-widget infoBoxHeading"><a href="#tabs-2">' . MODULE_BOXES_MANUFACTURERS_BOX_TITLE . '</a></div></li>' .
		 '</ul>' .
		 '<div class="ui-widget-content-cat ui-corner-bottom infoBoxContainer" id="tabs-1">' .
		 '' . $categories_string . '' .
		 '</div>' .
		 '<div class="infoBoxContainer" id="tabs-2">' .
		 '' . $manufacturers_content . '' .
		 '</div>' .
		 '</div>' .
		 '<script>' .
		 ' $(function(){' .
		 '		 $("#tabs_box").tabs();' .
		 ' });' .
		 '</script>';
	 return $data;
}

I have attached screenshots of how it looks.

Can I throw this open to suggestions / improvements please guys.

Thanks

Mark