What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hey guys π We have an application with 2 stores (DE, UK). In a molecule I cre
Hey guys π
We have an application with 2 stores (DE, UK). In a molecule I created I want to load a different twig template depending on the active store. How can I do that?
If not possible how could I use the same twig template but show different content depending on the active store? (would be a bad solution because there will be more stores in the future)
Thanks for helping π
Comments
-
have you tried the βcodebucketβ approach?
0 -
where you can put the template in a store-specific module extension?
0 -
like
FoobarDE/β¦/template.twig
0 -
not 100% sure this is correct, but worth a quick try
0 -
I have this path:
src\Pyz\Yves\ShopUi\Theme*default*\components\molecules\my-module\my-module.twigI tried to create these 2 versions:
src\Pyz\Yves\ShopUi\Theme*DE\components\molecules\my-module\my-module.twig
src\Pyz\Yves\ShopUi\Theme*UK\components\molecules\my-module\my-module.twigBut they are not used, the application always uses the default one
0 -
nope, try more like
src\Pyz\Yves\ShopUiDE\Theme\components\molecules\my-module\my-module.twig
0 -
but that is also not only working for templates
0 -
i can give you a bit better approach after my meeting
0 -
That would be great, I am waiting for you. Thank you a lot π
0 -
If we need to have just different templates: use Marko`s approach
But if you want to have a different content: depends on the content.F.e. if it is some dynamic content (like prices etc) - it is ok.
If content totally different - could be better to use different approach in general
0 -
Like different CMS blocks structure and relate blocks to proper stores
0 -
maybe you can already elaborate on your scenario in the meantime, @U010MP7GCTV
0 -
I tried this structure
src\Pyz\Yves\ShopUiDE\Theme\components\molecules\my-module\my-module.twig
src\Pyz\Yves\ShopUiUK\Theme\components\molecules\my-module\my-module.twig... and also this ...
src\Pyz\Yves\ShopUiDE\Theme\default\components\molecules\my-module\my-module.twig
src\Pyz\Yves\ShopUiUK\Theme\components\default\molecules\my-module\my-module.twig.. cleared the cache and did a frontend build but it's still taking the default one π
0 -
and it is just about the template, right?
0 -
Yep right π
0 -
k, got it. gimme a minute
0 -
Okay thank you
0 -
so, what you have to do is put the template to
0 -
src/Pyz/Yves/ShopUi/Theme/DE/components/molecules/footer-logo/footer-logo.twig
, assuming this should only be valid forDE
0 -
whereas
DE
in this path actually refers to an alternative theme and does not necessarily have to be identical to the store0 -
and then!
0 -
you have to extend the according twig config in shared to use that theme
0 -
<?php namespace Pyz\Shared\TwigDE; use Spryker\Shared\Twig\TwigConfig as SprykerTwigConfig; class TwigConfig extends SprykerTwigConfig { /** * @return string */ public function getYvesThemeName(): string { return 'DE'; } }
0 -
hope that helps
0 -
for the assets there was another step involved π€
0 -
Hey Marco, the theme seperation worked, I get the DE molecule in the DE shop now.
Unfortunately the asset Urls are wrong. The app tries to load:
/assets/DE/DE/css/yves_default.app.cssinstead of
/assets/DE/default/css/yves_default.app.cssI already created the frontend build config as it is described in the link you posted
0 -
doesnβt work? π€
0 -
It compiles the DE assets to ".../DE/default/"
but tries to load them in the browser from ".../DE/DE/"
0 -
works perfeclty fine for me π€
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random