Bilgi Sayfalarını Haberler olarak kopyalamak

numerous

OpenCart-TR
Katılım
31 Ağu 2010
Mesajlar
32
Tepkime puanı
0
Puanları
0
catalog/information ( bilgi sayfaları) modülünü çoğaltıp Haberler olarak kullanmak istiyorum, nasıl yapabilirim bunu.?

ben dosyaları kopyalayıp isimlerini news olarak değiştirdim. dosya içindende değiştirdim information yazan heryeri news yaptım. admin/common header da ekledım gerekli yerleri. dil dosyalarınıda yaptım. fakat site açılmıyor modülü aktif yapnca, ve erişim izinlerinde catalog/news gözükmüyor.

Error: Could not load model catalog/news! yazıyor.

database mi ekleyeceğiz acaba? tam olarak sorunsuz nasıl yapabileceğimi bilen varmı ?
 

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 konu altında modüllerin nasıl çoğaltılabileceği yazmaktadır. Sayfalarıda bu şekilde kopyalayabilirsiniz.
http://forum.opencart-tr.com/thread-2105.html

Veritabanında tablo oluşturmanız gerekir.
 

numerous

OpenCart-TR
Katılım
31 Ağu 2010
Mesajlar
32
Tepkime puanı
0
Puanları
0
aynı şekilde tablo oluşturdum, dosya isimleri ve içindeki isimleride information yerine news yaptım. fakat dosya izinlerinde gözükmüyor catalog/news diye bi onu beceremedim :S
 

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
Sadece catalog içindekileri kopyalamışsınızdır. Admin dizini altındakileri de aynı şeyi yapmalısınız.
 

debreli

OpenCart-TR
Katılım
31 Ağu 2010
Mesajlar
196
Tepkime puanı
0
Puanları
0
Web sitesi
vakifshop.com
bilgi syfaları edit.sitemin sağ alt bloğunda inceleyebilirsiniz. zipli dosyanın için den çıkan klasörleri sitenizin ana dizinine kopyalayın.benioku.txt dosyasını okuyun.
 

Ekli dosyalar

  • heber.zip
    19.6 KB · Görüntüleme: 59

numerous

OpenCart-TR
Katılım
31 Ağu 2010
Mesajlar
32
Tepkime puanı
0
Puanları
0
teşekkürler debreli senin modülü kurdum.

ADMİN PANELDEN CATALOG ALTINDAKİ HABERLERE TIKLADIĞIM ZAMAN ŞU HATAYI ALIYORUM

Sunucu hatası.

http://www.ambalajmarketim.net/admin/index.php?route=catalog/news&token=a74d8ab95e509721f47eebb2fc8078a9 alınırken web sitesi bir hatayla karşılaştı. http://www.ambalajmarketim.net/admin/index.php?route=catalog/news&token=a74d8ab95e509721f47eebb2fc8078a9 bakım için kapatılmış veya yanlış yapılandırılmış olabilir

modüllerden kurdum anasayfada modül gözüküyor onda problem yok şuanda
 

debreli

OpenCart-TR
Katılım
31 Ağu 2010
Mesajlar
196
Tepkime puanı
0
Puanları
0
Web sitesi
vakifshop.com
bendekinde su an hiç bir hata yok.enson admin sistem kullanıcılar kullanıcı gurup izinlerinden izinleri ver.daha olmazza baştan uygula.zipli dosyanın içinden cıkan beni oku txt dosyasını iyi uygula.
 

kadirmert

OpenCart-TR
Katılım
17 Ocak 2011
Mesajlar
10
Tepkime puanı
0
Puanları
0
bilgi sayfasını çoğalatma

Hocam verdiğiniz metodlarla bütün bilgi sayfalarını kopyaladım modü çoğaltamk istedim fakat modülü etkinleştirdiğimde Error: Could not load model catalog/bilgi! böyle bir hata veriyor. Diyorum acaba sitenin ingilizceside var tek tek ordakinide mi kopyalamam gerekiyor yada bu hata nedendir şimdiden teşekkür ederim

şimdide böyle bir hata veriyor hocam çözemedim ya Hata: Table 'siyasettime.bilgi' yok
Hiçbir Hata: 1146
SELECT * FROM Bilgi i SOL AÇIK id bilgi_description JOIN ON SOL bilgi_to_store I2S JOIN (= id.bilgi_id i.bilgi_id) (i.bilgi_id = i2s.bilgi_id) WHERE = '1 id.language_id 'VE = '0 i2s.store_id' VE i.status = '1 'AND i.sort_order <>' -1 'ORDER BY i.sort_order, LCase (id.title) ASC
 

karadamla

OpenCart-TR
Katılım
17 Şub 2011
Mesajlar
49
Tepkime puanı
0
Puanları
0
mrb arkadaşlar ben verilen modülü kurdum beni oku dosyasındaki her şeyi yaptım fakat haber sayfasına girmeye çalıştığımda bana aşşağıdaki gibi bir hata veriyor acaba sorunumu nasıl çözebi,lirim.bir yerde hatamı yaptım acaba, bütün söylenenleri eksiksik yaptığımı düşünüyorum oysa.lütfen yardım ederseniz sevinirim.
hata:Fatal error: Cannot redeclare class ControllerCatalognews in /home/kocaeliy/public_html/admin/model/catalog/news.php on line 452
 

