Sylius: Directory for themes

Created on 10 Oct 2018  Â·  8Comments  Â·  Source: Sylius/Sylius

Hi,
We still need to create our theme in app/themes in Sylius 1.3, but with the new symfony structure, app doesn't exist. (cf: https://docs.sylius.com/en/1.3/components_and_bundles/bundles/SyliusThemeBundle/your_first_theme.html)
As @pamil said on slack :
It'll be better to use the templates directory or create a top level directory themes.

Sylius version
1.3

Describe the proposed solution
Use the templates directory like templates/themes

Describe alternatives you've considered
Or create a top level directory themes

Most helpful comment

@pamil I change my PR #9814 to get this fact as default.

So app/themes/ default value will become themes/.

All 8 comments

It should be probably resolved by https://github.com/Sylius/Sylius/pull/9804? cc @pamil

@Zales0123 not really, #9804 solves templates resolving, their location is another issue to solve.

I just made a PR #9814 to change this.

The default path : %kernel.project_dir%/app/themes has to be changed in Sylius\Bundle\ThemeBundle\Configuration\Filesystem\FilesystemConfigurationSourceFactory, in all a test file, and documentation.

I use this conf now to get ride of this bug :

# config/packages/sylius_theme.yaml
sylius_theme:
    sources:
        filesystem:
            directories:
                - "%kernel.project_dir%/templates/themes"

I agree that templates/themes should be the new place for themes. We also need a better doc on how to build a theme with a real and updated theme skeleton.

After giving it some thought, I would vote for top-level themes/ directory. templates/themes/ does not look like the best place for themes, because they also contain translations and assets, which might be misleading when under templates/ directory.

My first thought was the same as yours but the templates dir is already used by SF users as the default place to override things.
If there is a root themes dir it means that you want to composer require themes outside the vendor dir when some customs themes will be available in a Bundle.

Is there any custom themes already available somewhere ?

Themes are mostly proprietary and made-on-demand because most of the stores need their own, unique theme.

Symfony 4 structure contains assets/, templates/ and translations/ root directories. Themes contain all of these resources (also using the old nomenclature, assets -> public and templates -> views).

With templates/themes/ there are the following issues:

  • translations and assets are under templates/ instead of their dedicated directories which is counter-intuitive
  • the structure for templates is also different than templates/bundles/:

    • overriding a bundle template templates/bundles/FooBundle/template.html.twig in a theme would be templates/themes/ThemeName/FooBundle/views/template.html.twig - so there's views directory out of nowhere

If your themes are installed via Composer, it's needed to specify that path in your sylius_theme configuration.

@pamil I change my PR #9814 to get this fact as default.

So app/themes/ default value will become themes/.

will theme directory reflect new flex directory?

Was this page helpful?
0 / 5 - 0 ratings