Post by davey c » Mon Dec 14, 2009 10:45 pm

Hi,

Is there a module, or a way, to display categories on the front-page as opposed to the latest products?
Last edited by i2Paq on Sat Feb 20, 2010 12:59 am, edited 1 time in total.
Reason: Topic moved

New member

Posts

Joined
Fri Aug 07, 2009 10:52 pm

Post by moggiex » Mon Dec 14, 2009 10:50 pm

Yes, sure Fido-x released a home page upgrade, look for that username in the forums and I pulled a version from the contributions [ http://www.opencart.com/index.php?route ... ntribution ] section along the top of the site.

Matt

Code: Select all

It was like that when I found it, honest!


User avatar
Active Member

Posts

Joined
Mon Nov 09, 2009 9:55 pm

Post by davey c » Mon Dec 14, 2009 11:01 pm

I had a look at Fido's Module, but it doesn't seem to offer categories, but just the ability to put featured items on the front page and text.

Am I missing something very obvious?

Cheers

New member

Posts

Joined
Fri Aug 07, 2009 10:52 pm

Post by moggiex » Mon Dec 14, 2009 11:30 pm

davey c wrote:I had a look at Fido's Module, but it doesn't seem to offer categories, but just the ability to put featured items on the front page and text.

Am I missing something very obvious?

Cheers
http://www.opencart.com/index.php?route ... ion_id=177

The home.php file I added makes it work for 1.3.4

It definitely does work as I use it on a bunch of sites.

Matt

Code: Select all

It was like that when I found it, honest!


User avatar
Active Member

Posts

Joined
Mon Nov 09, 2009 9:55 pm

Post by davey c » Tue Dec 15, 2009 9:50 pm

Hi Moggie-x

I read your posts and did an install on a site I'm working on (after upgrading from 1.30 to 1.34)

I've followed the instructions but now have the page as blank.

I did notice that the home.tpl file wasn't compatible with 1.3.4, so made some modifications to it so that it would fit within the new template design. My code is below

Code: Select all

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>

<div id="content">

  <div class="top">

    <h1><?php echo $heading_title; ?></h1>

  </div>

  <div class="middle">
  <div><?php echo $welcome; ?></div>

  <div class="heading"><?php echo $text_latest; ?></div>

  <table class="list">

    <?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>

    <tr>

      <?php for ($j = $i; $j < ($i + 4); $j++) { ?>

      <td style="width: 25%;"><?php if (isset($categories[$j])) { ?>

        <a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" /></a><br />

        <a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a><br />

        <?php } ?></td>

      <?php } ?>

    </tr>

    <?php } ?>

  </table>

</div>

  <div class="bottom">&nbsp;</div>

</div>

<?php echo $footer; ?> 
The homepage shows nothing with my site running 1.3.4. I notice that the home.zip file you mentioned is for 1.3.3 so could this be a compatibility issue with 1.3.4?

Cheers

Davey

New member

Posts

Joined
Fri Aug 07, 2009 10:52 pm

Post by Qphoria » Tue Dec 15, 2009 10:06 pm

1.3.3 and 1.3.4 are the same as far as templates go so that shouldn't matter

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by moggiex » Tue Dec 15, 2009 10:10 pm

This is an edited extract from one of one of my home.tpl files:

Code: Select all

<div class="top">
	  <h1>Some Heading Here</h1>
	</div>
	<div class="middle">
	  <table class="list">
		<?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>
		<tr>
		  <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
		  <td>
		  <?php if (isset($categories[$j])) { ?>
				<center>
					CODE HERE
					<a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a>

				</center>
			<?php } ?>
			</td>
		  <?php } ?>
		</tr>
		<?php } ?>
	  </table>
	</div>
	<div class="bottom">&nbsp;</div>
And use the home.php in that zip file for /catalog/controller/common/home.php

It should work with as that's what I'm at currently.

Matt

Code: Select all

It was like that when I found it, honest!


User avatar
Active Member

Posts

Joined
Mon Nov 09, 2009 9:55 pm

Post by davey c » Tue Dec 15, 2009 11:32 pm

Thanks so much for your help, Moggiex

For anyone else wishing to have a list of categories on the front page, this is the code I used in my home.tpl. This displays a list of the main categories if you set the category to '0' in the home.php file:

Code: Select all

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>

<div id="content">

  <div class="top">

    <h1>Defendapack Scale Sales</h1>

  </div>
  <div class="middle">

    <div><?php echo $welcome; ?></div>

    <table class="list">
      <?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td>
        <?php if (isset($categories[$j])) { ?>
            <center>

 <?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td width="25%"><?php if (isset($categories[$j])) { ?>
          <a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" style="margin-bottom: 3px;" /></a><br />
          <a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a>
          <?php } ?></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </table>
    <?php } ?>
    <?php if ($products) { ?>
     </div>
               
               <a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" /></a>

            </center>
         <?php } ?>
         </td>
        <?php } ?>
      </tr>
      <?php } ?>
     </table>

  </div>

  <div class="bottom">&nbsp;</div>

