Jump to content


Corporate Sponsors


Latest News: (loading..)

data2700

Member Since 28 Dec 2004
Offline Last Active Oct 13 2011, 12:28
-----

Posts I've Made

In Topic: Random Catagorys Image

16 September 2011, 13:59

Hi, Im wondering how to add the ability to select the random image only from active products? I think it can be done by modifying $produkt_query to include only products_status with a value of 1 , but Im unsure of the MySql syntax. Here is the entire file from the contribution, can anyone help ?

Here is the specific query I was thinking needs to be modified.
$produkt_query = tep_db_query( "select p.products_image as img from products p ".
	  "LEFT OUTER JOIN products_to_categories ptc ON ".
	  "p.products_id = ptc.products_id ".
	  "WHERE LENGTH(p.products_image) > 0 ".
	  "AND ptc.categories_id = ".$category_id);

and the next piece is the entire contribution, in case there is more to this than I realize.

Thank you

<?
/***********************************************/
/*    Random Category Images v 1.3  /
/*    coded    /
/*		 by Bo Biene   /
/***********************************************/
define('EMPTY_CAT_IMAGE', 'empty.gif');

function get_random_cat_image($category_id, $count = 0)
{
srand ((double)microtime()*1000000);
$retun_val;
if($category_id > 0 && tep_count_products_in_category_without_sub($category_id) > 0 && $count < 10)
{
 
  $randInt = rand(1,10);
  $randStart = $randInt -1;
  $produkt_query = tep_db_query( "select p.products_image as img from products p ".
	  "LEFT OUTER JOIN products_to_categories ptc ON ".
	  "p.products_id = ptc.products_id ".
	  "WHERE LENGTH(p.products_image) > 0 ".
	  "AND ptc.categories_id = ".$category_id);
 
  while($result = tep_db_fetch_array($produkt_query))
  {
   $retun_val = $result['img'];
   if(rand(1,10) > 8)
    break;
  }
   
  if(!(tep_not_null($retun_val)) &&  tep_has_category_subcategories($category_id))
  {
   $retun_val = get_random_cat_image_from_child($category_id,$count);
  }
 
}
else if($category_id > 0 && tep_has_category_subcategories($category_id) && $count < 10)
{
 
  $retun_val = get_random_cat_image_from_child($category_id,$count);
}
else
{
  $retun_val = EMPTY_CAT_IMAGE;
}
 
return $retun_val;
}
function get_random_cat_image_from_child($category_id,$count = 0)
{
$retun_val;
$category_query = tep_db_query("select categories_id as ID from ". TABLE_CATEGORIES ." WHERE parent_id = ". $category_id ." LIMIT 0,". rand(1,10) );
while($ids = tep_db_fetch_array($category_query))
{
  $id = $ids['ID'];
 
  $retun_val = get_random_cat_image($id, $count++);
  if((tep_not_null($retun_val)) && $retun_val != EMPTY_CAT_IMAGE)
   break;
}
return $retun_val;
}
//Changed from osCommerce
  function tep_count_products_in_category_without_sub($category_id, $include_inactive = false)
  {
    $products_count = 0;
    if ($include_inactive == true) {
	  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'");
    } else {
	  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'");
    }
    $products = tep_db_fetch_array($products_query);
    return $products['total'];
}
   
?>

In Topic: HOW TO: Facebook "Like" Button in OSCommerce

23 February 2011, 14:50

View Postsurfinagain, on 04 December 2010, 23:51, said:

i was able to resolve the issue. it was an code location issue. not sure why it mattered to IE8 but moved it and it's working now in all browsers. thanks for the code!


Can you post where in the code you located the FB code? I am still not able to get it to display in IE8. UPDATED

thanks to surfinagain I kept poking around and trying it in different locations to get it to work in IE8. My site is pretty modified, but the code worked well for me when place in these lines


if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_id'] . ']</span>';
} else {
$products_name = $product_info['products_name'];
}
?>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
<td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
</tr>

</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td class="main">



<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="<?php echo HTTP_SERVER . $_SERVER['REQUEST_URI']; ?>" show_faces="false" align="right" width="350"></fb:like>


<?php
if (tep_not_null($product_info['products_image'])) {
?>
<table border="0" cellspacing="0" cellpadding="2" align="right">
<tr>
<td align="center" class="smallText">

In Topic: HOW TO: Facebook "Like" Button in OSCommerce

23 February 2011, 12:01

View Postsmickyb, on 01 December 2010, 12:34, said:

aaahhh - what a waste!

Guys, simply go to your product_info.php file (parent folder) and try adding the following:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="<?php echo HTTP_SERVER . $_SERVER['REQUEST_URI']; ?>" show_faces="false" align="right" width="350"></fb:like>

This will quirey the server for the product URL and in turn use the full url as the link on FB to your site.
The 'like' box within your product page will also use a 1+1+1 etc method, as more people like the product the box will add each.

I recommend the code be added in/around that of the product part number section. Looks good and seems to fit well.

Dont see any need to change any of the other code, and this has been tested in Win Enviro's - running IE, Firefox as well as Linux OS running Chrome and Firefox, also works on the Galaxy Sgoogle browser!

This is great! Are there any disadvantages to doing it this way? For example, with the other methods that require a facebook developer ID are you able to track the number of likes by product or something like that which you perhaps cannot do using this method? This method is really easy and looks great on my products listing.

Enjoy!
:thumbsup:

In Topic: [Contribution] FAN - Faster Admin Navigation

17 February 2011, 14:46

Hi forum readers!

I'm trying to install this contribution but my site has been modified so I'm not quite sure how to combine this instruction:
Before:

onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '\'"

Add:

ondblclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product') . '\'"


Into this bit of modified code:

if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id) ) {
echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '\'">' . "\n";
} else {
echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";

I have tried, but I have limited php skills. Can anyone help?

Thanks in advance!


}