Jump to content

blocklayered in product-list.tpl


Recommended Posts

Hi all, it is possible filtering like in screen?

 

layered.jpg

 

 

I tried create hook and hook him.

public function hookdisplayTop3()
{
if(!$this->_prepareHook())
return;

// Check if not a mobile theme
if ($this->context->getMobileDevice() != false)
return false;
}	 

But doesnt work.

 

Link to comment
Share on other sites

1. i create a hook (in db and frontcontroler)

2. in module i insert this

public function hookdisplayTop3()
{
if(!$this->_prepareHook())
return;

// Check if not a mobile theme
if ($this->context->getMobileDevice() != false)
return false;
}	

3. i insert this code for show module in category.tpl

<div class="layered">{$HOOK_TOP3}</div>

But doesnt work. I have a blank page.

and this

Fatal error: Call to undefined method BlockLayered::_prepareHook() in /home/www/sirer.cz/www/sirer.cz/bike/modules/blocklayered/blocklayered.php on line 55
Link to comment
Share on other sites

Thanks. I reinstall module and in module i insert this

public function hookdisplayTop3()
{

// Check if not a mobile theme
if ($this->context->getMobileDevice() != false)
return false;
}	

Nothing happend. Problem is still there.

 

edit: so i need create it like this?

class/controller/FrontController.php

if (!isset($this->context->cart))
				$this->context->cart = new Cart();
			$this->context->smarty->assign(array(
				'HOOK_HEADER' => Hook::exec('displayHeader'),
				'HOOK_TOP' => Hook::exec('displayTop'),
				'HOOK_TOP2' => Hook::exec('displayTop2'),
				'HOOK_TOP3' => Hook::exec('displayTop3'),
                                'HOOK_prepare' => Hook::exec('_prepareHook'),
Edited by tozi (see edit history)
Link to comment
Share on other sites

Nothing happens for hookdisplayTop3 because you don't return anything, so nothing to display.

 

What is this for:

'HOOK_prepare' => Hook::exec('_prepareHook'),

The fatal error you had meant that the module doesn't have the '_prepareHook' function. That function needs to be inside the module, not as a hook.

 

Regards.

Robin.

The CartExpert Team

Link to comment
Share on other sites

First of all, decide where you want the module to be displayed.

If there is no hook there you create one. Let's call it myTestHook.

You add myTestHook to the database.

Then you need to execute the hook in the controller. e.g. the FrontController Hook::exec('myTestHook')

The function for this has to be created in the module, so you will have a function named 'hookMyTestHook', which can have a return value, or not.

In your case, you want a return value, because you want to display the layered filter. Hook::exec('myTestHook') must be assigned to the template, just like  Hook::exec('leftColumn') is.

Now you need to place {$HOOK_MY_TEST_HOOK} in the tpl file where you want the module to be displayed.

Finally, you need to transplant your module to the hook.

 

You can just duplicate the hookLeftColumn function of the module, rename it to match the new hook's name, instead of creating new a function from scratch.

 

But for this you must have a basic concept of coding, like functions returning value, OOP etc.

 

Regards.

Robin.

The CartExpert Team

Edited by CartExpert.net (see edit history)
Link to comment
Share on other sites

I did it but still not working.  :(

 

I copy function and rename

	public function hookdisplayTop3($params)
	{
		return $this->generateFiltersBlock($this->getSelectedFilters());
	}

And insert this before install

	
public function hookdisplayTop3()
{
return $this->hookLeftColumn();
}	
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...