</div>

<?php echo $footer; ?> 

New member

Posts

Joined
Fri Aug 07, 2009 10:52 pm

Post by moggiex » Wed Dec 16, 2009 1:27 am

Ah thats reminded me there is a flaw in it, as in that those categories are diplsayed with non seo rewritten URL's

Open up the home.php file, at around line 77, swap:

Code: Select all

$this->data['categories'][] = array(
        			'name'  => $result['name'],
        			'href'  => $this->url->http('product/category&path=' . $result['category_id']),
        			//'thumb' => HelperImage::resize($image, 120, 120)
					'thumb' => image_resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
      			);
            }
To:

Code: Select all

$this->data['categories'][] = array(
        			'name'  => $result['name'],
        			'href'  => $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $result['category_id'])),
        			//'thumb' => HelperImage::resize($image, 120, 120)
					'thumb' => image_resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
      			);
            }
And happy days

Matt

Code: Select all

It was like that when I found it, honest!


User avatar
Active Member

Posts

Joined
Mon Nov 09, 2009 9:55 pm

Post by i2Paq » Wed Dec 16, 2009 2:09 am

moggiex wrote:Ah thats reminded me there is a flaw in it, as in that those categories are diplsayed with non seo rewritten URL's

*knip*

And happy days

Matt
Thank you.

Will you update the contribution-package also?

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by macwhore » Fri Jan 15, 2010 5:28 am

Any idea how to get this working on 1.4.0?

Naughty Naughty - Your Adult Superstore


Newbie

Posts

Joined
Tue Jan 12, 2010 5:33 pm

Post by macwhore » Fri Jan 15, 2010 8:03 am

I get:
Fatal error: Call to a member function getTotalCategoriesByCategoryId() on a non-object in catalog/controller/common/home.php on line 25

When I try to use the contribution on 1.4.0. Any help is greatly appreciated :-\

Naughty Naughty - Your Adult Superstore


Newbie

Posts

Joined
Tue Jan 12, 2010 5:33 pm

Post by deeve » Sat Jan 23, 2010 12:10 am

Don't know why but I've been wrestling with this for a couple of hours now - working in 1.3.4
Followed instructions above to the letter but am seeing nothing at all on homepage where I'd expect to see the categories thumbs.

Sounds similar to the problem davey c experienced earlier. Have tried all the consequent code posted but nothing seems to budge!

Any suggestions?

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by deeve » Sat Jan 23, 2010 1:58 am

Apologies! I had overlooked to change the number of Categories to (0) in home.php
I can now see Categories thumbs nicely. Just need to make the footer & bottom of my middle table's border behave! For some reason, the border is missing it's bottom corners & base line and the footer is full width of page. I took out the 'if $product' code as was conflicting with a reflect script I'm using on the Categories images but maybe I've overlooked something in order to complete the table &footer correctly. If anyone can see with a fresh pair of eyes, I'd appreciate - mine are now a bit bleary!

Code: Select all

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content">
  <div class="top">
    <h1><?php echo $heading_title; ?></h1>
  </div>
  <div class="middle">
    <table class="list">
      <?php for ($i = 0; $i < sizeof($categories); $i = $i + 3) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 3); $j++) { ?>
        <td>
        <?php if (isset($categories[$j])) { ?>
            <?php for ($i = 0; $i < sizeof($categories); $i = $i + 3) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 3); $j++) { ?>
        <td width="25%"><?php if (isset($categories[$j])) { ?>
          <a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" style="float: left; margin-left: 15px; margin-bottom: 3px;" class="reflect" /></a><br />         
          <?php } ?></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </table>
    <?php } ?>
    <?php if ($products) { ?>
     </div>              
          <?php } ?>
         </td>
        <?php } ?>
      </tr>
      <?php } ?>
     </table>
  </div>
  <div class="bottom">&nbsp;</div>
</div>
<?php echo $footer; ?> 
..forgot to mention, I'm only using the default template.

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by soul » Mon Feb 01, 2010 8:15 am

Also getting the same "Call to a member function getTotalCategoriesByCategoryId()" error using this on 1.4. Any ideas?

Newbie

Posts

Joined
Mon Feb 01, 2010 3:10 am

Post by soul » Mon Feb 01, 2010 8:30 am

Solved the problem for 1.4.. need to add:

Code: Select all

$this->load->model('catalog/category');
in the loaders of home.php. Still getting some errors which I need to figure out but that at least gets the categories to load.

Newbie

Posts

Joined
Mon Feb 01, 2010 3:10 am

Post by davey c » Sat Feb 20, 2010 12:50 am

