Post by yegga » Wed Sep 30, 2009 5:45 am

Hello, I would like one of my categories from not showing up in the sidebar (the columns). How do I do this? I tied putting the sort order as -1 but this doesn't help.

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by Qphoria » Wed Sep 30, 2009 7:40 am

Very easy:

1. EDIT: catalog/model/catalog/category.php
2. FIND:

Code: Select all

public function getCategories($parent_id = 0) {
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "' ORDER BY c.sort_order");

	return $query->rows;
}
3. REPLACE WITH:

Code: Select all

public function getCategories($parent_id = 0) {
	$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "' AND c.sort_order <> '-1' ORDER BY c.sort_order");

	return $query->rows;
}
Now just set the sort order to -1 for all the ones you don't want to show.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by yegga » Wed Sep 30, 2009 2:34 pm

Qphoria for the win!

And how do I do the same for the information module? i.e, have a page in the module but not have it show up in the sidebar?

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by Qphoria » Wed Sep 30, 2009 7:32 pm

1. EDIT: catalog/model/catalog/information.php
2. FIND:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->language->getId() . "' ORDER BY i.sort_order ASC");
3. REPLACE WITH:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->language->getId() . "' AND i.sort_order <> '-1' ORDER BY i.sort_order ASC");
Then set the sort to -1 to hide it from the sidebox.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by yegga » Wed Sep 30, 2009 9:07 pm

Thanks Q!

Active Member

Posts

Joined
Tue Sep 08, 2009 5:03 am

Post by thinkingforward » Thu Feb 11, 2010 2:06 am

Worked a treat, thanks very much!:)

Active Member

Posts

Joined
Wed Nov 25, 2009 2:55 am


Post by gartheman » Thu Feb 18, 2010 9:27 pm

Qphoria wrote:1. EDIT: catalog/model/catalog/information.php
2. FIND:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->language->getId() . "' ORDER BY i.sort_order ASC");
3. REPLACE WITH:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->language->getId() . "' AND i.sort_order <> '-1' ORDER BY i.sort_order ASC");
Then set the sort to -1 to hide it from the sidebox.
when I try this i'm getting the following error:

Fatal error: Call to undefined method Language::getId() in C:\xampp\htdocs\catalog\model\catalog\information.php on line 10

any ideas?

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Post by fido-x » Thu Feb 18, 2010 9:33 pm

The code placed here is for version 1.3.4. You're using 1.4.0, so you'll need to use the following as the replacement code:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i.sort_order <> '-1' ORDER BY i.sort_order ASC");

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by gartheman » Fri Feb 19, 2010 4:59 pm

fido-x wrote:The code placed here is for version 1.3.4. You're using 1.4.0, so you'll need to use the following as the replacement code:

Code: Select all

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i.sort_order <> '-1' ORDER BY i.sort_order ASC");
hey fido, this doesn't seem to have any effect at all. maybe it's because i'm trying to hide the sitemap, i don't think it's treated as a regular category

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Post by fido-x » Fri Feb 19, 2010 5:11 pm

gartheman wrote:hey fido, this doesn't seem to have any effect at all. maybe it's because i'm trying to hide the sitemap, i don't think it's treated as a regular category
Got rid of the error, didn't it?

OK, you want to hide the sitemap. Maybe you should have said that in the first place, 'cos that's different. In "catalog/view/theme/YOUR_TEMPLATE/template/module/information.tpl", delete the following line (line 9 in the default):-

Code: Select all

<li><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by gartheman » Fri Feb 19, 2010 5:24 pm

fido-x wrote:
gartheman wrote:hey fido, this doesn't seem to have any effect at all. maybe it's because i'm trying to hide the sitemap, i don't think it's treated as a regular category
Got rid of the error, didn't it?

OK, you want to hide the sitemap. Maybe you should have said that in the first place, 'cos that's different. In "catalog/view/theme/YOUR_TEMPLATE/template/module/information.tpl", delete the following line (line 9 in the default):-

Code: Select all

<li><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
actually yeah, it did fix the error ;)

sorry, only realised after that what I was trying to do was different to just hiding a link in information

thanks again

New member

Posts

Joined
Tue Feb 16, 2010 5:12 pm

Post by cmrukcom » Sat Mar 27, 2010 1:56 am

Editing catalog/model/catalog/information.php to add the extra exclusion of categories with sort order '-1' doesn't seem to work in 1.4.4:

Code: Select all

<?php
class ModelCatalogInformation extends Model {
	public function getInformation($information_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.information_id = '" . (int)$information_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "'" AND i.sort_order <> '-1' );
	
		return $query->row;
	}
	
	public function getInformations() {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.sort_order <> '-1'  ORDER BY i.sort_order, id.title ASC");
		
		return $query->rows;
	}
}
?>
I'd like to hide a couple of categories from the category sidebox so that I can leverage them for putting in a special category for slideshows or featured lists etc. I would have guessed that this is a fairly common requirement but it all hinges on being able to create hidden 'virtual' categories for behind the scenes product groupings.

Any ideas what we need to do in 1.4.4 ?

K

New member

Posts

Joined
Wed Mar 24, 2010 11:34 am

Post by Qphoria » Sat Mar 27, 2010 1:59 am

It works exactly the same

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by cmrukcom » Sat Mar 27, 2010 2:28 am

Does anyone have it working in 1.4.4 - I have been over this a number of times (corrected syntax error in the posting above) and it is still not working.

Thanks

New member

Posts

Joined
Wed Mar 24, 2010 11:34 am

Post by Qphoria » Sat Mar 27, 2010 2:33 am

Well you are using the "information" example but talking about "categories". They are 2 different things. Same process but different files

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by cmrukcom » Sat Mar 27, 2010 3:36 pm

Sorry I hadn't noticed that the thread changed halfway through from talking about categories to information boxes.

All fixed now and I see that Q has also used the same protocol to hide categories in his CMS - perhaps this mod could be rolled into the core as a standard way of leveraging sort order to hide.

New member

Posts

Joined
Wed Mar 24, 2010 11:34 am

Post by diggydog » Thu Jul 15, 2010 7:04 pm

Hi,

Is there an similar tweak that can be applied to category on version 1.48b? The code is a little different to that of 1.4 whereby c.status determines whether the category is functional or not. If it is not enabled it also cannot be displayed regardless of not being in the list (i.e. by typing the url)

Code: Select all

public function getCategories($parent_id = 0) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "'  AND c.status = '1' ORDER BY c.sort_order, LCASE(cd.name)");
		
		return $query->rows;
	}
Guidance would be most welcome.

Thanks

Diggydog
http://www.promoteyourproducts.co.uk


Newbie

Posts

Joined
Thu Apr 29, 2010 6:24 pm
Location - UK

Post by Qphoria » Fri Jul 16, 2010 12:08 am

just add

Code: Select all

 AND c.sort_order <> '-1'
right before

Code: Select all

ORDER BY
and set the sort_order to -1 to hide from the side

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by diggydog » Fri Jul 16, 2010 5:01 pm

Perfect, Thanks Q

Diggydog
http://www.promoteyourproducts.co.uk


Newbie

Posts

Joined
Thu Apr 29, 2010 6:24 pm
Location - UK

Post by namasy » Sun Aug 01, 2010 11:04 am

plz i need hide some links from the list of information v1.4.8b

how?

Newbie

Posts

Joined
Thu Apr 01, 2010 6:22 am
Who is online

Users browsing this forum: No registered users and 21 guests