Page 1 of 2

Separate tree, search and attribute from filter component

Posted: 13 Aug 2017, 17:58
by devyk
I would like to display categories tree as main menu, attributes lists as right column at list page and display search field in the header section.

I see the only way to do it just by reimplementing this subparts as separate components. Is it right solution for the task or there is better method to deal with this?

Re: Separate tree, search and attribute from filter componen

Posted: 14 Aug 2017, 09:11
by aimeos
Which integration are you using?

Re: Separate tree, search and attribute from filter componen

Posted: 14 Aug 2017, 11:00
by devyk
I'm using laravel integration.

Re: Separate tree, search and attribute from filter componen

Posted: 15 Aug 2017, 08:44
by aimeos
The easiest way is to add the catalog filter components three times in your controller action, each with a different configuration for the subparts. In the template, you can then put the output of each component/subpart at a different place.

You should have a look at the "Page" object in the Aimeos Laravel integration to see how to instantiate components on your own:
https://github.com/aimeos/aimeos-larave ... ge.php#L74

Re: Separate tree, search and attribute from filter componen

Posted: 15 Aug 2017, 19:28
by devyk
I see from your method that this components will be available for a single action only, which is not suitable for my task. I have a global header, so this components should be available on multiple pages. Overriding each action seems to be a bad solution.

I'm thinking about overriding components factory, to make it able to use some sort of aliases.
For example I can specify

client/html/alias/<alias for component>/base/<original_component>
client/html/alias/<alias for component>/override/<original_component_config_option_path>

and configure my page to use 'alias/<alias for component>'. Then the factory will figure out that alias is requested and will populate context config with alias values. After all the factory will produce original component with alias configuration.

What you think?

Re: Separate tree, search and attribute from filter componen

Posted: 15 Aug 2017, 19:54
by devyk
Another possible solution is extend base component and override the getSubClientNames() method in way like this.
Component properties are private that's why more elegant solution is not possible, which is a little bit weird. (or component classes are not supposed to be extended?).

Code: Select all

    protected function getSubClientNames()
    {
        return $this->getContext()->getConfig()->get('client/html/catalog/navigation/standard/subparts', ['search']);
    }
UPD:
found a better solution

Code: Select all

<?php

namespace Aimeos\Client\Html\Catalog\Search;

class Factory implements \Aimeos\Client\Html\Common\Factory\Iface
{
    public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null )
    {
        $context->getConfig()->set('client/html/catalog/filter/standard/subparts', ['search'] );

        return \Aimeos\Client\Html\Catalog\Filter\Factory::createClient($context, $templatePaths, $name);
    }
}

Re: Separate tree, search and attribute from filter componen

Posted: 06 Sep 2018, 07:41
by mmm
Hi devyk,
Can you post the complete solution implementation as I am also trying to achieve the same but not so experienced with the aimeos yet.
Thanks in advance/
Mubashir

Re: Separate tree, search and attribute from filter componen

Posted: 06 Sep 2018, 12:55
by aimeos
The parts of the catalog/filter component are already available as single components:
- catalog/attribute
- catalog/search
- catalog/tree

Please have a look into the docs how you can use them in your pages:
https://aimeos.org/docs/Laravel/Adapt_pages

Re: Separate tree, search and attribute from filter componen

Posted: 09 Sep 2018, 08:02
by mmm
Thanks, now i can create new components .

However in order to get it working I added missing 'getBody()' function in client's Standard.php
files .

Re: Separate tree, search and attribute from filter componen

Posted: 09 Sep 2018, 22:00
by aimeos
Which HTML client are you talking about?