biocyn

OpenCart-TR
Katılım
26 May 2011
Mesajlar
75
Tepkime puanı
0
Puanları
0
karadamla' Alıntı:
mrb arkadaşlar ben verilen modülü kurdum beni oku dosyasındaki her şeyi yaptım fakat haber sayfasına girmeye çalıştığımda bana aşşağıdaki gibi bir hata veriyor acaba sorunumu nasıl çözebi,lirim.bir yerde hatamı yaptım acaba, bütün söylenenleri eksiksik yaptığımı düşünüyorum oysa.lütfen yardım ederseniz sevinirim.
hata:Fatal error: Cannot redeclare class ControllerCatalognews in /home/kocaeliy/public_html/admin/model/catalog/news.php on line 452

Aynen arkadaşım bende de aynı hatayı verdi nasıl düzeltebiliriz anlamış değilim. Anladığım kadarı ile hata aynı verinin ya da adın tekrarlanması ile ilgili birşey ama bakalım üstadlardan yardım gelecektir herhalde... Şimdiden teşekkür ediyorum...

hata:Fatal error: Cannot redeclare class ControllerCatalognews in../........../admin/model/catalog/news.php on line 452
 

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
biocyn' Alıntı:
karadamla' Alıntı:
mrb arkadaşlar ben verilen modülü kurdum beni oku dosyasındaki her şeyi yaptım fakat haber sayfasına girmeye çalıştığımda bana aşşağıdaki gibi bir hata veriyor acaba sorunumu nasıl çözebi,lirim.bir yerde hatamı yaptım acaba, bütün söylenenleri eksiksik yaptığımı düşünüyorum oysa.lütfen yardım ederseniz sevinirim.
hata:Fatal error: Cannot redeclare class ControllerCatalognews in /home/kocaeliy/public_html/admin/model/catalog/news.php on line 452

Aynen arkadaşım bende de aynı hatayı verdi nasıl düzeltebiliriz anlamış değilim. Anladığım kadarı ile hata aynı verinin ya da adın tekrarlanması ile ilgili birşey ama bakalım üstadlardan yardım gelecektir herhalde... Şimdiden teşekkür ediyorum...

hata:Fatal error: Cannot redeclare class ControllerCatalognews in../........../admin/model/catalog/news.php on line 452

http://forum.opencart-tr.com/thread-3044-post-15229.html#pid15229
http://forum.opencart-tr.com/thread-314.html
 

biocyn

OpenCart-TR
Katılım
26 May 2011
Mesajlar
75
Tepkime puanı
0
Puanları
0
Teşekkür ederim yardımınız için ancak bilgi sayfaları modülü ile bir alakası yok ki bu testimonial modülünün. Benim istediğim olay nasıl ki hakkımızda vs. şeklinde bir bölüm var Bilgi sayfaları adı altında. Bunun bir de kopyası olsa mesela Makaleler başlığı atında. Şimdi diyeceksiniz ki ben oraya bir de modül çoğaltma konu anlatımının linkini yazdım. Ancak veri tabanına neyi nasıl sorgulattıracağım? Olacak mı ki o şekilde. Yani modül çoğaltılır ancak bilgi sayfaları da aynı yolla çoğalır mı?

Sabah saat 05:37 oldu olsa keşke de daha 2 gün uyumasam...
 

biocyn

OpenCart-TR
Katılım
26 May 2011
Mesajlar
75
Tepkime puanı
0
Puanları
0
5 gün sonra işi çözmüş oldum. Ama gerçekten 5 günümü aldı. Aslında hata dosyalarda imiş.

admin/controller/catalog/news.php
admin/model/catalog/news.php

dosyalarında information terimleri inf ile tam olarak değiştirilmemiş. ve info olması gereken 8 terim de news olarak değiştirilmiş. Bunun için de sıkıntı yaratıyormuş. Neyseki çözdüm. iki ben yenisini de bu beş günlük zaman diliminde yapmış oldum. şimdi elimde 3 adet bilgi sayfaları modülü oldu. Aynı zamanda sorgu mantığını da çözmüş oldum. Kısacası balık tutmayı ömğreniyoruz. Herşeye sebep olan OpenCart ve Yöneticilerim. Allah binlerce kez sizlerden razı olsun...
 

adsl77

OpenCart-TR
Katılım
6 May 2011
Mesajlar
130
Tepkime puanı
0
Puanları
0
Konum
Ankara
biocyn' Alıntı:
5 gün sonra işi çözmüş oldum. Ama gerçekten 5 günümü aldı. Aslında hata dosyalarda imiş.

admin/controller/catalog/news.php
admin/model/catalog/news.php

