Anasayfada Kategoriler - Homepage Categories

admin

Administrator
Yönetici
Katılım
13 Ağu 2009
Mesajlar
3,200
Tepkime puanı
1
Puanları
38
Yaş
38
Konum
Bursa
Web sitesi
www.opencart-tr.com
Bu modül ile kategorilerinizi anasayfanızda göstermek isterseniz bu modülü kullanabilirsiniz. Son eklenen ürünler yerine kategoriler gösterilir. Dosyaları hostunuzu gönderdiğinizde üzerine yazayım diye soracaktır. Soruya evet deyiniz. Yalnız üzerine yazılacak dosyalarda değişik yaptıysanız bu değişikler gidecektir. Önce yedek alın daha sonra gönderin.

OpenCart 1.4.0 için dosyalarınızın içeriğini bunlarla değiştirin.

catalog\view\theme\default\template\common\home.tpl
PHP:
<?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) { ?>
    <hr />
    <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>
    <?php } ?>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<?php echo $footer; ?>

catalog\controller\common\home.php
PHP:
<?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'));
   }
}
?>

1.4.1 ve 1.4.4 sürümler için dosyalarınızın içeriğini bunlarla değiştirin.

catalog\view\theme\default\template\common\home.tpl
PHP:
<?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 } ?>
    <table class="list">
    <hr />
      <?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 str_replace('&', '&', $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 str_replace('&', '&', $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>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<?php echo $footer; ?>

catalog\controller\common\home.php
PHP:
<?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_name'));
		
		$this->load->model('setting/store');
		
		if (!$this->config->get('config_store_id')) {
			$this->data['welcome'] = html_entity_decode($this->config->get('config_description_' . $this->config->get('config_language_id')), ENT_QUOTES, 'UTF-8');
		} else {
			$store_info = $this->model_setting_store->getStore($this->config->get('config_store_id'));
			
			if ($store_info) {
				$this->data['welcome'] = html_entity_decode($store_info['description'], ENT_QUOTES, 'UTF-8');
			} else {
				$this->data['welcome'] = '';
			}
		}
		
		$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->model('tool/image');
		
		/* START: Added for homepage category hacks */
       //Set Category for display
	   
		$this->load->model('catalog/category');

        $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((HTTP_SERVER . 'index.php?route=product/category&path=' . $result['category_id'])),
                'thumb'   => $this->model_tool_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'   => $this->model_tool_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(HTTP_SERVER . 'index.php?route=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'));
	}
}
?>

1.4.8.x - 1.4.9.x için
http://forum.opencart-tr.com/thread-2955.html
 

Ekli dosyalar

  • homepage_categories132.zip
    3.1 KB · Görüntüleme: 22
  • homepage_categories134.zip
    3.3 KB · Görüntüleme: 55

AmmaRm

OpenCart-TR
Katılım
3 Eki 2009
Mesajlar
9
Tepkime puanı
0
Puanları
0
Re: Anasayfada Kategorileri Göstermek - Homepage Categories

teşekkürler eline sağlık . .
 

artistim

OpenCart-TR
Katılım
25 Kas 2009
Mesajlar
2
Tepkime puanı
0
Puanları
0
Re: Anasayfada Kategorileri Göstermek - Homepage Categories

bende hata verdım yedekten gerı yukledım bılgınıze.
 

admin

Administrator
Yönetici
Katılım
13 Ağu 2009
Mesajlar
3,200
Tepkime puanı
1
Puanları
38
Yaş
38
Konum
Bursa
Web sitesi
www.opencart-tr.com
Re: Anasayfada Kategorileri Göstermek - Homepage Categories

Hangi sürümde denediniz. Modül 1.3.2 sürümü ile uyumlu
 

byazem

OpenCart-TR
Katılım
30 Kas 2009
Mesajlar
12
Tepkime puanı
0
Puanları
0
Re: Anasayfada Kategorileri Göstermek - Homepage Categories

1.3.2 için uyumlu bir modülü 1.3.4 sürümünde kullanamazmıyız?
 

mirac

OpenCart-TR
Katılım
7 Şub 2010
Mesajlar
1,383
Tepkime puanı
0
Puanları
36
Yaş
42
Konum
Beykoz____
Web sitesi
www.notebook-cantasi.com
Re: Anasayfada Kategoriler - Homepage Categories [Güncellendi]