For anyone interested, I got this working on version 1.4 now:

Here is the code for home.tpl:

Code: Select all

<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content">
  <div class="top">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h1><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <div><?php echo $welcome; ?></div>

    <div class="heading"><?php echo $text_latest; ?></div>
    <?php if ($categories) { ?>
    <table class="list">
      <?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td width="25%"><?php if (isset($categories[$j])) { ?>
          <a href="<?php echo $categories[$j]['href']; ?>"><img src="<?php echo $categories[$j]['thumb']; ?>" title="<?php echo $categories[$j]['name']; ?>" alt="<?php echo $categories[$j]['name']; ?>" style="margin-bottom: 3px;" /></a><br />
          <a href="<?php echo $categories[$j]['href']; ?>"><?php echo $categories[$j]['name']; ?></a>
          <?php } ?></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </table>
    <?php } ?>
    <?php if ($products) { ?>
    <div class="sort">
      <div class="div1">
        <select name="sort" onchange="location=this.value">
          <?php foreach ($sorts as $sorts) { ?>
          <?php if (($sort . '-' . $order) == $sorts['value']) { ?>
          <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
          <?php } else { ?>
          <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
          <?php } ?>
          <?php } ?>
        </select>
      </div>
      <div class="div2"><?php echo $text_sort; ?></div>
    </div>
    <table class="list">
      <?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td 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 ($display_price) { ?>
          <?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 } ?>
          <?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>
    <div class="pagination"><?php echo $pagination; ?></div>
    <?php } ?>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<?php echo $footer; ?>  
Here is the code for home.php:

Code: Select all

<?php  
class ControllerCommonHome extends Controller {
	public function index() {
		$this->language->load('common/home');
		
		$this->document->title = $this->config->get('config_title');
		$this->document->description = $this->config->get('config_meta_description');
		
		$this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_store'));
		$this->data['welcome'] = html_entity_decode($this->config->get('config_welcome_' . $this->config->get('config_language_id')));
		
		$this->data['text_latest'] = $this->language->get('text_latest');
		
		$this->load->model('catalog/product');
		$this->load->model('catalog/review');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');
		$this->load->model('catalog/category');
		
		/* START: Added for homepage category hacks */

		

		 //Set Category for display

        $category_id = '0';



        //get total categories in your category

		$category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category_id);



		$this->data['products'] = array();



		 if (isset($category_total)) {

        $this->data['categories'] = array();



        $results = $this->model_catalog_category->getCategories($category_id);



            foreach ($results as $result) {

        	if ($result['image']) {

        		$image = $result['image'];

        	} else {

        		$image = 'no_image.jpg';

        	}



$this->data['categories'][] = array(
                 'name'  => $result['name'],
                 'href'  => $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $result['category_id'])),
                 //'thumb' => HelperImage::resize($image, 120, 120)
               'thumb' => image_resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
               );
            }



		$this->id       = 'content';

		$this->template = $this->template = 'default/template/common/home.tpl';

		$this->layout   = 'common/layout';



		$this->render();

	    }

		/* END: Added for homepage category hacks */
		
		$this->data['products'] = array();

		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 = FALSE;
			
			$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
			
			if ($discount) {
				$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
			 
				$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')));
				}						
			}
				
          	$this->data['products'][] = array(
            	'name'    => $result['name'],
				'model'   => $result['model'],
            	'rating'  => $rating,
				'stars'   => sprintf($this->language->get('text_stars'), $rating),
				'thumb'   => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            	'price'   => $price,
				'special' => $special,
				'href'    => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
          	);
		}

		if (!$this->config->get('config_customer_price')) {
			$this->data['display_price'] = TRUE;
		} elseif ($this->customer->isLogged()) {
			$this->data['display_price'] = TRUE;
		} else {
			$this->data['display_price'] = FALSE;
		}
				
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/home.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/home.tpl';
		} else {
			$this->template = 'default/template/common/home.tpl';
		}
		
		$this->children = array(
			'common/header',
			'common/footer',
			'common/column_left',
			'common/column_right'
		);
		
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}
}
?>

New member

Posts

Joined
Fri Aug 07, 2009 10:52 pm

Post by deeve » Sun Feb 28, 2010 5:09 pm

Been a while since I tried all of the above & looked on the surface like it worked but just gone back to dev site & noticed I'm getting these errors on base elements which are causing a lag on certain page loads - anyone got any ideas why?:

Undefined variable: header in mypath/store/catalog/view/theme/default/template/common/home.tpl on line 1
Undefined variable: column_left in mypath/store/catalog/view/theme/default/template/common/home.tpl on line 1
Undefined variable: column_right in mypath/store/catalog/view/theme/default/template/common/home.tpl on line 1
Undefined variable: footer in mypath/store/catalog/view/theme/default/template/common/home.tpl on line 36

