theme_config.XXX.enabled or theme_config.XXX == true works in different way

Hi

I have in blueprints.yaml in my theme the following:

latestposts:
      type: toggle
      label: Enable Latest Post in Sidebar
      highlight: 1
      default: 1
      options:
        1: PLUGIN_ADMIN.ENABLED
        0: PLUGIN_ADMIN.DISABLED
      validate:
        type: bool

If I want to filter the content if it is activated or deactivated (with if sentence), with theme_config.latestposts.enabled it does not work, however with theme_config.latestposts == true it works correctly.

Why is this happening? Is there something I am doing wrong?

Thanks.

Why would you assume .enabled should work?
config.latestposts is a boolean values as you have defined in blueprint

      default: 1
      options:
        1: PLUGIN_ADMIN.ENABLED
        0: PLUGIN_ADMIN.DISABLED
      validate:
        type: bool

And default value is true

The selection is not the names, but the keys - 0 and 1
If you had

      default: enabled
      options:
        enabled: PLUGIN_ADMIN.ENABLED
        disabled: PLUGIN_ADMIN.DISABLED

then it would be config.latestposts == 'enabled' or config.latestposts == 'disabled'

@pmoreno,

Extending on the answer of @Karmalakas

Mark the difference in variables used:

  • Variable theme_config.latestposts.enabled does not exist.
    Twig happily ignores/silences this issue by the way…
  • Variable theme_config.latestposts does exist.

Hello

I thought that it could be done the same as when we want to execute some code depending on whether a plugin is activated or not (config.plugins.XXX.enabled).

Thanks for your help