Hi, folks.

There's an example in the template.xml file for setting complex variables:

    <!-- Recommended way of defining complex variables -->   
    <variable name="theme_settings">
      <toggle_node_info_page>0</toggle_node_info_page>
      <toggle_node_info_example>0</toggle_node_info_example>
      <toggle_node_info_blog>1</toggle_node_info_blog>
      <toggle_favicon>0</toggle_favicon>
    </variable>

Is there a similar way to set complex variables in yaml? What I've tried hasn't worked so far:

  - tag: variable
      name: theme_settings
      value:
       toggle_node_info_page: 0
       toggle_node_info_story: 1
       toggle_favicon: 0

Thanks for your help!

Comments

vaish’s picture

This would be the correct syntax:

  - tag: variable
      name: theme_settings
      toggle_node_info_page: 0
      toggle_node_info_story: 1
      toggle_favicon: 0   

Some background:
Currently all the XML attributes are treated just as XML tags so following two examples would produce exactly the same PHP array:

    <variable name="theme_settings">
      <toggle_node_info_page>0</toggle_node_info_page>
      <toggle_node_info_example>0</toggle_node_info_example>
      <toggle_node_info_blog>1</toggle_node_info_blog>
      <toggle_favicon>0</toggle_favicon>
    </variable>
    <variable>
      <name>theme_settings</name>
      <toggle_node_info_page>0</toggle_node_info_page>
      <toggle_node_info_example>0</toggle_node_info_example>
      <toggle_node_info_blog>1</toggle_node_info_blog>
      <toggle_favicon>0</toggle_favicon>
    </variable>

"Value" in YAML should be used only when corresponding XML action has a string as a value. For example:

    <theme>garland</theme>

or

    <variable name="site_name">Drupal 6</variable>

Above two examples would be translated to YAML in the following way:

  - tag: variable
      name: site_name
      value: Drupal 6
  - tag: theme
      value: garland

I hope this helps.
Vaish

michaek’s picture

Looks great. I don't know why I assumed it was necessary to put the values in another structure. Thanks!

vaish’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.