Post by supreme » Tue May 26, 2009 5:49 am

Hi,

I got an issue: i want to move the "Latest products" to another page i created via Catalog > Information. I've put the code which displays the "Latest products" to another template called news.tpl in /theme/default/template/common and i included with php include in the News page, but it doesn't work.

Daniel, can you please help me? :(

Thanks!

Newbie

Posts

Joined
Mon May 25, 2009 3:51 pm

Post by supreme » Wed May 27, 2009 4:09 am

nobody? :(

Newbie

Posts

Joined
Mon May 25, 2009 3:51 pm

Post by JNeuhoff » Wed May 27, 2009 7:28 pm

You would have to change the information.tpl to include sometjhing like this:

Code: Select all

  <div class="heading"><?php echo $text_latest; ?></div>
  <table class="list">
    <?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
    <tr>
      <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
      <td style="width: 25%;"><?php if (isset($products[$j])) { ?>
        <a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" /></a><br />
        <a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
        <span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
        <?php if (!$products[$j]['special']) { ?>
        <span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
        <?php } else { ?>
        <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
        <?php } ?>
        <?php if ($products[$j]['rating']) { ?>
        <img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
        <?php } ?>
        <?php } ?></td>
      <?php } ?>
    </tr>
    <?php } ?>
  </table>
The $products and $text_latest variables are to be set from a database query in the corresponding controller class information.php:

Code: Select all

		foreach ($this->model_catalog_product->getLatestProducts(8) as $result) {			
			if ($result['image']) {
				$image = $result['image'];
			} else {
				$image = 'no_image.jpg';
			}
			
			$rating = $this->model_catalog_review->getAverageRating($result['product_id']);	

			$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
			
			if ($special) {
				$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$special = FALSE;
			}
					
          	$this->data['products'][] = array(
            	'name'    => $result['name'],
				'model'   => $result['model'],
            	'rating'  => $rating,
				'stars'   => sprintf($this->language->get('text_stars'), $rating),
				'thumb'   => HelperImage::resize($image, 120, 120),
            	'price'   => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
				'special' => $special,
				'href'    => $this->url->http('product/product&product_id=' . $result['product_id'])
          	);
		}
Finally, you have to comment out the latest products DIVs in the home.tpl since you don't want it there. Also, the information.php code mentioned above needs to be updated so as to make sure that it will display the latest products only for a certain information page.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 5 guests