dosyalarında information terimleri inf ile tam olarak değiştirilmemiş. ve info olması gereken 8 terim de news olarak değiştirilmiş. Bunun için de sıkıntı yaratıyormuş. Neyseki çözdüm. iki ben yenisini de bu beş günlük zaman diliminde yapmış oldum. şimdi elimde 3 adet bilgi sayfaları modülü oldu. Aynı zamanda sorgu mantığını da çözmüş oldum. Kısacası balık tutmayı ömğreniyoruz. Herşeye sebep olan OpenCart ve Yöneticilerim. Allah binlerce kez sizlerden razı olsun...

bende aynı hatayı alıyorum. değiştirdiğin 2 dosyayı paylaşabilirmisin? dediğin dosyalardaki değişiklikleri yaptım ancak iyice karıştı ve içinden çıkılmaz bir hal aldı. kısacası yapamadım :)

teşekkürler...
 

biocyn

OpenCart-TR
Katılım
26 May 2011
Mesajlar
75
Tepkime puanı
0
Puanları
0
adsl77' Alıntı:
biocyn' Alıntı:
5 gün sonra işi çözmüş oldum. Ama gerçekten 5 günümü aldı. Aslında hata dosyalarda imiş.

admin/controller/catalog/news.php
admin/model/catalog/news.php

dosyalarında information terimleri inf ile tam olarak değiştirilmemiş. ve info olması gereken 8 terim de news olarak değiştirilmiş. Bunun için de sıkıntı yaratıyormuş. Neyseki çözdüm. iki ben yenisini de bu beş günlük zaman diliminde yapmış oldum. şimdi elimde 3 adet bilgi sayfaları modülü oldu. Aynı zamanda sorgu mantığını da çözmüş oldum. Kısacası balık tutmayı ömğreniyoruz. Herşeye sebep olan OpenCart ve Yöneticilerim. Allah binlerce kez sizlerden razı olsun...

bende aynı hatayı alıyorum. değiştirdiğin 2 dosyayı paylaşabilirmisin? dediğin dosyalardaki değişiklikleri yaptım ancak iyice karıştı ve içinden çıkılmaz bir hal aldı. kısacası yapamadım :)

teşekkürler...


admin/controller/catalog/news.php

PHP:
<?php
class ControllerCatalogNews extends Controller { 
	private $error = array();

	public function index() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		 
		$this->load->model('catalog/news');

