Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

  • Index
  •  » ClickCartPro 6
  •  » Dynamic Category Images - A Simple Solution With No PHP Rotate Script

#1 02-06-2011 23:59:21

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Dynamic Category Images - A Simple Solution With No PHP Rotate Script

This probably isn't recommended and is highly likely to do something 'orrible to something, but it has yet to kill our webstore so...

First off you need to find your  or  file...

...then find the following code block:

Code:

if (($catshow['catimg']) && ($catshow['catimg'] != 'none.png')) {

     $imgname  = $catshow['catimg'];
     if (empty($imgname)) {$imgname = 'none.png';}

     $imgwidth = $this->globals('khxc_settings.' . $app . '.imgsizecat');
     $imgurl   = 'media/' . $app . '/cat/' . $imgname;

     $imgtag   = '<img src="' . $imgurl . '" ';
     if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';}
     $imgtag  .= 'alt="' . $catname . '" />';

...and (making amendments where necessary) change it to:


Code:

if (($catshow['catimg']) && ($catshow['catimg'] != 'none.png') && ($catdisp == '1')) {

     if (preg_match('/Litez_.*_Bitz/',$catid)) {

          include '/var/wetsocks.php';

          mysql_pconnect("$s", "$u", "$p") or die(mysql_error());
          mysql_select_db("$d") or die(mysql_error());

          // Edit this number to however many links you want displaying
          $num_displayed = 1;

          // Select random rows from the database
          $result = mysql_query ("SELECT imgsm FROM gbu0_prod WHERE prodnum LIKE '$catid' ORDER BY RAND() LIMIT $num_displayed") or 
          die(mysql_error());

          // For all the rows that you selected
          while($row = mysql_fetch_array($result )) {

          // Display them to the screen...
          $imgname = $row['imgsm'];

          } // End of while statement.

          if (empty($imgname)) {$imgname = 'none.png';}

          $imgwidth = $this->globals('khxc_settings.' . $app . '.imgsizecat');
          $imgurl   = 'media/' . $app . '/prodsm/' . $imgname;

          $imgtag   = '<img src="' . $imgurl . '" ';
          if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';}
          $imgtag  .= 'alt="' . $catname . '" />';

     } else {

          $imgname = $catshow['catimg'];

          if (empty($imgname)) {$imgname = 'none.png';}

          $imgwidth = $this->globals('khxc_settings.' . $app . '.imgsizecat');
          $imgurl   = 'media/' . $app . '/cat/' . $imgname;

          $imgtag   = '<img src="' . $imgurl . '" ';
          if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';}
          $imgtag  .= 'alt="' . $catname . '" />';

     } // End of if statement.

You might also need to add some of the following to the variables at the top of the file, such as:


Code:

$app        = $this->globals('khxc_display.app');
$eol        = $this->globals('khxc.eol');
$catshow    = $this->globals('ecom.cat_catshow');
$catname    = $this->xhtml_encode($catshow['name']);
$catid      = $catshow['id'];
$catdisp    = $catshow['descdisplay'];
$xcat       = $catshow['xcat'];

Be careful modifying the  statement. - It normally functions as a conditional (on or off / true or false), and matching actual words or the like can be a major problem.  There is also  (which, confusingly) appears to have exactly the same functionality as .

You will also need your very own .

The recipe is simple. - Just create a file, give it a .php file extension, and then enter something like the following (using your own database name, username, password, etc.):


Code:

<?php

$d = 'smouldering_footwear';
$u = 'cheesey';
$p = 'trainers';
$s = 'localhost';

?>

If everything works, and your webstore is still functioning, you now have the means to make the small image for all the products within a given catagory be randomly selected for display on any category pages set to display both image and description.  Further, set as the above script is, you can match a whole range of like named categories (in our case Litez_Lite_Bitz, Litez_Kidz_Bitz, Litez_Heavi_Bitz, and Litez_Weird_Bitz) all with the same script. - Much less hassle than trying to implement rotate scripts (which, yes, do work. - You can actually enter scripts into the image name boxes and make them run).

Last edited by Design_Wholesale (02-07-2011 22:51:16)

Offline

 
  • Index
  •  » ClickCartPro 6
  •  » Dynamic Category Images - A Simple Solution With No PHP Rotate Script

Board footer