raindropdevs / RaindropSonataThemeBundle

Raindrop themes bundle for SonataAdminBundle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variable "raindrop_sonata_theme" does not exist

edertxodev opened this issue · comments

Hi,

Recently I've installed this Bundle in my Symfony 2.8 application, and after configure, it shows this error:

Variable "raindrop_sonata_theme" does not exist.

in vendor/raindrop/sonata-theme-bundle/Raindrop/SonataThemeBundle/Resources/views/standard_layout.html.twig at line 38  -
{% for stylesheet in sonata_admin.adminPool.getOption('stylesheets', []) %}
  <link rel="stylesheet" href="{{ asset(stylesheet) }}">
{% endfor %}
  <link rel="stylesheet" href="{{ asset('bundles/raindropsonatatheme/css/themes/' ~ raindrop_sonata_theme ~ '/bootstrap.min.css') }}" type="text/css" media="all" />
{% endblock %}
{% block javascripts %}

I follow the steps to configure it properly.

composer.json:

"sonata-project/admin-bundle": "^3.19",
"raindrop/sonata-theme-bundle": "dev-master"

Hope somebody can help me

did you activate the bundle?

Yes, sure, in AppKernel.php. That's what you say?

yes.
it looks like the twig extension is not exposing that variable.
i don't know exactly what's wrong, maybe the deprecation of the twig extension.
to solve it, you could mimic the functioning of the twig extension by exposing the variable inside the template, that variable contains the theme label.

see Twig\Extension.php:

public function getGlobals() { return array( 'raindrop_sonata_theme' => $this->theme ); }

Yes, I did it on my own Twig extension class and it works.

Thanks a lot! :)

no problem.
i re-set the issue as open since it still requires a solution

Hello, any news on this issue? I am receiving the same error and I can't use the bundle.
Is there a temporary workaround?

Thanks.

haven't fixed yet.
the workaround is 3 comments above: just expose the 'raindrop_sonata_theme' variable as a twig global

Could you please explain to me what should I do? Do I need to create a Twig Extension or I just need to set the variable as global?
Where should I put the file?

Thanks.

you can just set the variable as global

What should I put as value?

# app/config/config.yml
twig:
    globals:
        raindrop_sonata_theme: '???'

the name of the theme

Thank you! Now it's working fine:

# app/config/config.yml

parameters:
    locale: en
    raindrop_sonata_theme: flatly

twig:
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    globals:
        raindrop_sonata_theme: '%raindrop_sonata_theme%'

raindrop_sonata_theme:
    theme: '%raindrop_sonata_theme%'

The only thing it's that the theme is not changing the sidebar color, do you know why?

Thanks.

This fix also works on Symfony 3.3

You should add to the doc

Thank's!!