		$this->getList();
	}

	public function insert() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		
		$this->load->model('catalog/news');
				
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
			$this->model_catalog_news->addnews($this->request->post);
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';
			
			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}
			
			$this->redirect(HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url);
		}

		$this->getForm();
	}

	public function update() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		
		$this->load->model('catalog/news');
		
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
			$this->model_catalog_news->editnews($this->request->get['news_id'], $this->request->post);
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';
			
			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}
			
			$this->redirect(HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url);
		}

		$this->getForm();
	}
 
	public function delete() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		
		$this->load->model('catalog/news');
		
		if (isset($this->request->post['selected']) && $this->validateDelete()) {
			foreach ($this->request->post['selected'] as $news_id) {
				$this->model_catalog_news->deletenews($news_id);
			}
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';
			
			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}
			
			$this->redirect(HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url);
		}

		$this->getList();
	}

	private function getList() {
		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}
		
		if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'id.title';
		}
		
		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'ASC';
		}
		
		$url = '';
			
		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

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

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('text_home'),
      		'separator' => FALSE
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url,
       		'text'      => $this->language->get('heading_title'),
      		'separator' => ' :: '
   		);
							
		$this->data['insert'] = HTTPS_SERVER . 'index.php?route=catalog/news/insert&token=' . $this->session->data['token'] . $url;
		$this->data['delete'] = HTTPS_SERVER . 'index.php?route=catalog/news/delete&token=' . $this->session->data['token'] . $url;	

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

		$data = array(
			'sort'  => $sort,
			'order' => $order,
			'start' => ($page - 1) * $this->config->get('config_admin_limit'),
			'limit' => $this->config->get('config_admin_limit')
		);
		
		$news_total = $this->model_catalog_news->getTotalnewss();
	
		$results = $this->model_catalog_news->getnewss($data);
 
    	foreach ($results as $result) {
			$action = array();
						
			$action[] = array(
				'text' => $this->language->get('text_edit'),
				'href' => HTTPS_SERVER . 'index.php?route=catalog/news/update&token=' . $this->session->data['token'] . '&news_id=' . $result['news_id'] . $url
			);
						
			$this->data['newss'][] = array(
				'news_id' => $result['news_id'],
				'title'      => $result['title'],
				'sort_order' => $result['sort_order'],
				'selected'   => isset($this->request->post['selected']) && in_array($result['news_id'], $this->request->post['selected']),
				'action'     => $action
			);
		}	
	
		$this->data['heading_title'] = $this->language->get('heading_title');

		$this->data['text_no_results'] = $this->language->get('text_no_results');

		$this->data['column_title'] = $this->language->get('column_title');
		$this->data['column_sort_order'] = $this->language->get('column_sort_order');
		$this->data['column_action'] = $this->language->get('column_action');		
		
		$this->data['button_insert'] = $this->language->get('button_insert');
		$this->data['button_delete'] = $this->language->get('button_delete');
 
 		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}
		
		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
		
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}

		$url = '';

		if ($order == 'ASC') {
			$url .= '&order=DESC';
		} else {
			$url .= '&order=ASC';
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}
		
		$this->data['sort_title'] = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . '&sort=id.title' . $url;
		$this->data['sort_sort_order'] = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . '&sort=i.sort_order' . $url;
		
		$url = '';

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}
												
		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		$pagination = new Pagination();
		$pagination->total = $news_total;
		$pagination->page = $page;
		$pagination->limit = $this->config->get('config_admin_limit');
		$pagination->text = $this->language->get('text_pagination');
		$pagination->url = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url . '&page={page}';
			
		$this->data['pagination'] = $pagination->render();

		$this->data['sort'] = $sort;
		$this->data['order'] = $order;
		
		$this->template = 'catalog/news_list.tpl';
		$this->children = array(
			'common/header',	
			'common/footer'	
		);
		
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}

	private function getForm() {
		$this->data['heading_title'] = $this->language->get('heading_title');

		$this->data['text_default'] = $this->language->get('text_default');
		$this->data['text_enabled'] = $this->language->get('text_enabled');
    	$this->data['text_disabled'] = $this->language->get('text_disabled');
		
		$this->data['entry_title'] = $this->language->get('entry_title');
		$this->data['entry_description'] = $this->language->get('entry_description');
		$this->data['entry_store'] = $this->language->get('entry_store');
		$this->data['entry_keyword'] = $this->language->get('entry_keyword');
		$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
		$this->data['entry_status'] = $this->language->get('entry_status');
		
		$this->data['button_save'] = $this->language->get('button_save');
		$this->data['button_cancel'] = $this->language->get('button_cancel');

		$this->data['token'] = $this->session->data['token'];

 		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}

 		if (isset($this->error['title'])) {
			$this->data['error_title'] = $this->error['title'];
		} else {
			$this->data['error_title'] = '';
		}
		
	 	if (isset($this->error['description'])) {
			$this->data['error_description'] = $this->error['description'];
		} else {
			$this->data['error_description'] = '';
		}
		
		$url = '';
			
		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}
		
  		$this->document->breadcrumbs = array();

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('text_home'),
      		'separator' => FALSE
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url,
       		'text'      => $this->language->get('heading_title'),
      		'separator' => ' :: '
   		);
							
		if (!isset($this->request->get['news_id'])) {
			$this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/news/insert&token=' . $this->session->data['token'] . $url;
		} else {
			$this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/news/update&token=' . $this->session->data['token'] . '&news_id=' . $this->request->get['news_id'] . $url;
		}
		
		$this->data['cancel'] = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url;

		if (isset($this->request->get['news_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
			$news_info = $this->model_catalog_news->getnews($this->request->get['news_id']);
		}
		
		$this->load->model('localisation/language');
		
		$this->data['languages'] = $this->model_localisation_language->getLanguages();
		
		if (isset($this->request->post['news_description'])) {
			$this->data['news_description'] = $this->request->post['news_description'];
		} elseif (isset($this->request->get['news_id'])) {
			$this->data['news_description'] = $this->model_catalog_news->getnewsDescriptions($this->request->get['news_id']);
		} else {
			$this->data['news_description'] = array();
		}

		if (isset($this->request->post['status'])) {
			$this->data['status'] = $this->request->post['status'];
		} elseif (isset($news_info)) {
			$this->data['status'] = $news_info['status'];
		} else {
			$this->data['status'] = 1;
		}
		
		$this->load->model('setting/store');
		
		$this->data['stores'] = $this->model_setting_store->getStores();
		
		if (isset($this->request->post['news_store'])) {
			$this->data['news_store'] = $this->request->post['news_store'];
		} elseif (isset($news_info)) {
			$this->data['news_store'] = $this->model_catalog_news->getnewsStores($this->request->get['news_id']);
		} else {
			$this->data['news_store'] = array(0);
		}		
		
		if (isset($this->request->post['keyword'])) {
			$this->data['keyword'] = $this->request->post['keyword'];
		} elseif (isset($news_info)) {
			$this->data['keyword'] = $news_info['keyword'];
		} else {
			$this->data['keyword'] = '';
		}
		
		if (isset($this->request->post['sort_order'])) {
			$this->data['sort_order'] = $this->request->post['sort_order'];
		} elseif (isset($news_info)) {
			$this->data['sort_order'] = $news_info['sort_order'];
		} else {
			$this->data['sort_order'] = '';
		}
		
		$this->template = 'catalog/news_form.tpl';
		$this->children = array(
			'common/header',	
			'common/footer'	
		);
		
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}

	private function validateForm() {
		if (!$this->user->hasPermission('modify', 'catalog/news')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		foreach ($this->request->post['news_description'] as $language_id => $value) {
			if ((strlen(utf8_decode($value['title'])) < 3) || (strlen(utf8_decode($value['title'])) > 250)) {
				$this->error['title'][$language_id] = $this->language->get('error_title');
			}
		
			if (strlen(utf8_decode($value['description'])) < 3) {
				$this->error['description'][$language_id] = $this->language->get('error_description');
			}
		}

		if (!$this->error) {
			return TRUE;
		} else {
			if (!isset($this->error['warning'])) {
				$this->error['warning'] = $this->language->get('error_required_data');
			}
			return FALSE;
		}
	}

	private function validateDelete() {
		if (!$this->user->hasPermission('modify', 'catalog/news')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		$this->load->model('setting/store');
		
		foreach ($this->request->post['selected'] as $news_id) {
			if ($this->config->get('config_account_id') == $news_id) {
				$this->error['warning'] = $this->language->get('error_account');
			}
			
			if ($this->config->get('config_checkout_id') == $news_id) {
				$this->error['warning'] = $this->language->get('error_checkout');
			}
			
			$store_total = $this->model_setting_store->getTotalStoresBynewsId($news_id);

			if ($store_total) {
				$this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
			}
		}

		if (!$this->error) {
			return TRUE;
		} else {
			return FALSE;
		}
	}
}
?>


admin/model/catalog/news.php

PHP:
<?php
class ModelCatalogNews extends Model {
	public function addNews($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "news SET sort_order = '" . (int)$this->request->post['sort_order'] . "', status = '" . (int)$data['status'] . "'");

		$news_id = $this->db->getLastId(); 
			
		foreach ($data['news_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "news_description SET news_id = '" . (int)$news_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "'");
		}
		
		if (isset($data['news_store'])) {
			foreach ($data['news_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "news_to_store SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "'");
			}
		}
		
		if ($data['keyword']) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'news_id=" . (int)$news_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
		}
		
		$this->cache->delete('news');
	}
	
	public function editNews($news_id, $data) {
		$this->db->query("UPDATE " . DB_PREFIX . "news SET sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "' WHERE news_id = '" . (int)$news_id . "'");

		$this->db->query("DELETE FROM " . DB_PREFIX . "news_description WHERE news_id = '" . (int)$news_id . "'");
					
		foreach ($data['news_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "news_description SET news_id = '" . (int)$news_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "'");
		}

		$this->db->query("DELETE FROM " . DB_PREFIX . "news_to_store WHERE news_id = '" . (int)$news_id . "'");
		
		if (isset($data['news_store'])) {
			foreach ($data['news_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "news_to_store SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "'");
			}
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'news_id=" . (int)$news_id. "'");
		
		if ($data['keyword']) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'news_id=" . (int)$news_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
		}
		
		$this->cache->delete('news');
	}
	
	public function deleteNews($news_id) {
		$this->db->query("DELETE FROM " . DB_PREFIX . "news WHERE news_id = '" . (int)$news_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "news_description WHERE news_id = '" . (int)$news_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "news_to_store WHERE news_id = '" . (int)$news_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'news_id=" . (int)$news_id . "'");

		$this->cache->delete('news');
	}	

	public function getNews($news_id) {
		$query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'news_id=" . (int)$news_id . "') AS keyword FROM " . DB_PREFIX . "news WHERE news_id = '" . (int)$news_id . "'");
		
		return $query->row;
	}
		
	public function getNewss($data = array()) {
		if ($data) {
			$sql = "SELECT * FROM " . DB_PREFIX . "news i LEFT JOIN " . DB_PREFIX . "news_description id ON (i.news_id = id.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";
		
			$sort_data = array(
				'id.title',
				'i.sort_order'
			);		
		
			if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
				$sql .= " ORDER BY " . $data['sort'];	
			} else {
				$sql .= " ORDER BY id.title";	
			}
			
			if (isset($data['order']) && ($data['order'] == 'DESC')) {
				$sql .= " DESC";
			} else {
				$sql .= " ASC";
			}
		
			if (isset($data['start']) || isset($data['limit'])) {
				if ($data['start'] < 0) {
					$data['start'] = 0;
				}		

				if ($data['limit'] < 1) {
					$data['limit'] = 20;
				}	
			
				$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
			}	
			
			$query = $this->db->query($sql);
			
			return $query->rows;
		} else {
			$news_data = $this->cache->get('news.' . $this->config->get('config_language_id'));
		
			if (!$news_data) {
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "news i LEFT JOIN " . DB_PREFIX . "news_description id ON (i.news_id = id.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");
	
				$news_data = $query->rows;
			
				$this->cache->set('news.' . $this->config->get('config_language_id'), $news_data);
			}	
	
			return $news_data;			
		}
	}
	
	public function getNewsDescriptions($news_id) {
		$news_description_data = array();
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "news_description WHERE news_id = '" . (int)$news_id . "'");

		foreach ($query->rows as $result) {
			$news_description_data[$result['language_id']] = array(
				'title'       => $result['title'],
				'description' => $result['description']
			);
		}
		
		return $news_description_data;
	}
	
	public function getNewsStores($news_id) {
		$news_store_data = array();
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "news_to_store WHERE news_id = '" . (int)$news_id . "'");

		foreach ($query->rows as $result) {
			$news_store_data[] = $result['store_id'];
		}
		
		return $news_store_data;
	}
	
	public function getTotalNewss() {
      	$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "news");
		
		return $query->row['total'];
	}	
}
?>
 

