Welcome to the THELIA support and discusssion forum


Rejoignez la communauté sur le Discord Thelia :


#1 Multi network eshop

(11-09-2018 08:41:43)

I will like to have one main shop on and I will like to have a subdomain for it like ,
Is this possible?

   - All modules need to be shared
  - Database shared
  - Different configuration ( templates, maibe hooks and loops)

If you have/propose a different approach  I'm open

Br. ,

Last edited by lucian.criste (11-09-2018 08:44:17)


#2 Re: Multi network eshop

(11-09-2018 09:19:16)

You can do it with a couple of simple modules. The basic idea is to associate a template to a domain (or subdomain), then listen to kernel events to set the template related to the current domain when a request is submitted.

To switch the current front template, you can use the TemplateSwitcher module : … stener.php

Then in your module create a listener which listens to KernelEvents::REQUEST or KernelEvents::CONTROLLER events, something like :

namespace YourModule\Listener;

use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use TemplateSwitcher\Event\TemplateSwitcherEvent;

class KernelListener implements EventSubscriberInterface
    /** @var RequestStack */
    protected $requestStack;

    /** @var Container */
    protected $dispatcher;

     * KernelListener constructor.
     * @param RequestStack $requestStack
     * @param EventDispatcherInterface $dispatcher
    public function __construct(RequestStack $requestStack, EventDispatcherInterface $dispatcher) {
        $this->dispatcher = $dispatcher;
        $this->requestStack = $requestStack;

     * @param FilterControllerEvent $event
    public function controller(FilterControllerEvent $event)
        $request = $this->requestStack->getCurrentRequest();

        $serverName = $request->getHost();

        // Find the template related to the current server name (e.g., domain)
        $frontTemplateName = ...

        // Set the front template for the current user using the TemplateSwitcher module
            new TemplateSwitcherEvent($frontTemplateName)

     * @inheritDoc
    public static function getSubscribedEvents()
        return [
            KernelEvents::CONTROLLER => ['controller', 192],

This way, you can share modules and data between several templates and domains.

OpenStudio Toulouse


#3 Re: Multi network eshop

(11-09-2018 11:38:12)

Thanks for the quick response!
I will try to implement this , if i get block somewhere I will ask you again to help me .