Irina Despot
Irina Despot

Reputation: 33

How to handle assets in a Sylius theme?

I'm new to Sylius and I have many issues handling shop customization. My current issue is adding assets (images, css...) to my custom theme. I've tried every way but I can't figure it out. My questions are:

  1. Where are you supposed to put them exactly?
  2. How do you get them to the public folder? I tried the assets:install and sylius:theme:assets:install commands, but since I don't know where to put the files in the first place it didn't really help.
  3. How do you reference them in your templates? I can't find where the asset() function points to.

Context

I've seen similar issues on Stack Overflow but they don't seem relevant to this version of Sylius.

Upvotes: 0

Views: 1690

Answers (1)

sander voogt
sander voogt

Reputation: 71

I've placed the public folder of my assets inside the SyliusShopBundle of the theme. These files are copied to the public folder after the command

sylius:theme:assets:install

is executed.

Here is a image to my folder structure

Here a implementation inside the theme

<div class="column">
<a href="{{ path('sylius_shop_homepage') }}"><img src="{{ asset('bundles/syliusshop/assets/logo_fitfoods.svg') }}" alt="Sylius logo" class="ui small image" /></a>

Upvotes: 2

Related Questions