Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Blueprints function call for theme settings

Solved by Ole Vik View solution

Started by grund 5 years ago · 2 replies · 702 views
5 years ago

I'm trying to get the data from a theme settings selectize into a page blueprint select. So far i haven't found anything on the topic but my PHP knowledge is quite limited and i might missed something. i tried something like

YAML
categories:
        type: selectize
        size: large
        label: Categories
        classes: fancy
        help: PLUGIN_ADMIN.TAXONOMY_TYPES_HELP
        validate:
          type: commalist

into something like that

YAML
 project.category:
          type: select
          label: Select one of the following
          '@data-options': '\Grav\Themes\themename\settings::categories'
          options:
            '/': DATA-OPTIONS

Anyone can give me hint how to achieve this?

5 years ago Solution

You only specify the options-property once, I think subsequent definitions may override it. config-options@: theme.variable is valid, and assumes a variable is set in mytheme.yaml that contains a hash/dictionary (YAML), equivalent to an associated array (PHP).

However, a selectize stores a plain list/array, which does not have named keys for its values. That means that when the order of the selectize's stored values changes, the numerical values for the select no longer match. You'd need to limit the Category-values in selectize to a known quantity, so that the options for the select matches.

A concrete example of seemingly exactly what you're wanting to achieve is in the Project Space Theme. Wherein a static function retrieves a list of categories from config and uses them in the blueprint. The categories are defined in a selectize.

5 years ago

Thank you, the solution does work pretty well.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1144 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago