Page 1 of 2

A way to exclude one or more categories from the columns?

Posted: Wed Sep 30, 2009 5:45 am
by yegga
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.

Re: A way to exclude one or more categories from the columns?

Posted: Wed Sep 30, 2009 7:40 am
by Qphoria
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.

Re: A way to exclude one or more categories from the columns?

Posted: Wed Sep 30, 2009 2:34 pm
by yegga
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?

Re: A way to exclude one or more categories from the columns?

Posted: Wed Sep 30, 2009 7:32 pm
by Qphoria
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.

Re: A way to exclude one or more categories from the columns?

Posted: Wed Sep 30, 2009 9:07 pm
by yegga
Thanks Q!

Re: A way to exclude one or more categories from the columns?

Posted: Thu Feb 11, 2010 2:06 am
by thinkingforward
Worked a treat, thanks very much!:)

Re: A way to exclude one or more categories from the columns?

Posted: Thu Feb 18, 2010 9:27 pm
by gartheman
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?

Re: A way to exclude one or more categories from the columns?

Posted: Thu Feb 18, 2010 9:33 pm
by fido-x
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");

Re: A way to exclude one or more categories from the columns?

Posted: Fri Feb 19, 2010 4:59 pm
by gartheman
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

Re: A way to exclude one or more categories from the columns?

Posted: Fri Feb 19, 2010 5:11 pm
by fido-x
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>

Re: A way to exclude one or more categories from the columns?

Posted: Fri Feb 19, 2010 5:24 pm
by gartheman
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

Re: A way to exclude one or more categories from the columns?

Posted: Sat Mar 27, 2010 1:56 am
by cmrukcom
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

Re: A way to exclude one or more categories from the columns?

Posted: Sat Mar 27, 2010 1:59 am
by Qphoria
It works exactly the same

Re: A way to exclude one or more categories from the columns?

Posted: Sat Mar 27, 2010 2:28 am
by cmrukcom
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

Re: A way to exclude one or more categories from the columns?

Posted: Sat Mar 27, 2010 2:33 am
by Qphoria
Well you are using the "information" example but talking about "categories". They are 2 different things. Same process but different files

Re: A way to exclude one or more categories from the columns?

Posted: Sat Mar 27, 2010 3:36 pm
by cmrukcom
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.

Re: A way to exclude one or more categories from the columns

Posted: Thu Jul 15, 2010 7:04 pm
by diggydog
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

Re: A way to exclude one or more categories from the columns

Posted: Fri Jul 16, 2010 12:08 am
by Qphoria
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

Re: A way to exclude one or more categories from the columns

Posted: Fri Jul 16, 2010 5:01 pm
by diggydog
Perfect, Thanks Q

Re: A way to exclude one or more categories from the columns

Posted: Sun Aug 01, 2010 11:04 am
by namasy
plz i need hide some links from the list of information v1.4.8b

how?