Paylaşım için teşekkürler..
1.3.4 smrel in temasında aşağıdaki hatayı verdi.. Bilginize..

Notice: Undefined variable: products in C:\wamp\www\mirac\catalog\view\theme\smrel\template\common\home.tpl on line 19
 

devrimce

OpenCart-TR
Katılım
10 Şub 2010
Mesajlar
18
Tepkime puanı
0
Puanları
0
Re: Anasayfada Kategoriler - Homepage Categories [Güncellendi]

1.4 için güncellenebilirmi .)
 

admin

Administrator
Yönetici
Katılım
13 Ağu 2009
Mesajlar
3,200
Tepkime puanı
1
Puanları
38
Yaş
38
Konum
Bursa
Web sitesi
www.opencart-tr.com
Re: Anasayfada Kategoriler - Homepage Categories [Güncellendi]

mirac' Alıntı:
Paylaşım için teşekkürler..
1.3.4 smrel in temasında aşağıdaki hatayı verdi.. Bilginize..

Notice: Undefined variable: products in C:\wamp\www\mirac\catalog\view\theme\smrel\template\common\home.tpl on line 19

indirdiğin home.tpl dosyasını smrel teması içinde bulunan dosya ile değiştir.

devrimce' Alıntı:
1.4 için güncellenebilirmi .)

Müsait bir zaman da bununla ilgileneceğim.
 

admin

Administrator
Yönetici
Katılım
13 Ağu 2009
Mesajlar
3,200
Tepkime puanı
1
Puanları
38
Yaş
38
Konum
Bursa
Web sitesi
www.opencart-tr.com
OpenCart 1.4.0 için ilk mesajda yazan düzenlemeleri yapmanız yeterli
 

GENERAL

OpenCart-TR
Katılım
18 Ocak 2010
Mesajlar
80
Tepkime puanı
0
Puanları
0
Yaş
41
Web sitesi
www.musterisepeti.com
Çok güzel oldu ama smrel temada üstte yeni ürünler butonuna tıklandığında da kategoriler çıkıyor..Keşke bu sorunada bir çözüm olsa
 

smart176

OpenCart-TR
Katılım
12 Eki 2009
Mesajlar
22
Tepkime puanı
0
Puanları
0
merhabalar

1.4.4 sürümü içinde yapabilirmisiniz rica etsem

teşekkürler
 

smart176

OpenCart-TR
Katılım
12 Eki 2009
Mesajlar
22
Tepkime puanı
0
Puanları
0
teşekkürler oldu yalnız son eklenen ürünler kategorilerin altında gözükmekte, yardımınızı rica ederim
 

mirac

OpenCart-TR
Katılım
7 Şub 2010
Mesajlar
1,383
Tepkime puanı
0
Puanları
36
Yaş
42
Konum
Beykoz____
Web sitesi
www.notebook-cantasi.com
smart176' Alıntı:
teşekkürler oldu yalnız son eklenen ürünler kategorilerin altında gözükmekte, yardımınızı rica ederim

home.tpl dosyasındaki kodları alttaki kod ile değiştiriniz..

Kod:
<?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 } ?>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<?php echo $footer; ?>
 

kadan_adam

OpenCart-TR
Katılım
29 Mar 2010
Mesajlar
20
Tepkime puanı
0
Puanları
0
Yaş
44
selam yanlız söyle bir hata oluşuyor....
satınal butonu eklediğimiz için kople değştirdigimiz zaman diger moduller gidiyor daha önce bu secenegi ekledim sonra satın al butonu ekledim yine çakışıyor sizden ricam şimdiki kod sadece neresi değişmesi lazğım onu söyleme imkanınız varmı tşkler.

Pardon ben yanlış kod girmişim oldu :)
 

wiyaduk

OpenCart-TR
Katılım
8 Mar 2010
Mesajlar
9
Tepkime puanı
0
Puanları
0
Web sitesi
www.analizburo2.0fees.net
GENERAL' Alıntı:
Çok güzel oldu ama smrel temada üstte yeni ürünler butonuna tıklandığında da kategoriler çıkıyor..Keşke bu sorunada bir çözüm olsa

Gerekli düzeltmeyle common/home linkine kategorileri çekiyorsun bunu yapınca.. Oraya tıklayınca ne çıkmasını istiyorsun ki..
 
Üst