Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    23
    Plugin Contributions
    0

    Default 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!)

  2. #2
    Join Date
    May 2006
    Posts
    23
    Plugin Contributions
    0

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

    Quote Originally Posted by 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:
      Code:
      <?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!'));    
      ?>
    2. Add some code to ~/includes/modules/product_listing.php to insert the dummy images, ie insert immediately before this line
      Code:
      require($template->get_template_dir('tpl_modules_product_listing.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_product_listing.php');
      this code
      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.

 

 

Similar Threads

  1. Replies: 1
    Last Post: 10 Aug 2011, 02:07 AM
  2. Adding "Sizes" & "Colors" button in Product Page
    By zoombee in forum Basic Configuration
    Replies: 2
    Last Post: 10 Dec 2010, 01:51 PM
  3. Can I make all "add: 0" input boxes on product pages to "more info..."?
    By sfklaas in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 15 Aug 2009, 06:05 PM
  4. Can I make a "product" actually be a link to another category?
    By RFree190 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 14 May 2009, 01:37 AM
  5. Replies: 2
    Last Post: 22 Nov 2008, 09:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg