Post by Dieter » Wed Sep 10, 2008 7:02 pm

Hi guys,

I have a question regarding my site: http://fan2c.com/collections
The thing is that I only want to show the categories who have sort_code 0 on the left menu (under collections)
and the same list on the right hand side as well.

I want to do the same on another page but then with products who have a different sort_code

Does anyone know how to do this?
I suppose it has to be changed in the category.php file but I couldn't find it

Thx,

Dieter

Newbie

Posts

Joined
Wed Sep 10, 2008 6:57 pm

Post by fido-x » Wed Sep 10, 2008 7:35 pm

You could try editing "catalog/extension/module/category.php".
Changing

Code: Select all

$results = $database->getRows("select c.category_id, cd.name from category c left join category_description cd on (c.category_id = cd.category_id) where parent_id = '0' and language_id = '" . (int)$language->getId() . "' order by c.sort_order");
to

Code: Select all

$results = $database->getRows("select c.category_id, cd.name from category c left join category_description cd on (c.category_id = cd.category_id) where parent_id = '0' and language_id = '" . (int)$language->getId() . "' and c.sort_order = '0' order by c.category_id");
should achieve the results you want.

Regards, Fido-X.

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 Dieter » Wed Sep 10, 2008 8:16 pm

Thanks, that's already half the solution ...

The menu on the left is now OK but all the categories are still showing up on the right side
(The reason why i couldn't figure out the menu part is becuase i was working on the wrong category.php file

Cheers

Newbie

Posts

Joined
Wed Sep 10, 2008 6:57 pm

Post by fido-x » Wed Sep 10, 2008 8:37 pm

Make a similar change to "catalog/controller/category.php" - somewhere around line 50.

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 Dieter » Wed Sep 10, 2008 10:08 pm

Sorry, can't seem to get it working

Newbie

Posts

Joined
Wed Sep 10, 2008 6:57 pm

Post by bruce » Wed Sep 10, 2008 10:35 pm

I have a suspicion that hacking one file to do two jobs will not work.

Instead, change the category.php to produce the left hand list with 0 sort order then...

Create a new module using copies of all the files used by category in the catalog area only and give it a new name. Then you can have a completely independant dataset.

With what I am showing you, the module does not even need to be installed in the admin and so will not appear on each page.
In the controller you want it to display from, put something similar to the following line.

Code: Select all

		$template->set('workflow_steps', $module->fetchOne('workflowstep'));  // Experimental call to a single module, not necessarily installed.
		$template->set($module->fetch());
		$response->set($template->fetch('layout.tpl'));
add the following to library\cart\module.php

Code: Select all

	//
	// Experimental, to fetch a module that exists but is not actually installed.
	//
	function fetchOne($code)
	{
		$file  = DIR_EXTENSION . 'module' . '/' . $code . '.php';
		$class = 'Module' . str_replace('_', '', $code);

		if (file_exists($file))
		{
			require_once($file);
			$obj = new $class($this->locator);
		}
		$module_data = array();
		$module = $obj->fetch();
		if ($module)
		{
			$module_data = $module;
		}
		return $module_data;
	}
and in the target template, at the desired location, something like

Code: Select all

		<?php if (isset($workflow_steps)) { ?>
			<?php echo $workflow_steps; ?>
		<?php } ?>

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm
Who is online

Users browsing this forum: No registered users and 3 guests