adsl77

OpenCart-TR
Katılım
6 May 2011
Mesajlar
130
Tepkime puanı
0
Puanları
0
Konum
Ankara
biocyn' Alıntı:
adsl77' Alıntı:
bende aynı hatayı alıyorum. değiştirdiğin 2 dosyayı paylaşabilirmisin? dediğin dosyalardaki değişiklikleri yaptım ancak iyice karıştı ve içinden çıkılmaz bir hal aldı. kısacası yapamadım :)

teşekkürler...


admin/controller/catalog/news.php

PHP:
<?php
class ControllerCatalogNews extends Controller { 
	private $error = array();

	public function index() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		 
		$this->load->model('catalog/news');

		$this->getList();
	}

	public function insert() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		
		$this->load->model('catalog/news');
				
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
			$this->model_catalog_news->addnews($this->request->post);
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';
			
			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}
			
			$this->redirect(HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url);
		}

		$this->getForm();
	}

	public function update() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		
		$this->load->model('catalog/news');
		
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
			$this->model_catalog_news->editnews($this->request->get['news_id'], $this->request->post);
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';
			
			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}
			
			$this->redirect(HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url);
		}

		$this->getForm();
	}
 
	public function delete() {
		$this->load->language('catalog/news');

		$this->document->title = $this->language->get('heading_title');
		
		$this->load->model('catalog/news');
		
		if (isset($this->request->post['selected']) && $this->validateDelete()) {
			foreach ($this->request->post['selected'] as $news_id) {
				$this->model_catalog_news->deletenews($news_id);
			}
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';
			
			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}
			
			$this->redirect(HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url);
		}

		$this->getList();
	}

	private function getList() {
		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}
		
		if (isset($this->request->get['sort'])) {
			$sort = $this->request->get['sort'];
		} else {
			$sort = 'id.title';
		}
		
		if (isset($this->request->get['order'])) {
			$order = $this->request->get['order'];
		} else {
			$order = 'ASC';
		}
		
		$url = '';
			
		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

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

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('text_home'),
      		'separator' => FALSE
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url,
       		'text'      => $this->language->get('heading_title'),
      		'separator' => ' :: '
   		);
							
		$this->data['insert'] = HTTPS_SERVER . 'index.php?route=catalog/news/insert&token=' . $this->session->data['token'] . $url;
		$this->data['delete'] = HTTPS_SERVER . 'index.php?route=catalog/news/delete&token=' . $this->session->data['token'] . $url;	

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

		$data = array(
			'sort'  => $sort,
			'order' => $order,
			'start' => ($page - 1) * $this->config->get('config_admin_limit'),
			'limit' => $this->config->get('config_admin_limit')
		);
		
		$news_total = $this->model_catalog_news->getTotalnewss();
	
		$results = $this->model_catalog_news->getnewss($data);
 
    	foreach ($results as $result) {
			$action = array();
						
			$action[] = array(
				'text' => $this->language->get('text_edit'),
				'href' => HTTPS_SERVER . 'index.php?route=catalog/news/update&token=' . $this->session->data['token'] . '&news_id=' . $result['news_id'] . $url
			);
						
			$this->data['newss'][] = array(
				'news_id' => $result['news_id'],
				'title'      => $result['title'],
				'sort_order' => $result['sort_order'],
				'selected'   => isset($this->request->post['selected']) && in_array($result['news_id'], $this->request->post['selected']),
				'action'     => $action
			);
		}	
	
		$this->data['heading_title'] = $this->language->get('heading_title');

		$this->data['text_no_results'] = $this->language->get('text_no_results');

		$this->data['column_title'] = $this->language->get('column_title');
		$this->data['column_sort_order'] = $this->language->get('column_sort_order');
		$this->data['column_action'] = $this->language->get('column_action');		
		
		$this->data['button_insert'] = $this->language->get('button_insert');
		$this->data['button_delete'] = $this->language->get('button_delete');
 
 		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}
		
		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
		
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}

		$url = '';

		if ($order == 'ASC') {
			$url .= '&order=DESC';
		} else {
			$url .= '&order=ASC';
		}

		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}
		
		$this->data['sort_title'] = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . '&sort=id.title' . $url;
		$this->data['sort_sort_order'] = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . '&sort=i.sort_order' . $url;
		
		$url = '';

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}
												
		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}

		$pagination = new Pagination();
		$pagination->total = $news_total;
		$pagination->page = $page;
		$pagination->limit = $this->config->get('config_admin_limit');
		$pagination->text = $this->language->get('text_pagination');
		$pagination->url = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url . '&page={page}';
			
		$this->data['pagination'] = $pagination->render();

		$this->data['sort'] = $sort;
		$this->data['order'] = $order;
		
		$this->template = 'catalog/news_list.tpl';
		$this->children = array(
			'common/header',	
			'common/footer'	
		);
		
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}

	private function getForm() {
		$this->data['heading_title'] = $this->language->get('heading_title');

		$this->data['text_default'] = $this->language->get('text_default');
		$this->data['text_enabled'] = $this->language->get('text_enabled');
    	$this->data['text_disabled'] = $this->language->get('text_disabled');
		
		$this->data['entry_title'] = $this->language->get('entry_title');
		$this->data['entry_description'] = $this->language->get('entry_description');
		$this->data['entry_store'] = $this->language->get('entry_store');
		$this->data['entry_keyword'] = $this->language->get('entry_keyword');
		$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
		$this->data['entry_status'] = $this->language->get('entry_status');
		
		$this->data['button_save'] = $this->language->get('button_save');
		$this->data['button_cancel'] = $this->language->get('button_cancel');

		$this->data['token'] = $this->session->data['token'];

 		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}

 		if (isset($this->error['title'])) {
			$this->data['error_title'] = $this->error['title'];
		} else {
			$this->data['error_title'] = '';
		}
		
	 	if (isset($this->error['description'])) {
			$this->data['error_description'] = $this->error['description'];
		} else {
			$this->data['error_description'] = '';
		}
		
		$url = '';
			
		if (isset($this->request->get['page'])) {
			$url .= '&page=' . $this->request->get['page'];
		}

		if (isset($this->request->get['sort'])) {
			$url .= '&sort=' . $this->request->get['sort'];
		}

		if (isset($this->request->get['order'])) {
			$url .= '&order=' . $this->request->get['order'];
		}
		
  		$this->document->breadcrumbs = array();

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('text_home'),
      		'separator' => FALSE
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url,
       		'text'      => $this->language->get('heading_title'),
      		'separator' => ' :: '
   		);
							
		if (!isset($this->request->get['news_id'])) {
			$this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/news/insert&token=' . $this->session->data['token'] . $url;
		} else {
			$this->data['action'] = HTTPS_SERVER . 'index.php?route=catalog/news/update&token=' . $this->session->data['token'] . '&news_id=' . $this->request->get['news_id'] . $url;
		}
		
		$this->data['cancel'] = HTTPS_SERVER . 'index.php?route=catalog/news&token=' . $this->session->data['token'] . $url;

		if (isset($this->request->get['news_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
			$news_info = $this->model_catalog_news->getnews($this->request->get['news_id']);
		}
		
		$this->load->model('localisation/language');
		
		$this->data['languages'] = $this->model_localisation_language->getLanguages();
		
		if (isset($this->request->post['news_description'])) {
			$this->data['news_description'] = $this->request->post['news_description'];
		} elseif (isset($this->request->get['news_id'])) {
			$this->data['news_description'] = $this->model_catalog_news->getnewsDescriptions($this->request->get['news_id']);
		} else {
			$this->data['news_description'] = array();
		}

		if (isset($this->request->post['status'])) {
			$this->data['status'] = $this->request->post['status'];
		} elseif (isset($news_info)) {
			$this->data['status'] = $news_info['status'];
		} else {
			$this->data['status'] = 1;
		}
		
		$this->load->model('setting/store');
		
		$this->data['stores'] = $this->model_setting_store->getStores();
		
		if (isset($this->request->post['news_store'])) {
			$this->data['news_store'] = $this->request->post['news_store'];
		} elseif (isset($news_info)) {
			$this->data['news_store'] = $this->model_catalog_news->getnewsStores($this->request->get['news_id']);
		} else {
			$this->data['news_store'] = array(0);
		}		
		
		if (isset($this->request->post['keyword'])) {
			$this->data['keyword'] = $this->request->post['keyword'];
		} elseif (isset($news_info)) {
			$this->data['keyword'] = $news_info['keyword'];
		} else {
			$this->data['keyword'] = '';
		}
		
		if (isset($this->request->post['sort_order'])) {
			$this->data['sort_order'] = $this->request->post['sort_order'];
		} elseif (isset($news_info)) {
			$this->data['sort_order'] = $news_info['sort_order'];
		} else {
			$this->data['sort_order'] = '';
		}
		
		$this->template = 'catalog/news_form.tpl';
		$this->children = array(
			'common/header',	
			'common/footer'	
		);
		
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}

	private function validateForm() {
		if (!$this->user->hasPermission('modify', 'catalog/news')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		foreach ($this->request->post['news_description'] as $language_id => $value) {
			if ((strlen(utf8_decode($value['title'])) < 3) || (strlen(utf8_decode($value['title'])) > 250)) {
				$this->error['title'][$language_id] = $this->language->get('error_title');
			}
		
			if (strlen(utf8_decode($value['description'])) < 3) {
				$this->error['description'][$language_id] = $this->language->get('error_description');
			}
		}

		if (!$this->error) {
			return TRUE;
		} else {
			if (!isset($this->error['warning'])) {
				$this->error['warning'] = $this->language->get('error_required_data');
			}
			return FALSE;
		}
	}

	private function validateDelete() {
		if (!$this->user->hasPermission('modify', 'catalog/news')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		$this->load->model('setting/store');
		
		foreach ($this->request->post['selected'] as $news_id) {
			if ($this->config->get('config_account_id') == $news_id) {
				$this->error['warning'] = $this->language->get('error_account');
			}
			
			if ($this->config->get('config_checkout_id') == $news_id) {
				$this->error['warning'] = $this->language->get('error_checkout');
			}
			
			$store_total = $this->model_setting_store->getTotalStoresBynewsId($news_id);

			if ($store_total) {
				$this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
			}
		}

		if (!$this->error) {
			return TRUE;
		} else {
			return FALSE;
		}
	}
}
?>


admin/model/catalog/news.php

PHP:
<?php
class ModelCatalogNews extends Model {
	public function addNews($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "news SET sort_order = '" . (int)$this->request->post['sort_order'] . "', status = '" . (int)$data['status'] . "'");

		$news_id = $this->db->getLastId(); 
			
		foreach ($data['news_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "news_description SET news_id = '" . (int)$news_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "'");
		}
		
		if (isset($data['news_store'])) {
			foreach ($data['news_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "news_to_store SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "'");
			}
		}
		
		if ($data['keyword']) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'news_id=" . (int)$news_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
		}
		
		$this->cache->delete('news');
	}
	
	public function editNews($news_id, $data) {
		$this->db->query("UPDATE " . DB_PREFIX . "news SET sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "' WHERE news_id = '" . (int)$news_id . "'");

		$this->db->query("DELETE FROM " . DB_PREFIX . "news_description WHERE news_id = '" . (int)$news_id . "'");
					
		foreach ($data['news_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "news_description SET news_id = '" . (int)$news_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "'");
		}

		$this->db->query("DELETE FROM " . DB_PREFIX . "news_to_store WHERE news_id = '" . (int)$news_id . "'");
		
		if (isset($data['news_store'])) {
			foreach ($data['news_store'] as $store_id) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "news_to_store SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "'");
			}
		}
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'news_id=" . (int)$news_id. "'");
		
		if ($data['keyword']) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'news_id=" . (int)$news_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
		}
		
		$this->cache->delete('news');
	}
	
	public function deleteNews($news_id) {
		$this->db->query("DELETE FROM " . DB_PREFIX . "news WHERE news_id = '" . (int)$news_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "news_description WHERE news_id = '" . (int)$news_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "news_to_store WHERE news_id = '" . (int)$news_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'news_id=" . (int)$news_id . "'");

		$this->cache->delete('news');
	}	

	public function getNews($news_id) {
		$query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'news_id=" . (int)$news_id . "') AS keyword FROM " . DB_PREFIX . "news WHERE news_id = '" . (int)$news_id . "'");
		
		return $query->row;
	}
		
	public function getNewss($data = array()) {
		if ($data) {
			$sql = "SELECT * FROM " . DB_PREFIX . "news i LEFT JOIN " . DB_PREFIX . "news_description id ON (i.news_id = id.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";
		
			$sort_data = array(
				'id.title',
				'i.sort_order'
			);		
		
			if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
				$sql .= " ORDER BY " . $data['sort'];	
			} else {
				$sql .= " ORDER BY id.title";	
			}
			
			if (isset($data['order']) && ($data['order'] == 'DESC')) {
				$sql .= " DESC";
			} else {
				$sql .= " ASC";
			}
		
			if (isset($data['start']) || isset($data['limit'])) {
				if ($data['start'] < 0) {
					$data['start'] = 0;
				}		

				if ($data['limit'] < 1) {
					$data['limit'] = 20;
				}	
			
				$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
			}	
			
			$query = $this->db->query($sql);
			
			return $query->rows;
		} else {
			$news_data = $this->cache->get('news.' . $this->config->get('config_language_id'));
		
			if (!$news_data) {
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "news i LEFT JOIN " . DB_PREFIX . "news_description id ON (i.news_id = id.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");
	
				$news_data = $query->rows;
			
				$this->cache->set('news.' . $this->config->get('config_language_id'), $news_data);
			}	
	
			return $news_data;			
		}
	}
	
	public function getNewsDescriptions($news_id) {
		$news_description_data = array();
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "news_description WHERE news_id = '" . (int)$news_id . "'");

		foreach ($query->rows as $result) {
			$news_description_data[$result['language_id']] = array(
				'title'       => $result['title'],
				'description' => $result['description']
			);
		}
		
		return $news_description_data;
	}
	
	public function getNewsStores($news_id) {
		$news_store_data = array();
		
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "news_to_store WHERE news_id = '" . (int)$news_id . "'");

		foreach ($query->rows as $result) {
			$news_store_data[] = $result['store_id'];
		}
		
		return $news_store_data;
	}
	
	public function getTotalNewss() {
      	$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "news");
		
		return $query->row['total'];
	}	
}
?>


çok teşekkür ederim sayende yaptım ;)
 

ebadem

OpenCart-TR
Katılım
3 Şub 2011
Mesajlar
28
Tepkime puanı
0
Puanları
0
Hemen hemen tüm yazılanları yaptığımı sanıyorum fakat bi hata alıyorum. Öncelikle bu işlemleri yaptıktan sonra eklentiler sayfasında modüllerd bu modulü görmem gerekiyor mu? Gerekiyorsa bende yok.

Sonrasında katalog haber sayfaları diyorum sayfa açılıyor haber yada makale eklediğimde aşağıdaki hatayıalıyorum neden acaba?

Warning: Cannot modify header information - headers already sent by (output started at /home/ankaofis/public_html/admin/controller/catalog/news.php:454) in /home/ankaofis/public_html/system/engine/controller.php on line 27
 
Üst