Forums / Templates, Stylesheets, Page Layout / Adding "fake" product or category images to make up numbers

Adding "fake" product or category images to make up numbers

Locked

Started by more_solutions on 7 Jun 2006, 10:03 AM · Views: 2,148

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
7 Jun 2006, 10:03 AM
#1
more_solutions avatar

more_solutions

New Zenner

Join Date:
May 2006
Posts:
23
Plugin Contributions:
0

Adding "fake" product or category images to make up numbers

I have a Zen site which shows products/categories in three columns on the product/category listings pages.

Therefore, if I have (say) 10 products, I get one column with four products and two columns with three products.

What I want to do is insert randomly into that listing two new images so that I end up with three columns of four "products". Those new images might say something like "click any image to view product information" or "welcome to my shop, please buy something!" (you get the idea).

Ideally I could make these links to other pages or not depending on what I was trying to do. Eg the above wouldn't be links anywhere, but I might have a "Sale now on" image which linked to a sale category.

I haven't found anything along these lines so I'm ready to get my PHP hands dirty. Where would I start?

(I think I picked the right forum; my motive is certainly just to balance the page layout. Point me elsewhere if necessary!)

4 Jul 2006, 3:11 PM
#2
more_solutions avatar

more_solutions

New Zenner

Join Date:
May 2006
Posts:
23
Plugin Contributions:
0

Re: Adding "fake" product or category images to make up numbers

more-solutions:

What I want to do is insert randomly into that listing two new images so that I end up with three columns of four "products". Those new images might say something like "click any image to view product information" or "welcome to my shop, please buy something!" (you get the idea).

OK, so there's a complete lack of interest here for this!

I have achieved what I set out to do with products, although with categories its a little harder. In case anyone is interested, what you need to do is:

  1. Create a file defining the image/text/html to use as a dummy, eg ~/includes/languages/english/extra_definitions/product_dummy_items.php:
<?php
// defined as an image, text or a combination
define('TEXT_PRODUCT_DUMMY_PRODUCT', zen_image(DIR_WS_TEMPLATE_IMAGES . 'dummyproduct.gif', 'Welcome to my shop!'));    
?>
  1. Add some code to ~/includes/modules/product_listing.php to insert the dummy images, ie insert immediately before this linerequire($template->get_template_dir('tpl_modules_product_listing.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_product_listing.php'); this code ```
    // MSL: Insert blanks into product list as required
    if (defined('TEXT_PRODUCT_DUMMY_PRODUCT')) {
    $rows = count($list_box_contents);
    $cols = count($list_box_contents[0]);
    //$cols = PRODUCT_LISTING_COLUMNS_PER_ROW;
    $lastrowcols = count($list_box_contents[$rows-1]);
    $insertcount = $cols - $lastrowcols;
    $totalcount = $rows * $cols;
    if ($insertcount) {
    // Reorder the items, inserting some blanks to make the rows complete
    $new_list_box_contents = array();
    foreach($list_box_contents as $r=>$row) foreach($row as $i=>$item) {
    $new_list_box_contents[] = $item;
    // echo "if ($insertcount && (".rand(1,$totalcount)." > ".($totalcount-count($new_list_box_contents)-$insertcount).")) {";
    if ($insertcount && (mt_rand(1,$totalcount) > ($totalcount-$insertcount-count($new_list_box_contents))*1.2)) {
    $new_list_box_contents[] = array('align' => 'center',
    'params' => 'class="productListing-data"',
    'text' => TEXT_PRODUCT_DUMMY_PRODUCT
    );
    $insertcount--;
    }
    }
    $r = $i = 0;
    $list_box_contents = array();
    foreach($new_list_box_contents as $item) {
    $list_box_contents[$r][$i++] = $item;
    if ($i >= $cols) { $i = 0; $r++; }
    }
    }
    }
    // END: MSL: Insert blanks into product list as required

That should do the trick. If anyone uses or improves on this this let me know.