OC 1.3.4
home.php

Code: Select all

<?php  
class ControllerCommonHome extends Controller {
	public function index() {
		$this->language->load('common/home');
		
		$this->document->title = $this->config->get('config_title');
		$this->document->description = $this->config->get('config_meta_description');
		
		$this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_store'));
		$this->data['welcome'] = html_entity_decode($this->config->get('config_welcome_' . $this->config->get('config_language_id')));
		
		$this->data['text_latest'] = $this->language->get('text_latest');
		
		$this->load->model('catalog/product');
		$this->load->model('catalog/review');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');
		
		$this->data['products'] = array();

		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 = FALSE;
			
			$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
			
			if ($discount) {
				$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
			 
				$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')));
				}						
			}
				
          	$this->data['products'][] = array(
            	'name'    => $result['name'],
				'model'   => $result['model'],
            	'rating'  => $rating,
				'stars'   => sprintf($this->language->get('text_stars'), $rating),
				'thumb'   => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            	'price'   => $price,
				'special' => $special,
				'href'    => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
          	);
		}

		if (!$this->config->get('config_customer_price')) {
			$this->data['display_price'] = TRUE;
		} elseif ($this->customer->isLogged()) {
			$this->data['display_price'] = TRUE;
		} else {
			$this->data['display_price'] = FALSE;
		}
				
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/home.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/home.tpl';
		} else {
			$this->template = 'default/template/common/home.tpl';
		}
		
		$this->children = array(
			'common/header',
			'common/footer',
			'common/column_left',
			'common/column_right'
		);
		
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}
}
?>

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by deeve » Thu Mar 04, 2010 9:28 pm

No one else getting these errors with this mod?

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm

Post by deeve » Tue Mar 23, 2010 7:28 pm

Doh! Again, I overlooked to include the working [or rather NOT working] php file. If anyone could shine a light on why I'm receiving these undefined variable errors I'd be eternally grateful !

Code: Select all

<?php  
class ControllerCommonHome extends Controller {
	public function index() {
	
		$this->language->load('common/home');
		
		$this->document->title = $this->config->get('config_title');
		$this->document->description = $this->config->get('config_meta_description');

		$this->document->breadcrumbs = array();

      	$this->document->breadcrumbs[] = array(
        	'href'      => $this->url->http('common/home'),
        	'text'      => $this->language->get('text_home'),
        	'separator' => FALSE
      	);
		
		$this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_store'));
		$this->data['welcome'] = html_entity_decode($this->config->get('config_welcome_' . $this->language->getId()));
		
		$this->data['text_latest'] = $this->language->get('text_latest');
		
		$this->load->model('catalog/product');
		$this->load->model('catalog/category');
		$this->load->model('catalog/review');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');
		
		/* START: Added for homepage category hacks */
		
		 //Set Category for display
        $category_id = '0';

        //get total categories in your category
		$category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category_id);

		$this->data['products'] = array();

		 if (isset($category_total)) {
        $this->data['categories'] = array();

        $results = $this->model_catalog_category->getCategories($category_id);

            foreach ($results as $result) {
        	if ($result['image']) {
        		$image = $result['image'];
        	} else {
        		$image = 'no_image.jpg';
        	}

        	$this->data['categories'][] = array(
                 'name'  => $result['name'],
                 'href'  => $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $result['category_id'])),
                 //'thumb' => HelperImage::resize($image, 151, 151)
               'thumb' => image_resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
               );
            }

		$this->id       = 'content';
		$this->template = $this->template = 'default/template/common/home.tpl';
		$this->layout   = 'common/layout';

		$this->render();
	    }
		/* END: Added for homepage category hacks */
		
		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 = FALSE;
			
			$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
			
			if ($discount) {
				$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
			 
				$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')));
				}						
			}
				
          	$this->data['products'][] = array(
            	'name'    => $result['name'],
				'model'   => $result['model'],
            	'rating'  => $rating,
				'stars'   => sprintf($this->language->get('text_stars'), $rating),
				'thumb'   => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            	'price'   => $price,
				'special' => $special,
				'href'    => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
          	);
		}

		if (!$this->config->get('config_customer_price')) {
			$this->data['display_price'] = TRUE;
		} elseif ($this->customer->isLogged()) {
			$this->data['display_price'] = TRUE;
		} else {
			$this->data['display_price'] = FALSE;
		}
				
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/home.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/home.tpl';
		} else {
			$this->template = 'default/template/common/home.tpl';
		}
		
		$this->children = array(
			'common/header',
			'common/footer',
			'common/column_left',
			'common/column_right'
		);
		
		$this->response->setOutput($this->render(TRUE));
	}
}
?>

Active Member

Posts

Joined
Tue Oct 20, 2009 4:31 pm
Who is online

Users browsing this forum: No registered users and 3 guests