Separate tree, search and attribute from filter component

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
devyk
Posts: 4
Joined: 13 Aug 2017, 17:44

Separate tree, search and attribute from filter component

Post by devyk » 13 Aug 2017, 17:58

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?

User avatar
aimeos
Administrator
Posts: 7820
Joined: 01 Jan 1970, 00:00

Re: Separate tree, search and attribute from filter componen

Post by aimeos » 14 Aug 2017, 09:11

Which integration are you using?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

devyk
Posts: 4
Joined: 13 Aug 2017, 17:44

Re: Separate tree, search and attribute from filter componen

Post by devyk » 14 Aug 2017, 11:00

I'm using laravel integration.

User avatar
aimeos
Administrator
Posts: 7820
Joined: 01 Jan 1970, 00:00

Re: Separate tree, search and attribute from filter componen

Post by aimeos » 15 Aug 2017, 08:44

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

devyk
Posts: 4
Joined: 13 Aug 2017, 17:44

Re: Separate tree, search and attribute from filter componen

Post by devyk » 15 Aug 2017, 19:28

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?

devyk
Posts: 4
Joined: 13 Aug 2017, 17:44

Re: Separate tree, search and attribute from filter componen

Post by devyk » 15 Aug 2017, 19:54

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);
    }
}

mmm
Posts: 19
Joined: 07 Aug 2018, 07:01

Re: Separate tree, search and attribute from filter componen

Post by mmm » 06 Sep 2018, 07:41

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

User avatar
aimeos
Administrator
Posts: 7820
Joined: 01 Jan 1970, 00:00

Re: Separate tree, search and attribute from filter componen

Post by aimeos » 06 Sep 2018, 12:55

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mmm
Posts: 19
Joined: 07 Aug 2018, 07:01

Re: Separate tree, search and attribute from filter componen

Post by mmm » 09 Sep 2018, 08:02

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 .

User avatar
aimeos
Administrator
Posts: 7820
Joined: 01 Jan 1970, 00:00

Re: Separate tree, search and attribute from filter componen

Post by aimeos » 09 Sep 2018, 22:00

Which HTML client are you talking about?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply